node-red-contrib-presence-faker icon indicating copy to clipboard operation
node-red-contrib-presence-faker copied to clipboard

Feature request: Save entity state before, restore after

Open windsurferwill opened this issue 1 year ago • 4 comments

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".

windsurferwill avatar Oct 28 '23 12:10 windsurferwill

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?

csuermann avatar Oct 31 '23 17:10 csuermann

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 avatar Oct 31 '23 17:10 windsurferwill

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

windsurferwill avatar Oct 31 '23 18:10 windsurferwill

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.

csuermann avatar Nov 03 '23 07:11 csuermann