From fc17b820215bd41d85beccbbc51d6b69318a2fb2 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 28 Feb 2021 15:01:39 +0300 Subject: [PATCH] support response for extenders --- custom_components/mega/http.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/custom_components/mega/http.py b/custom_components/mega/http.py index 72f2b2a..8a9bc6a 100644 --- a/custom_components/mega/http.py +++ b/custom_components/mega/http.py @@ -118,8 +118,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]: