mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87492be38f | ||
|
|
0fab2384b0 | ||
|
|
70a2e5bbb0 | ||
|
|
83c843d722 | ||
|
|
af684a6c00 | ||
|
|
d94efbe1a7 | ||
|
|
eaa46a99ae | ||
|
|
e65598fe63 | ||
|
|
e12ab45c04 | ||
|
|
7fb72be646 |
@@ -99,7 +99,7 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: {
|
||||
vol.Optional(CONF_ALLOW_HOSTS): [str],
|
||||
vol.Required(str, description='id меги из веб-интерфейса'): {
|
||||
vol.Optional(vol.Any(str, int), description='id меги из веб-интерфейса'): {
|
||||
vol.Optional(CONF_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
|
||||
vol.Optional(
|
||||
CONF_DEF_RESPONSE,
|
||||
|
||||
@@ -64,7 +64,7 @@ LUX = 'lux'
|
||||
SINGLE_CLICK = 'single'
|
||||
DOUBLE_CLICK = 'double'
|
||||
|
||||
PATT_FW = re.compile(r'fw:\s(.+)\)')
|
||||
PATT_FW = re.compile(r'fw:\s(.+?)\)')
|
||||
|
||||
REMOVE_CONFIG = [
|
||||
'extenders',
|
||||
|
||||
@@ -296,7 +296,7 @@ class MegaOutPort(MegaPushEntity):
|
||||
def max_dim(self):
|
||||
if self.dimmer_scale == 1:
|
||||
return 255
|
||||
elif self.dimmer == 16:
|
||||
elif self.dimmer_scale == 16:
|
||||
return 4095
|
||||
else:
|
||||
return 255
|
||||
|
||||
@@ -91,6 +91,7 @@ class MegaD:
|
||||
**kwargs,
|
||||
):
|
||||
"""Initialize."""
|
||||
self.skip_ports = set()
|
||||
if config is not None:
|
||||
lg.debug(f'load config: %s', config.data)
|
||||
self.config = config
|
||||
@@ -477,6 +478,11 @@ class MegaD:
|
||||
:param params: параметры url
|
||||
:return:
|
||||
"""
|
||||
pt = params.get('pt')
|
||||
if pt in self.skip_ports:
|
||||
return
|
||||
if pt is not None:
|
||||
pass
|
||||
_params = tuple(params.items())
|
||||
delay = None
|
||||
if 'delay' in params:
|
||||
|
||||
@@ -6,6 +6,7 @@ from homeassistant.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_CO2,
|
||||
PERCENTAGE,
|
||||
LIGHT_LUX,
|
||||
TEMP_CELSIUS,
|
||||
@@ -103,6 +104,10 @@ i2c_classes = {
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None)
|
||||
],
|
||||
'dps368': [
|
||||
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'mlx90614': [
|
||||
Skip,
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'),
|
||||
@@ -119,9 +124,21 @@ i2c_classes = {
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
|
||||
],
|
||||
't67xx': [
|
||||
DeviceType(None, CONCENTRATION_PARTS_PER_MILLION, None) # для co2 нет класса в HA
|
||||
DeviceType(DEVICE_CLASS_CO2, CONCENTRATION_PARTS_PER_MILLION, None)
|
||||
],
|
||||
'tmp117': [
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
]
|
||||
],
|
||||
'ads1115': [
|
||||
DeviceType(None, None, 'ch0'),
|
||||
DeviceType(None, None, 'ch1'),
|
||||
DeviceType(None, None, 'ch2'),
|
||||
DeviceType(None, None, 'ch3'),
|
||||
],
|
||||
'ads1015': [
|
||||
DeviceType(None, None, 'ch0'),
|
||||
DeviceType(None, None, 'ch1'),
|
||||
DeviceType(None, None, 'ch2'),
|
||||
DeviceType(None, None, 'ch3'),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "mega",
|
||||
"name": "mega",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/mega_hacs",
|
||||
"documentation": "https://github.com/andvikt/mega_hacs",
|
||||
"requirements": [
|
||||
"beautifulsoup4",
|
||||
"lxml"
|
||||
@@ -15,5 +15,5 @@
|
||||
"@andvikt"
|
||||
],
|
||||
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
|
||||
"version": "v1.0.1"
|
||||
"version": "v1.0.7"
|
||||
}
|
||||
@@ -20,7 +20,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.template import Template
|
||||
from .entities import MegaPushEntity
|
||||
from .const import CONF_KEY, TEMP, HUM, W1, W1BUS, CONF_CONV_TEMPLATE, CONF_HEX_TO_FLOAT
|
||||
from .const import CONF_KEY, TEMP, HUM, W1, W1BUS, CONF_CONV_TEMPLATE, CONF_HEX_TO_FLOAT, DOMAIN, CONF_CUSTOM, CONF_SKIP
|
||||
from .hub import MegaD
|
||||
import re
|
||||
|
||||
@@ -84,9 +84,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
mid = config_entry.data[CONF_ID]
|
||||
hub: MegaD = hass.data['mega'][mid]
|
||||
devices = []
|
||||
customize = hass.data.get(DOMAIN, {}).get(CONF_CUSTOM, {}).get(mid, {})
|
||||
for tp in ['sensor', 'i2c']:
|
||||
for port, cfg in config_entry.data.get(tp, {}).items():
|
||||
port = int_ignore(port)
|
||||
c = customize.get(port, {})
|
||||
if c.get(CONF_SKIP):
|
||||
hub.skip_ports |= {port}
|
||||
continue
|
||||
for data in cfg:
|
||||
hub.lg.debug(f'add sensor on port %s with data %s', port, data)
|
||||
sensor = _constructors[tp](
|
||||
|
||||
Reference in New Issue
Block a user