csuermann / node-red-contrib-presence-faker

Node-RED node that fakes presence in a smart home by switching devices (e.g. lights) on and off at random times.
MIT License
24 stars 2 forks source link

Feature request: Save entity state before, restore after #55

Open windsurferwill opened 8 months ago

windsurferwill commented 8 months ago

Love this! Would you please consider adding the following capability? It would be useful to remember the entity's state prior to enabling presence faker then restore the state afterwards. So "when disabled" there would be a new option of "restore to initial state" in addition to "turn on", "turn off", "do nothing".

csuermann commented 8 months ago

Hi @windsurferwill,

Thanks for reaching out! Just to make sure I understand your suggestion correctly: How do you envision presence faker to know a device's state prior to enabling it?

windsurferwill commented 8 months ago

I really appreciate you reaching out. 

I'm was thinking of the functionality of the 'on-the-fly' Scenes functionality per https://www.home-assistant.io/integrations/scene/ which captures the current state of a set of entities and allows you to restore them as well. Would something like this help?

https://community.home-assistant.io/t/fetch-entity-state-in-a-function-node/174613/6

Steve

windsurferwill commented 8 months ago

I think if I were doing this in node-red as a node function I'd use something like the 'current_state' node.

csuermann commented 8 months ago

One possible way of going about this could be to feed all device state changes as they happen into the presence-faker node for it to remember it, so that once the end of a schedule has come, it can emit the appropriate final msg.

It would be good if presence-faker could somehow "query" a device's state before a schedule starts, but as far as I know, this is not how Node-RED works.