Compare commits

...

3 Commits

Author SHA1 Message Date
Andrey
7e02797be8 fix http response 2021-02-18 11:58:33 +03:00
Andrey
035bdebf64 fix ds2413 2021-02-18 11:42:23 +03:00
Andrey
8d92bbdfb3 ad more logging 2021-02-18 11:23:44 +03:00
2 changed files with 5 additions and 4 deletions

View File

@@ -253,7 +253,7 @@ class MegaOutPort(MegaPushEntity):
return self._state == 'ON'
elif val is not None:
val = val.get("value")
if self.index and self.addr:
if self.index is not None and self.addr is not None:
if not isinstance(val, dict):
self.mega.lg.warning(f'{self.entity_id}: {val} is not a dict')
return
@@ -263,14 +263,15 @@ class MegaOutPort(MegaPushEntity):
return
_val = _val.split('/')
if len(_val) >= 2:
self.mega.lg.debug('%s parsed values: %s[%s]="%s"', self.entity_id, _val, self.index, _val)
val = _val[self.index]
else:
self.mega.lg.warning(f'{self.entity_id}: {_val} has wrong length')
return
elif self.index and self.addr is None:
elif self.index is not None and self.addr is None:
self.mega.lg.warning(f'{self.entity_id} does not has addr')
return
self.mega.lg.debug('%s.state = %s', self.entity_id, val)
if not self.invert:
return val == 'ON' or str(val) == '1' or (safe_int(val) is not None and safe_int(val) > 0)
else:

View File

@@ -78,7 +78,7 @@ class MegaView(HomeAssistantView):
template.hass = hass
ret = template.async_render(data)
_LOGGER.debug('response %s', ret)
ret = Response(body='', content_type='text/plain', headers={'Server': 's', 'Date': 'n'})
Response(body='', content_type='text/plain', headers={'Server': 's', 'Date': 'n'})
await hub.request(cmd=ret)
return ret