Compare commits

...

15 Commits

Author SHA1 Message Date
Викторов Андрей Германович
74235a39ad Bump version: 1.0.10b12 → 1.0.10b13 2021-10-29 10:03:22 +03:00
Викторов Андрей Германович
61bcbbd103 add more debug log info 2021-10-29 10:03:18 +03:00
andvikt
6411e6e5f9 Bump version: 1.0.10b11 → 1.0.10b12 2021-10-29 09:13:52 +03:00
andvikt
2020a840a8 timeouts 2021-10-29 09:13:48 +03:00
andvikt
f6c2cd025e Bump version: 1.0.10b10 → 1.0.10b11 2021-10-28 20:14:33 +03:00
andvikt
ab599cd59d . 2021-10-28 20:14:30 +03:00
andvikt
a349cbd4a4 . 2021-10-28 20:13:49 +03:00
andvikt
bd1ba0379f Bump version: 1.0.10b9 → 1.0.10b10 2021-10-28 20:03:15 +03:00
andvikt
70016dd69d . 2021-10-28 20:03:09 +03:00
andvikt
5617e7afa5 Bump version: 1.0.10b9 → 1.0.11b0 2021-10-28 20:01:49 +03:00
andvikt
bcdec2d793 . 2021-10-28 20:01:18 +03:00
Викторов Андрей Германович
c4aae6b3ec Bump version: 1.0.10b8 → 1.0.10b9 2021-10-28 16:41:39 +03:00
Викторов Андрей Германович
58d243dcc3 новы способ адресации кастомизаций 2021-10-28 16:41:36 +03:00
Викторов Андрей Германович
3488d4593a Bump version: 1.0.10b7 → 1.0.10b8 2021-10-28 15:57:59 +03:00
Викторов Андрей Германович
76b8988b83 only bin sensors can update state in http mode 2021-10-28 15:57:55 +03:00
8 changed files with 19 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.10b7
current_version = 1.0.10b13
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(?P<release>[bf]*)(?P<build>\d*)
commit = True
tag = True

View File

@@ -104,6 +104,11 @@ CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: {
vol.Optional(CONF_ALLOW_HOSTS): [str],
vol.Optional('entities'): {
vol.Optional(str): vol.Any(
CUSTOMIZE_PORT,
CUSTOMIZE_DS2413
)},
vol.Optional(vol.Any(str, int), description='id меги из веб-интерфейса'): {
vol.Optional(CONF_FORCE_D, description='Принудительно слать d после срабатывания входа', default=False): bool,
vol.Optional(

View File

@@ -67,6 +67,7 @@ class MegaBinarySensor(BinarySensorEntity, MegaPushEntity):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.mega.binary_sensors.append(self.port)
self._is_on = None
self._attrs = None
self._click_task = None

View File

@@ -129,12 +129,14 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
if self.hass is None:
return {}
if self._customize is None:
c_entity_id = self.hass.data.get(DOMAIN, {}).get('entities', {}).get(self.entity_id, {})
c = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM) or {}
c = c.get(self._mega_id) or {}
c = c.get(self.port) or {}
if self.addr is not None and self.index is not None and isinstance(c, dict):
idx = self.addr.lower() + f'_a' if self.index == 0 else '_b'
c = c.get(idx, {})
c.update(c_entity_id)
self._customize = c
return self._customize

View File

@@ -134,7 +134,7 @@ class MegaView(HomeAssistantView):
if ret == 'd' and act:
await hub.request(cmd=act.replace(':3', f':{v}'))
ret = 'd' if hub.force_d else ''
else:
elif port in hub.binary_sensors:
hub.values[port] = data
for cb in self.callbacks[hub.id][port]:
cb(data)
@@ -147,7 +147,7 @@ class MegaView(HomeAssistantView):
_LOGGER.debug('response %s', ret)
Response(body='' if hub.fake_response else ret, content_type='text/plain')
if hub.fake_response and 'value' not in data and 'pt' in data:
if hub.fake_response and 'value' not in data and 'pt' in data and port in hub.binary_sensors:
if 'd' in ret:
await hub.request(pt=port, cmd=ret)
else:

View File

@@ -164,6 +164,7 @@ class MegaD:
hass.data[DOMAIN][CONF_HTTP].protected = protected
except Exception:
self.lg.exception('while setting allowed hosts')
self.binary_sensors = []
async def start(self):
pass
@@ -309,8 +310,8 @@ class MegaD:
return ret
except asyncio.TimeoutError:
self.lg.warning(f'timeout while requesting {url}')
raise
# await asyncio.sleep(1)
# raise
await asyncio.sleep(1)
raise asyncio.TimeoutError('after 3 tries')
async def save(self):

View File

@@ -15,5 +15,5 @@
"@andvikt"
],
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
"version": "v1.0.10b7"
"version": "v1.0.10b13"
}

View File

@@ -115,6 +115,10 @@ class FilterBadValues(MegaPushEntity):
self._prev_value = None
def filter_value(self, value):
self.lg.debug(
'value=%s filter_low=%s filter_high=%s filter_scale=%s prev_value=%s filter_values=%s',
(value, self.filter_low, self.filter_high, self.filter_scale, self._prev_value, self.filter_values)
)
if value in self.filter_values \
or (self.filter_low is not None and value < self.filter_low) \
or (self.filter_high is not None and value > self.filter_high) \