diff --git a/README.md b/README.md index d3a53e4..2c496ba 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,12 @@ njsPC-HA communicates with nodejs-PoolController via the native API, the same wa - Salt Target - Salt Needed - pH/Orp +- Schedules (toggle) +- Chem Controllers +- Filters -## Not Supported -- ????? +# EVENT BUS +If there is something in nodejs-PoolController that isn't in njsPC-HA, you can maninpulate the data yourself. All incoming data is sent to the Home Assistant event bus under the event `njspc-ha_event`. You can subscribe and view these events in the `EVENTS` tab in `Developer Tools`. The event topic is found in `data.evt` and the data is `data.data`. These are the same messages that Dashpanel receives which you can view them by using the developer console on your browser. If you find something you think should be added to this integration, just let us know. # Home Assistant ![Home Assistant](/images/lovelace.png) diff --git a/custom_components/njspc_ha/__init__.py b/custom_components/njspc_ha/__init__.py index 351832d..aa7175e 100644 --- a/custom_components/njspc_ha/__init__.py +++ b/custom_components/njspc_ha/__init__.py @@ -132,66 +132,79 @@ async def sio_connect(self): async def handle_temps(data): data["event"] = EVENT_TEMPS self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("pump") async def handle_pump(data): data["event"] = EVENT_PUMP self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("circuit") async def handle_circuit(data): data["event"] = EVENT_CIRCUIT self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("chlorinator") async def handle_chlorinator(data): data["event"] = EVENT_CHLORINATOR self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("chemController") async def handle_chem_controller(data): data["event"] = EVENT_CHEM_CONTROLLER self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("body") async def handle_body(data): data["event"] = EVENT_BODY self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("lightGroup") async def handle_lightgroup(data): data["event"] = EVENT_LIGHTGROUP self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("circuitGroup") async def handle_circuitgroup(data): data["event"] = EVENT_CIRCUITGROUP self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("feature") async def handle_feature(data): data["event"] = EVENT_FEATURE self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("controller") async def handle_controller(data): data["event"] = EVENT_CONTROLLER self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("filter") async def handle_filter(data): data["event"] = EVENT_FILTER self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("virtualCircuit") async def handle_virtual_circuit(data): data["event"] = EVENT_VIRTUAL_CIRCUIT self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.on("schedule") async def handle_schedule(data): data["event"] = EVENT_SCHEDULE self.async_set_updated_data(data) + self.send_to_bus(data) @self.sio.event async def connect(): @@ -220,6 +233,11 @@ async def sio_close(self): """Close the connection to njsPC""" await self.sio.disconnect() + def send_to_bus(self, data): + """Send incoming messages to HA event bus""" + bus_data = {"evt": data["event"], "data": data} + self.hass.bus.async_fire("njspc-ha_event", bus_data) + class NjsPCHAapi: """API for sending data to nodejs-PoolController"""