hufftheweevil / node-red-contrib-persistent-fsm

A Node Red node that wraps around Javascript State Machine
Other
4 stars 7 forks source link

State not persisted on deployment #13

Open Stadicus opened 1 year ago

Stadicus commented 1 year ago

I use Node Red as part of Home Assistant. The node-red-contrib-persistent-fsm is amazing! It helps control many things like blinds and lights with very few buttons, as it keeps track of the state and can act intelligently with the next press on the same button.

This worked great until about two weeks ago. Suddenly, things started to act weird. For example, blinds started going into the open position in the morning. There was no change in the Node-Red flows at that time. I updated a few things (Home Assistant and Node Red itself), but I'm not sure how closely related that is.

I attach a quick screencast to demonstrate:

https://github.com/hufftheweevil/node-red-contrib-persistent-fsm/assets/19550140/7529eeea-4fe7-442f-845b-ed24ed1a65c4

This is the flow export from this example:

[{"id":"bb4fd94092510052","type":"tab","label":"State Machine not persistent","disabled":false,"info":"","env":[]},{"id":"cbb840864cfb0a79","type":"inject","z":"bb4fd94092510052","name":"m","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":130,"y":120,"wires":[["1b3e44b669aa1d14"]]},{"id":"1b3e44b669aa1d14","type":"state-machine","z":"bb4fd94092510052","name":"Blinds","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","initialDelay":"","persistOnReload":true,"outputStateChangeOnly":true,"throwException":false,"states":["closed","open"],"transitions":[{"name":"toggle","from":"closed","to":"open"},{"name":"toggle","from":"open","to":"closed"}],"x":290,"y":140,"wires":[["657d41f0b789875e"]]},{"id":"657d41f0b789875e","type":"switch","z":"bb4fd94092510052","name":"Action OPEN / CLOSE","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"OPEN","vt":"str"},{"t":"eq","v":"CLOSE","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":480,"y":140,"wires":[["1ffbcc68a82b3c6d"],["030ab2f9181a1911"]]},{"id":"1ffbcc68a82b3c6d","type":"api-call-service","z":"bb4fd94092510052","d":true,"name":"Blinds OPEN","server":"f915e846.bc0e18","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.markise_terrasse_alle"],"data":"{ \"position\": 25 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":120,"wires":[[]]},{"id":"030ab2f9181a1911","type":"api-call-service","z":"bb4fd94092510052","d":true,"name":"Blinds CLOSE","server":"f915e846.bc0e18","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.markise_terrasse_alle"],"data":"{ \"position\": 100 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":180,"wires":[[]]},{"id":"f915e846.bc0e18","type":"server","name":"Home Assistant","addon":true}]

I'm not quite sure where to start debugging. Maybe I'm doing something wrong? Maybe the Node Red update broke something? Maybe the underlying data storage is no longer working?

Any help would be greatly appreciated.

ximon commented 10 months ago

I've just encountered this myself and found that persisting context to the filesystem makes this work as expected. I added the config from the 'Saving context data to the file-system' section on this page.