Compare commits

...

11 Commits

Author SHA1 Message Date
Andrey
54f1ebeda3 fix some issues with brightness after restart 2021-07-29 21:30:41 +03:00
Andrey
87492be38f fix dimmer_scale for PCA9685 2021-07-25 08:36:12 +03:00
Andrey
0fab2384b0 fix patt 2021-04-21 10:08:28 +03:00
Andrey
70a2e5bbb0 fix patt 2021-04-20 17:00:31 +03:00
Andrey
83c843d722 fix validation error 2021-04-20 09:23:36 +03:00
Andrey
af684a6c00 fix validation error 2021-04-20 09:19:37 +03:00
Andrey
d94efbe1a7 add ADS1115
add DEVICE_CLASS_CO2
2021-04-20 09:11:00 +03:00
Andrey
eaa46a99ae fix fw pattern
add dps368 support
fix docs url
2021-04-20 07:37:39 +03:00
Andrey
e65598fe63 fix int mega id 2021-04-20 07:35:59 +03:00
Andrey
e12ab45c04 fix int mega id 2021-04-20 07:35:06 +03:00
Andrey
7fb72be646 add skip sensors 2021-04-19 22:03:30 +03:00
7 changed files with 37 additions and 9 deletions

View File

@@ -99,7 +99,7 @@ CONFIG_SCHEMA = vol.Schema(
{ {
DOMAIN: { DOMAIN: {
vol.Optional(CONF_ALLOW_HOSTS): [str], 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_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
vol.Optional( vol.Optional(
CONF_DEF_RESPONSE, CONF_DEF_RESPONSE,

View File

@@ -64,7 +64,7 @@ LUX = 'lux'
SINGLE_CLICK = 'single' SINGLE_CLICK = 'single'
DOUBLE_CLICK = 'double' DOUBLE_CLICK = 'double'
PATT_FW = re.compile(r'fw:\s(.+)\)') PATT_FW = re.compile(r'fw:\s(.+?)\)')
REMOVE_CONFIG = [ REMOVE_CONFIG = [
'extenders', 'extenders',

View File

@@ -296,7 +296,7 @@ class MegaOutPort(MegaPushEntity):
def max_dim(self): def max_dim(self):
if self.dimmer_scale == 1: if self.dimmer_scale == 1:
return 255 return 255
elif self.dimmer == 16: elif self.dimmer_scale == 16:
return 4095 return 4095
else: else:
return 255 return 255
@@ -421,7 +421,7 @@ class MegaOutPort(MegaPushEntity):
self._last_called = time.time() self._last_called = time.time()
if not self.dimmer: if not self.dimmer:
transition = None transition = None
if not self.is_on: if not self.is_on and (brightness is None or brightness == 0):
brightness = self._restore_brightness brightness = self._restore_brightness
brightness = brightness or self.brightness or 255 brightness = brightness or self.brightness or 255
_prev = safe_int(self.brightness) or 0 _prev = safe_int(self.brightness) or 0

View File

@@ -91,6 +91,7 @@ class MegaD:
**kwargs, **kwargs,
): ):
"""Initialize.""" """Initialize."""
self.skip_ports = set()
if config is not None: if config is not None:
lg.debug(f'load config: %s', config.data) lg.debug(f'load config: %s', config.data)
self.config = config self.config = config
@@ -477,6 +478,11 @@ class MegaD:
:param params: параметры url :param params: параметры url
:return: :return:
""" """
pt = params.get('pt')
if pt in self.skip_ports:
return
if pt is not None:
pass
_params = tuple(params.items()) _params = tuple(params.items())
delay = None delay = None
if 'delay' in params: if 'delay' in params:

View File

@@ -6,6 +6,7 @@ from homeassistant.const import (
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_PRESSURE, DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_CO2,
PERCENTAGE, PERCENTAGE,
LIGHT_LUX, LIGHT_LUX,
TEMP_CELSIUS, TEMP_CELSIUS,
@@ -103,6 +104,10 @@ i2c_classes = {
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None) DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None)
], ],
'dps368': [
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
],
'mlx90614': [ 'mlx90614': [
Skip, Skip,
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'), DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'),
@@ -119,9 +124,21 @@ i2c_classes = {
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
], ],
't67xx': [ 't67xx': [
DeviceType(None, CONCENTRATION_PARTS_PER_MILLION, None) # для co2 нет класса в HA DeviceType(DEVICE_CLASS_CO2, CONCENTRATION_PARTS_PER_MILLION, None)
], ],
'tmp117': [ 'tmp117': [
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), 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'),
],
} }

View File

@@ -2,7 +2,7 @@
"domain": "mega", "domain": "mega",
"name": "mega", "name": "mega",
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/mega_hacs", "documentation": "https://github.com/andvikt/mega_hacs",
"requirements": [ "requirements": [
"beautifulsoup4", "beautifulsoup4",
"lxml" "lxml"
@@ -15,5 +15,5 @@
"@andvikt" "@andvikt"
], ],
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues", "issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
"version": "v1.0.1" "version": "v1.0.8"
} }

View File

@@ -20,7 +20,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.template import Template from homeassistant.helpers.template import Template
from .entities import MegaPushEntity 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 from .hub import MegaD
import re import re
@@ -84,9 +84,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
mid = config_entry.data[CONF_ID] mid = config_entry.data[CONF_ID]
hub: MegaD = hass.data['mega'][mid] hub: MegaD = hass.data['mega'][mid]
devices = [] devices = []
customize = hass.data.get(DOMAIN, {}).get(CONF_CUSTOM, {}).get(mid, {})
for tp in ['sensor', 'i2c']: for tp in ['sensor', 'i2c']:
for port, cfg in config_entry.data.get(tp, {}).items(): for port, cfg in config_entry.data.get(tp, {}).items():
port = int_ignore(port) port = int_ignore(port)
c = customize.get(port, {})
if c.get(CONF_SKIP):
hub.skip_ports |= {port}
continue
for data in cfg: for data in cfg:
hub.lg.debug(f'add sensor on port %s with data %s', port, data) hub.lg.debug(f'add sensor on port %s with data %s', port, data)
sensor = _constructors[tp]( sensor = _constructors[tp](