Digital-Alchemy-TS / hass

Typescript APIs for Home Assistant. Includes rest & websocket bindings
https://docs.digital-alchemy.app
MIT License
5 stars 2 forks source link

Add entities to turn addon on/off #23

Open chrisdrackett opened 3 months ago

chrisdrackett commented 3 months ago

Right now I'm running into an issue where if I'm doing development on my computer while the addon is running on HASS they sometimes conflict as they are both running similar but often not the same code. To get around this I currently need to turn the automations running on HASS off while doing development.

I've added a toggle helper that is turned on by the dev server when its running and in production stops all my automations from running. I'm just wondering if others are doing non-local dev if this might be a useful built-in feature.

zoe-codez commented 3 months ago

There is support for this type of operation in the library, but it's not well documented & requires some implementation details by the dev.

https://github.com/Digital-Alchemy-TS/hass/blob/main/src/extensions/websocket-api.extension.ts#L670

hass.socket.pauseMessages = true

Setting this will cause entity update events to not fire, and for the socket to black hole outgoing messages. Internal workflows, such as maintaining accurate state & registry should still work properly, allowing it to pick up without missing a beat.

I haven't run across a standardized approach to automatically controlling that flag that'd work out of the box though. When the upgraded synapse integration is complete, this would probably be a lot more straightforward to accomplish

chrisdrackett commented 3 months ago

I think I can still probably use this, basically just toggle this based on my switch vs. building a wrapper like I've done so far :)