Compare commits

..

5 Commits

Author SHA1 Message Date
Andrey
ad1210d5cc fix some timeouts 2021-03-29 21:43:25 +03:00
Andrey Viktorov
687e80f729 fix empty config while first setup 2021-03-29 19:54:48 +03:00
Andrey Viktorov
7d777c9e82 fix sensors 2021-03-24 18:14:15 +03:00
Andrey Viktorov
c9f0e85f6a edit readme 2021-03-24 17:04:37 +03:00
andvikt
e75f8b91ef Update sensor.py 2021-03-24 12:40:39 +03:00
3 changed files with 20 additions and 15 deletions

View File

@@ -157,11 +157,10 @@ class MegaD:
if force_d is not None:
self.customize[CONF_FORCE_D] = force_d
try:
if allow_hosts is not None:
if allow_hosts is not None and DOMAIN in hass.data:
allow_hosts = set(allow_hosts.split(';'))
hass.data[DOMAIN][CONF_HTTP].allowed_hosts |= allow_hosts
hass.data[DOMAIN][CONF_HTTP].protected = protected
except Exception:
self.lg.exception('while setting allowed hosts')
@@ -290,6 +289,8 @@ class MegaD:
url = f"{url}/?{cmd}"
self.lg.debug('request: %s', url)
async with self._http_lck(priority):
for _ntry in range(3):
try:
async with aiohttp.request("get", url=url) as req:
if req.status != 200:
self.lg.warning('%s returned %s (%s)', url, req.status, await req.text())
@@ -298,6 +299,10 @@ class MegaD:
ret = await req.text()
self.lg.debug('response %s', ret)
return ret
except asyncio.TimeoutError:
self.lg.warning(f'timeout while requesting {url}')
await asyncio.sleep(1)
raise asyncio.TimeoutError('after 3 tries')
async def save(self):
await self.send_command(cmd='s')

View File

@@ -146,7 +146,7 @@ class MegaI2C(MegaPushEntity):
ret = tmpl.async_render({'value': ret})
except:
ret = ret
return ret
return str(ret)
@property
def device_class(self):
@@ -241,7 +241,8 @@ class Mega1WSensor(MegaPushEntity):
tmpl.hass = self.hass
ret = tmpl.async_render({'value': ret})
except:
return ret
pass
return str(ret)
@property
def name(self):

View File

@@ -26,7 +26,6 @@
[подробнее про smooth](https://github.com/andvikt/mega_hacs/wiki/smooth)
- Возможность работы с несколькими megad
- Обратная связь по [http](https://github.com/andvikt/mega_hacs/wiki/http)
будет выключена в версиях >= 1.0.0, тк в нем нет необходимости)
- Автоматическое восстановление состояний выходов после перезагрузки контроллера
- Автоматическое добавление/изменение объектов после перезагрузки контроллера
- [События](https://github.com/andvikt/mega_hacs/wiki/События) на двойные/долгие нажатия