mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2f412b89e | ||
|
|
8fa14cdbc5 | ||
|
|
fc17b82021 |
@@ -63,7 +63,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for mega."""
|
||||
|
||||
VERSION = 15
|
||||
VERSION = 16
|
||||
CONNECTION_CLASS = config_entries.CONN_CLASS_ASSUMED
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
|
||||
@@ -106,7 +106,8 @@ class MegaView(HomeAssistantView):
|
||||
else:
|
||||
pt_orig = hub.ext_in.get(port)
|
||||
if pt_orig is None:
|
||||
hub.lg.warning(f'can not find extender for int port {port}')
|
||||
hub.lg.warning(f'can not find extender for int port {port}, '
|
||||
f'have ext_int: {hub.ext_in}, ext: {hub.extenders}')
|
||||
return Response(status=200)
|
||||
for e, v in data.items():
|
||||
if e.startswith('ext'):
|
||||
@@ -118,8 +119,14 @@ class MegaView(HomeAssistantView):
|
||||
hub.values[pt] = data
|
||||
for cb in self.callbacks[hub.id][pt]:
|
||||
cb(data)
|
||||
if pt in hub.ext_act:
|
||||
await hub.request(cmd=hub.ext_act[pt])
|
||||
act = hub.ext_act.get(pt)
|
||||
template: Template = self.templates.get(hub.id, {}).get(port, hub.def_response)
|
||||
if template is not None:
|
||||
template.hass = hass
|
||||
ret = template.async_render(data)
|
||||
if ret == 'd' and act:
|
||||
await hub.request(cmd=act)
|
||||
ret = 'd' if hub.force_d else ''
|
||||
else:
|
||||
hub.values[port] = data
|
||||
for cb in self.callbacks[hub.id][port]:
|
||||
|
||||
@@ -82,7 +82,7 @@ class MegaD:
|
||||
restore_on_restart=False,
|
||||
extenders=None,
|
||||
ext_in=None,
|
||||
ext_act=None,
|
||||
ext_acts=None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Initialize."""
|
||||
@@ -99,7 +99,7 @@ class MegaD:
|
||||
self.http = None
|
||||
self.extenders = extenders or []
|
||||
self.ext_in = ext_in or {}
|
||||
self.ext_act = ext_act or {}
|
||||
self.ext_act = ext_acts or {}
|
||||
self.poll_outs = poll_outs
|
||||
self.update_all = update_all if update_all is not None else True
|
||||
self.nports = nports
|
||||
@@ -539,7 +539,8 @@ class MegaD:
|
||||
])
|
||||
elif cfg == MCP230:
|
||||
extenders.append(port)
|
||||
ext_int[int(cfg.inta)] = port
|
||||
if cfg.inta:
|
||||
ext_int[int_ignore(cfg.inta)] = port
|
||||
values = await self.request(pt=port, cmd='get')
|
||||
values = values.split(';')
|
||||
for n in range(len(values)):
|
||||
|
||||
Reference in New Issue
Block a user