Washing Machine State Machine

Hi All,

this is defenitely a great thread about things weare able to do with openhab. I build a state machine as a rule in openHAB and it worked like a charm, but then i found the article about NodeRed. Thanks to @rgerrans

Because i heared often about NodeRed as one of THE IoT tools, i decided to give it a try. Installed NodeRed on an fresh openHABian installation (Thanks @ThomDietrich) and startet.

It is really simple to work with NodeRed just open the broswer an goto http://NodeRedServer:1880/ and start. I searched around and found the FSM node that represents a Finite State Machine in one node. Perfect, but as we know we have a little timer issue to overcome this jitter problem with many of the washing machines and therefore i could not use the FSM node.

Ok, i had to build the FSM with timer support on my own. The standard time in NodeRed could be retriggered, but not stopped, so i had to find a silution on this → stoptimer node did the trick for me.

At the end i created a flow that receives the power consumption from an item and sets the surrent sate of the washing machine using a String item.

For all who are interested the flow to import it into node red

[{“id”:“b6da215f.92716”,“type”:“tab”,“label”:“Washing Machine State Machine”},{“id”:“329acfe5.fbe06”,“type”:“openhab2-in”,“z”:“b6da215f.92716”,“name”:“WashingMachinePower”,“controller”:“e0c90f4f.513a8”,“itemname”:“WashingMachinePower”,“x”:120,“y”:600,“wires”:[[“172bb3e6.e94fcc”],]},{“id”:“172bb3e6.e94fcc”,“type”:“switch”,“z”:“b6da215f.92716”,“name”:“evaluate power”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“lt”,“v”:“2”,“vt”:“num”},{“t”:“lt”,“v”:“4”,“vt”:“num”},{“t”:“gt”,“v”:“10”,“vt”:“num”}],“checkall”:“false”,“outputs”:3,“x”:320,“y”:600,“wires”:[[“b5c4128b.3c3e3”],[“83b083d2.51a1e”],[“4e5a7235.047f3c”]]},{“id”:“1cf011b8.ce5d8e”,“type”:“switch”,“z”:“b6da215f.92716”,“name”:“evaluate state on power below 2W”,“property”:“payload.state”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“STATE_OFF”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_STANDBY”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_ACTIVE”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_FINISHED”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“outputs”:5,“x”:860,“y”:340,“wires”:[[“c270265e.13e1f8”],[“c270265e.13e1f8”],[“2a38ca8.538d236”],[“c270265e.13e1f8”],[“c270265e.13e1f8”]]},{“id”:“b5c4128b.3c3e3”,“type”:“openhab2-get”,“z”:“b6da215f.92716”,“name”:“WashingMachineState”,“controller”:“e0c90f4f.513a8”,“itemname”:“WashingMachineState”,“x”:540,“y”:540,“wires”:[[“1cf011b8.ce5d8e”]]},{“id”:“35249b23.f02864”,“type”:“openhab2-out”,“z”:“b6da215f.92716”,“name”:“Set WashingMachineState”,“controller”:“e0c90f4f.513a8”,“itemname”:“WashingMachineState”,“topic”:“ItemUpdate”,“payload”:“”,“x”:1880,“y”:580,“wires”:},{“id”:“2a38ca8.538d236”,“type”:“stoptimer”,“z”:“b6da215f.92716”,“duration”:“150”,“units”:“Second”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“”,“x”:1130,“y”:440,“wires”:[[“c270265e.13e1f8”],]},{“id”:“c270265e.13e1f8”,“type”:“change”,“z”:“b6da215f.92716”,“name”:“set STATE_OFF”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STATE_OFF”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1380,“y”:400,“wires”:[[“fc76d58.c9a6c28”]]},{“id”:“83b083d2.51a1e”,“type”:“openhab2-get”,“z”:“b6da215f.92716”,“name”:“WashingMachineState”,“controller”:“e0c90f4f.513a8”,“itemname”:“WashingMachineState”,“x”:540,“y”:600,“wires”:[[“ec78584d.73ef78”]]},{“id”:“ec78584d.73ef78”,“type”:“switch”,“z”:“b6da215f.92716”,“name”:“evaluate state on power below 4W”,“property”:“payload.state”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“STATE_OFF”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_STANDBY”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_ACTIVE”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_FINISHED”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“outputs”:5,“x”:860,“y”:640,“wires”:[[“ac335bda.d55018”],[“ac335bda.d55018”],[“d4d30b61.0754d8”],[“e2463e68.5343d”],[“ac335bda.d55018”]]},{“id”:“ac335bda.d55018”,“type”:“change”,“z”:“b6da215f.92716”,“name”:“set STATE_STANDBY”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STATE_STANDBY”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1400,“y”:620,“wires”:[[“fc76d58.c9a6c28”]]},{“id”:“e2463e68.5343d”,“type”:“change”,“z”:“b6da215f.92716”,“name”:“set STATE_FINISHED”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STATE_FINISHED”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1400,“y”:520,“wires”:[[“fc76d58.c9a6c28”]]},{“id”:“d4d30b61.0754d8”,“type”:“stoptimer”,“z”:“b6da215f.92716”,“duration”:“150”,“units”:“Second”,“payloadtype”:“num”,“payloadval”:“0”,“name”:“”,“x”:1130,“y”:500,“wires”:[[“e2463e68.5343d”],]},{“id”:“4e5a7235.047f3c”,“type”:“openhab2-get”,“z”:“b6da215f.92716”,“name”:“WashingMachineState”,“controller”:“e0c90f4f.513a8”,“itemname”:“WashingMachineState”,“x”:540,“y”:660,“wires”:[[“2ee8f606.cf76fa”,“9a4f86d0.2018a8”]]},{“id”:“2ee8f606.cf76fa”,“type”:“switch”,“z”:“b6da215f.92716”,“name”:“evaluate state on power above 10W”,“property”:“payload.state”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“STATE_OFF”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_STANDBY”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_ACTIVE”,“vt”:“str”},{“t”:“eq”,“v”:“STATE_FINISHED”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“outputs”:5,“x”:860,“y”:780,“wires”:[[“2f9848db.0c1c58”],[“2f9848db.0c1c58”],[“2f9848db.0c1c58”],[“2f9848db.0c1c58”],[“2f9848db.0c1c58”]]},{“id”:“9a4f86d0.2018a8”,“type”:“change”,“z”:“b6da215f.92716”,“name”:“send STOP”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STOP”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:850,“y”:480,“wires”:[[“d4d30b61.0754d8”,“2a38ca8.538d236”]]},{“id”:“2f9848db.0c1c58”,“type”:“change”,“z”:“b6da215f.92716”,“name”:“set STATE_ACTIVE”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“STATE_ACTIVE”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1400,“y”:720,“wires”:[[“fc76d58.c9a6c28”]]},{“id”:“7c4f6915.4e48e8”,“type”:“debug”,“z”:“b6da215f.92716”,“name”:“Debug Info”,“active”:true,“console”:“false”,“complete”:“payload”,“x”:1830,“y”:640,“wires”:},{“id”:“fc76d58.c9a6c28”,“type”:“rbe”,“z”:“b6da215f.92716”,“name”:“”,“func”:“rbei”,“gap”:“”,“start”:“”,“inout”:“out”,“x”:1670,“y”:580,“wires”:[[“35249b23.f02864”,“7c4f6915.4e48e8”]]},{“id”:“e0c90f4f.513a8”,“type”:“openhab2-controller”,“z”:“”,“name”:“openHAB”,“protocol”:“http”,“host”:“localhost”,“port”:“8080”,“path”:“”,“username”:“”,“password”:“”}]

Based on this experience, i this NodeRed is in minimum a perfect addon to the rule engine of openHAB and with openHABian it is a piece of cake to set it up.

Any comments, optimisations and and and are welcome.

Thomas

8 Likes