From b00a31d080c63d653d2c23455e25fa26e9687c25 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 23 Jan 2025 23:41:21 -0600 Subject: [PATCH] feat: rebuild device list --- ovos_PHAL_plugin_homeassistant/__init__.py | 3 ++- ovos_PHAL_plugin_homeassistant/logic/integration.py | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ovos_PHAL_plugin_homeassistant/__init__.py b/ovos_PHAL_plugin_homeassistant/__init__.py index 65db7d8..83704a8 100644 --- a/ovos_PHAL_plugin_homeassistant/__init__.py +++ b/ovos_PHAL_plugin_homeassistant/__init__.py @@ -97,6 +97,7 @@ def __init__(self, bus=None, config=None): self.bus.on("ovos.phal.plugin.homeassistant.get.light.color", self.handle_get_light_color) self.bus.on("ovos.phal.plugin.homeassistant.set.light.color", self.handle_set_light_color) self.bus.on("ovos.phal.plugin.homeassistant.check_connected", self.handle_check_connected) + self.bus.on("ovos.phal.plugin.homeassistant.rebuild.device.list", self.build_devices) # GUI EVENTS self.bus.on("ovos-PHAL-plugin-homeassistant.home", @@ -262,7 +263,7 @@ def init_configuration(self, message=None): self.bus.emit( Message("ovos.phal.plugin.homeassistant.requires.configuration")) - def build_devices(self): + def build_devices(self, message: Optional[Message] = None): """ Build the devices from the Home Assistant API """ for device in self.devices: device_type = map_entity_to_device_type(device["entity_id"]) diff --git a/ovos_PHAL_plugin_homeassistant/logic/integration.py b/ovos_PHAL_plugin_homeassistant/logic/integration.py index ec9c007..61826c7 100644 --- a/ovos_PHAL_plugin_homeassistant/logic/integration.py +++ b/ovos_PHAL_plugin_homeassistant/logic/integration.py @@ -5,7 +5,7 @@ class Integrator: # Class handles the integration of the plugin with the rest of the system - + def __init__(self, bus, gui): """ Constructor Args: @@ -15,11 +15,11 @@ def __init__(self, bus, gui): self.bus = bus self.gui = gui self.register_bus_listeners() - + def register_bus_listeners(self): self.bus.on('ovos.phal.plugin.homeassistant.integration.query_media', self.handle_query_media) - + def handle_query_media(self, message: Message): """ Handle a query to the media. Args: @@ -44,7 +44,3 @@ def handle_query_media(self, message: Message): self.gui.send_event( "ovos.phal.plugin.homeassistant.integration.query_media.result", {"results": collected_results}) - - - -