Xiaomi vacuum - Queue commands with HA and node red

Hi !

First time I post in this section, and I’m still a newbie at HA. Anyway, here’s what I’m working on using node-red and home assistant.

Note: there are probably easier and better ways to do this, and the project itself may not be that useful. I’m just having fun and learning in the meantime.

So, let’s get into it.

Background.
I purchased one of xiaomi’s robot vacuum cleaner, and I must say I’m very satisfied of it. With the help of many of you on this forum, I managed to integrate it into HA, enable zoned cleaning and even created a clickable floorplan that is most useful (all credits go to Stanvx, I copied his config for the vacuum).

"Problem"
I have this nice flooplan that I use to run the vacuum in, lets say, the living room:
image

-> What if I want the vacuum to go first in the Kitchen, but then in the living room ?

Sure, I could create a script that does that, but it’s not very useful since the combination and order of rooms to vacuum may vary quite a lot.
So I need to figure out how to “schedule” vacuum operations, and have a visual indication of what’s going on.

Also, I’m working on this dashboard that’ll include the status of the vacuum per room (Running, Scheduled, Off), so I also need to figure this out.

My current solution
I recently discovered Node red. Node red is fun. I like having fun. So I’ll use Node red.

I need to be able to send data from HA to node red, and somehow update the vacuum status. So here’s what I did:

Set up 2 input_select and mqtt script in HA

So on the front end, I get this:
image
image

Next, node red side, here’s what I made so far. The flow is a bit long so I’ll break it appart:

1- Get mqtt info from HA


This one’s pretty simple: Once a message is received with the proper topic, it’s converted to JSON and I make sure the input_select of the room is set to off (so in theory, nothing’s scheduled or running).

Then, the room enters the scheduled state. I want to wait for the value of the input to actually change (from false to scheduled), hence the wait node, but I’m not sure about this one …
The throttle node is here to prevent button spam.

2- Run vacuum, or queue command


So, the room is now in scheduled state.

  • If the vacuum is not running and available (in another room let’s say), it should be in charging mode. So if that’s the case, the message is forwarded directly (2nd output of the Vacuum state switch).
  • If there’s an error (vacuum stuck or something else), I get a notification via telegram.
  • If the vacuum is busy, then the instruction is added to the queue.

3- Manage queue


I like this one. It may not be the best way to do it, but I like the fact that it works. So, when the vacuum status change to charging it triggers a command that release the next item of the queue (for now I trigger it manually … still testing things).

The queue can be reset from HA using an input_boolean, but I’m not happy with that so I’m working on an alternative way.

There’s also so stuff about a counter … It’s too early to discuss it, I’m not even sure what I want to do with this one.

3- Run vacuum


Once a message is released from the queue (or directly if the vacuum is available), the room enters the Running state and the script that runs the vacuum is called (simple zone cleaning command … it’s only a debug node for now).

The good part is, once it returns to its base and enter the Charging state, the “Trigger” flow is activated and the hold releases the message, allowing me to set the room state to “Off” when the vacuum is done. Again, might not be the best way to do it, but it seems to work !

Next step
Next step is the UI. I have some help on that side (lucky me), so what I plan to do is create a sensor for each input_select, and use a picture card on lovelace to display animated svg icons depending on the vaccum state in the room. I do this for my lamps, it’s quite fun:
Icons
Only the sleeping animation is done. I must make the other ones less subtle ! (note: I most probably stole the idea from dribbble, but I can’t remember where :confused:).

After that, I’d like the user to be able to cancel a scheduled clean up. Right now I can reset the queue, but I must find a way to delete a specific item in it … that sounds complicated !

Wrapping up
I hope you guys enjoyed the reading, I’m certainly not an expert so don’t take anything that I say too seriously. If you have questions or remarks, I’ll be more than happy to answer !

Also, if you see any solution to some of the problems I’m facing, or better ways to implement what I want to do, feel free to tell me :slight_smile: !

Cheers

6 Likes

Thanks a lot for this post ! it looks very cool !
Is it possible for you to share your node red script ? I will test your code and tell you if i saw how to improve it ! Thanks !

Thanks for your message ! It’s been a long time since I posted, and I’ve improved the script during the last 2 years … current version looks nothing like the initial one I posted ^^.

I’m now using a state machine for each room, with a designated sensor that tracks the room status. Users can schedule/launch/cancel vacuum by pressing a button in the UI, it works quite well for us.

With my newborn daughter I don’t have much time to get into details, but here’s the exported nodered flow (sidenote: I use Valetudo as a way to control my vac, you’ll need to adapt the script if you’re not using this) :

[{"id":"1087ef6c.254cb1","type":"tab","label":"Cameras","disabled":false,"info":""},{"id":"46d0996b.fc20f8","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum launch request","links":["c4bb47c8.065428","4c44dc98.818784","750b461e.f155c8","4ab5d477.98622c","38970b2e.7513e4","f1f0b23.0200d5","b3b4ff4.f03f"],"x":1235,"y":160,"wires":[]},{"id":"c4bb47c8.065428","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":1000,"wires":[["69aaeced.c71904"]]},{"id":"34b8e503.89212a","type":"comment","z":"1087ef6c.254cb1","name":"Room status ____________________________________________________________","info":"## iddle\nRoom is ready to be cleaned\n\n## scheduled\nRoom has been added to the cleaning schedule\n\n## busy\nRoom is being cleaned\n\n---\n\n# Transitions\nFor message received with a topic *clean_room* triggers a transition.\n - iddle -> scheduled\n - scheduled -> iddle\n - busy -> busy\n","x":320,"y":320,"wires":[]},{"id":"24ef5fc6.bfa51","type":"state-machine","z":"1087ef6c.254cb1","name":"vacuum state","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":false,"throwException":false,"states":["vacuum_iddle","vacuum_busy"],"transitions":[{"name":"vacuum_iddle","from":"vacuum_busy","to":"vacuum_iddle"},{"name":"vacuum_busy","from":"vacuum_iddle","to":"vacuum_busy"}],"x":530,"y":120,"wires":[["4e4f90ac.5376d"]]},{"id":"7bb57aef.e2a764","type":"switch","z":"1087ef6c.254cb1","name":"room status","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"room_requested","vt":"str"},{"t":"eq","v":"room_busy","vt":"str"},{"t":"eq","v":"room_skip","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":330,"y":180,"wires":[["24ef5fc6.bfa51"],["571998d8.a32bc8"],["1ecbf1b.857530e"]]},{"id":"d2f4e8d0.f1fa18","type":"switch","z":"1087ef6c.254cb1","name":"vacuum status","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"vacuum_busy","vt":"str"},{"t":"eq","v":"vacuum_iddle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":120,"wires":[["6385f5ca.6e515c"],["d83bbcae.4aaba"]]},{"id":"6385f5ca.6e515c","type":"simple-queue","z":"1087ef6c.254cb1","name":"Room queue","firstMessageBypass":false,"bypassInterval":"0","x":1090,"y":80,"wires":[["d83bbcae.4aaba"]]},{"id":"69aaeced.c71904","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"livingroom","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":1000,"wires":[["f5aa936e.c6a83"]]},{"id":"d83bbcae.4aaba","type":"change","z":"1087ef6c.254cb1","name":"launch request","rules":[{"t":"set","p":"topic","pt":"msg","to":"vaccuum_launch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":160,"wires":[["46d0996b.fc20f8"]]},{"id":"571998d8.a32bc8","type":"change","z":"1087ef6c.254cb1","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"data\": \t { \t \"entity_id\": \"vacuum.rockrobo\", \t \"command\": \"zoned_cleanup\", \t \"params\": \t { \t \"zone_ids\": [msg.payload] \t } \t }\t}","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"vacuum_busy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":180,"wires":[["e8125abd.8d6758","52d0dc8.dfe6a24"]]},{"id":"4e4f90ac.5376d","type":"switch","z":"1087ef6c.254cb1","name":"! discarded","property":"discard","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":120,"wires":[["d2f4e8d0.f1fa18"]]},{"id":"b22f3aaf.747e48","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum status","links":["cae88e5f.68b1e","e50dde73.d6a8b","4f700cba.015b74","3252b41a.ff8e0c","f6de9b0.69f0368","a9a4093e.8bca98","fdaf7a5d.9f5408","97beba68.3ebec8"],"x":1635,"y":340,"wires":[]},{"id":"cae88e5f.68b1e","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":235,"y":120,"wires":[["67618139.2d6a8"]]},{"id":"ffc94ef7.6ca94","type":"change","z":"1087ef6c.254cb1","name":":vacuum_busy","rules":[{"t":"set","p":"topic","pt":"msg","to":"vacuum_busy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":340,"wires":[["b22f3aaf.747e48"]]},{"id":"37cb80a9.7caad","type":"change","z":"1087ef6c.254cb1","name":":vacuum_iddle","rules":[{"t":"set","p":"topic","pt":"msg","to":"vacuum_iddle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":380,"wires":[["b22f3aaf.747e48","a179e7.10050618"]]},{"id":"63a3d584.6654cc","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum set status","links":["e8125abd.8d6758"],"x":995,"y":380,"wires":[[]]},{"id":"e8125abd.8d6758","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum set status","links":["63a3d584.6654cc"],"x":675,"y":180,"wires":[]},{"id":"e50dde73.d6a8b","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":920,"wires":[["fdbaa74e.671e28"]]},{"id":"acd4e8e1.d681d8","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"bedroom","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":580,"wires":[["90b0424e.acd19"]]},{"id":"4c44dc98.818784","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":580,"wires":[["acd4e8e1.d681d8"]]},{"id":"4f700cba.015b74","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":500,"wires":[["4dd4ef79.937cf"]]},{"id":"63aaca8.2c8b734","type":"change","z":"1087ef6c.254cb1","name":"trigger item","rules":[{"t":"set","p":"trigger","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":80,"wires":[["6385f5ca.6e515c"]]},{"id":"7a0b0e6d.35443","type":"switch","z":"1087ef6c.254cb1","name":"! discarded","property":"discard","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":180,"wires":[["7bb57aef.e2a764"]]},{"id":"e65831be.2d32","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum command","links":["466189c9.a23708","9084e62f.56ab18","24dea9c1.47c876","73fcc86.c867938","4cc101bc.97d53","98624c2d.65a53","163d6941.928197"],"x":35,"y":180,"wires":[["7a0b0e6d.35443"]]},{"id":"466189c9.a23708","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":960,"wires":[]},{"id":"9084e62f.56ab18","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":540,"wires":[]},{"id":"f5aa936e.c6a83","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":960,"wires":[["466189c9.a23708","1a3ef6e5.46f8e9"]]},{"id":"90b0424e.acd19","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":540,"wires":[["9084e62f.56ab18","18c63932.c24e77"]]},{"id":"52d0dc8.dfe6a24","type":"api-call-service","z":"1087ef6c.254cb1","name":"launch vacuum","server":"d43fd5d8.55f3b8","version":1,"debugenabled":false,"service_domain":"vacuum","service":"send_command","entityId":"vacuum.rockrobo","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":220,"wires":[[]]},{"id":"ef0e07d6.319ea8","type":"trigger-state","z":"1087ef6c.254cb1","name":"Vaccuum status","server":"d43fd5d8.55f3b8","entityid":"vacuum.rockrobo","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":960,"y":340,"wires":[["c4d023c0.db0ee"],[]]},{"id":"bbb78db.5bae57","type":"mqtt out","z":"1087ef6c.254cb1","name":"","topic":"","qos":"","retain":"","broker":"97a9fda1.0cc2f","x":610,"y":1240,"wires":[]},{"id":"d4af4ab3.981f68","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":1000,"wires":[]},{"id":"22bd5ceb.f4eee4","type":"link in","z":"1087ef6c.254cb1","name":"[From] MQTT","links":["d4af4ab3.981f68","a77a878.5c3ac78","d10b7d13.9942f","7ff50e4c.14a1c","d0e89db8.6f01a","3d50929b.d43b1e","6cee879e.ce5228"],"x":35,"y":1240,"wires":[["3ebb3f9.5cf3fc"]]},{"id":"260efe4f.6c4bc2","type":"change","z":"1087ef6c.254cb1","name":"","rules":[{"t":"set","p":"newpayload","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"\"vacuum/roomstatus/\" & $.payload","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"newpayload","tot":"msg"},{"t":"set","p":"retain","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1240,"wires":[["bbb78db.5bae57","3ebbfd14.d57802"]]},{"id":"3ebbfd14.d57802","type":"debug","z":"1087ef6c.254cb1","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":1280,"wires":[]},{"id":"a77a878.5c3ac78","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":580,"wires":[]},{"id":"870ab10f.71082","type":"comment","z":"1087ef6c.254cb1","name":"MQTT _________________________________________________________________","info":"","x":320,"y":1200,"wires":[]},{"id":"d90c6960.c6b9c8","type":"switch","z":"1087ef6c.254cb1","name":"","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"room_skip","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":1240,"wires":[["260efe4f.6c4bc2"]]},{"id":"3ebb3f9.5cf3fc","type":"switch","z":"1087ef6c.254cb1","name":"","property":"discard","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":130,"y":1240,"wires":[["d90c6960.c6b9c8"]]},{"id":"67618139.2d6a8","type":"change","z":"1087ef6c.254cb1","name":"discard","rules":[{"t":"set","p":"discard","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":120,"wires":[["24ef5fc6.bfa51"]]},{"id":"18c63932.c24e77","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":580,"wires":[["a77a878.5c3ac78"]]},{"id":"1a3ef6e5.46f8e9","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":1000,"wires":[["d4af4ab3.981f68"]]},{"id":"a179e7.10050618","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum queue","links":["38d630f6.842a7"],"x":1635,"y":380,"wires":[]},{"id":"38d630f6.842a7","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum queue","links":["a179e7.10050618"],"x":795,"y":80,"wires":[["63aaca8.2c8b734"]]},{"id":"22a489e0.523106","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum iddle","links":["1ecbf1b.857530e"],"x":1115,"y":480,"wires":[["53e92ec8.f06ca"]]},{"id":"1ecbf1b.857530e","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum iddle","links":["22a489e0.523106"],"x":475,"y":240,"wires":[]},{"id":"12908ccd.622af3","type":"comment","z":"1087ef6c.254cb1","name":"Vacuum status ___________________________________________________________","info":"","x":1190,"y":280,"wires":[]},{"id":"280f66d0.cdbcfa","type":"comment","z":"1087ef6c.254cb1","name":"Vacuum control flow _________________________________________________________________________________________________________","info":"","x":520,"y":40,"wires":[]},{"id":"4dd4ef79.937cf","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"bedroom","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":540,"wires":[["90b0424e.acd19"]]},{"id":"fdbaa74e.671e28","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"livingroom","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":960,"wires":[["f5aa936e.c6a83"]]},{"id":"418748fc.ef4448","type":"trigger-state","z":"1087ef6c.254cb1","name":"bedroom","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_bedroom","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":80,"y":540,"wires":[["606cb8c5.c644e8"],[]]},{"id":"606cb8c5.c644e8","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":540,"wires":[["4dd4ef79.937cf"]]},{"id":"3c455835.5e1c68","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":960,"wires":[["fdbaa74e.671e28"]]},{"id":"74f42382.601a7c","type":"trigger-state","z":"1087ef6c.254cb1","name":"livingroom","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_livingroom","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":90,"y":960,"wires":[["3c455835.5e1c68"],[]]},{"id":"9264feb2.70874","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"corridor","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":720,"wires":[["5d00a4ab.480aac"]]},{"id":"4ab5d477.98622c","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":720,"wires":[["9264feb2.70874"]]},{"id":"f6de9b0.69f0368","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":640,"wires":[["37dbcd59.0b1ae2"]]},{"id":"73fcc86.c867938","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":680,"wires":[]},{"id":"5d00a4ab.480aac","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":680,"wires":[["73fcc86.c867938","e40ff58e.108c18"]]},{"id":"7ff50e4c.14a1c","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":720,"wires":[]},{"id":"e40ff58e.108c18","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":720,"wires":[["7ff50e4c.14a1c"]]},{"id":"37dbcd59.0b1ae2","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"corridor","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":680,"wires":[["5d00a4ab.480aac"]]},{"id":"7bab9151.83d53","type":"trigger-state","z":"1087ef6c.254cb1","name":"corridor","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_corridor","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":80,"y":680,"wires":[["1f6cb8a7.1a1857"],[]]},{"id":"1f6cb8a7.1a1857","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":680,"wires":[["37dbcd59.0b1ae2"]]},{"id":"e29ae18.f08952","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"study","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":1140,"wires":[["40366f4b.65f46"]]},{"id":"38970b2e.7513e4","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":1140,"wires":[["e29ae18.f08952"]]},{"id":"a9a4093e.8bca98","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":1060,"wires":[["fd72a057.e4f86"]]},{"id":"4cc101bc.97d53","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":1100,"wires":[]},{"id":"40366f4b.65f46","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":1100,"wires":[["4cc101bc.97d53","66b632e.65479cc"]]},{"id":"d0e89db8.6f01a","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":1140,"wires":[]},{"id":"66b632e.65479cc","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":1140,"wires":[["d0e89db8.6f01a"]]},{"id":"fd72a057.e4f86","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"study","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1100,"wires":[["40366f4b.65f46"]]},{"id":"b899b487.477ad8","type":"trigger-state","z":"1087ef6c.254cb1","name":"study","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_study","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":70,"y":1100,"wires":[["85a07d81.10f69"],[]]},{"id":"85a07d81.10f69","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":1100,"wires":[["fd72a057.e4f86"]]},{"id":"eedd5d5d.5c8a9","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"kitchen","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":820,"wires":[["3f271259.6b529e"]]},{"id":"fdaf7a5d.9f5408","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":780,"wires":[["eedd5d5d.5c8a9"]]},{"id":"3f271259.6b529e","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":820,"wires":[["98624c2d.65a53","e1d0afcc.cc8a1"]]},{"id":"11f8c5a7.cfa10a","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":820,"wires":[["eedd5d5d.5c8a9"]]},{"id":"9fe5cd62.d4361","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"kitchen","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":860,"wires":[["3f271259.6b529e"]]},{"id":"98624c2d.65a53","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":820,"wires":[]},{"id":"e1d0afcc.cc8a1","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":860,"wires":[["3d50929b.d43b1e"]]},{"id":"7fc7640d.6baeac","type":"trigger-state","z":"1087ef6c.254cb1","name":"kitchen","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_kitchen","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":80,"y":820,"wires":[["11f8c5a7.cfa10a"],[]]},{"id":"f1f0b23.0200d5","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":860,"wires":[["9fe5cd62.d4361"]]},{"id":"3d50929b.d43b1e","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":860,"wires":[]},{"id":"66d8dcf6.39f8d4","type":"change","z":"1087ef6c.254cb1","name":"payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"bathroom","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":400,"wires":[["cbadde75.cbd3"]]},{"id":"97beba68.3ebec8","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum status","links":["b22f3aaf.747e48"],"x":275,"y":360,"wires":[["66d8dcf6.39f8d4"]]},{"id":"cbadde75.cbd3","type":"state-machine","z":"1087ef6c.254cb1","name":"Room status","triggerProperty":"topic","triggerPropertyType":"msg","stateProperty":"topic","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["room_iddle","room_busy","room_requested","room_skip"],"transitions":[{"name":"clean_room","from":"room_busy","to":"room_skip"},{"name":"clean_room","from":"room_iddle","to":"room_requested"},{"name":"clean_room","from":"room_requested","to":"room_iddle"},{"name":"vaccuum_launch","from":"room_iddle","to":"room_skip"},{"name":"vaccuum_launch","from":"room_requested","to":"room_busy"},{"name":"vacuum_iddle","from":"room_busy","to":"room_iddle"},{"name":"vacuum_iddle","from":"room_skip","to":"room_iddle"}],"x":550,"y":400,"wires":[["163d6941.928197","5a0eb25b.3c01cc"]]},{"id":"d7118516.2e8ce8","type":"change","z":"1087ef6c.254cb1","name":"topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"clean_room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":400,"wires":[["66d8dcf6.39f8d4"]]},{"id":"6178e8fc.2802f8","type":"switch","z":"1087ef6c.254cb1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"bathroom","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":440,"wires":[["cbadde75.cbd3"]]},{"id":"163d6941.928197","type":"link out","z":"1087ef6c.254cb1","name":"[To] Vacuum command","links":["e65831be.2d32"],"x":675,"y":400,"wires":[]},{"id":"5a0eb25b.3c01cc","type":"debounce","z":"1087ef6c.254cb1","time":"500","name":"","x":720,"y":440,"wires":[["6cee879e.ce5228"]]},{"id":"a8c839ca.4ec178","type":"trigger-state","z":"1087ef6c.254cb1","name":"bathroom","server":"d43fd5d8.55f3b8","entityid":"script.vacuum_bathroom","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"tjgehzy2s0r","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":80,"y":400,"wires":[["d7118516.2e8ce8"],[]]},{"id":"b3b4ff4.f03f","type":"link in","z":"1087ef6c.254cb1","name":"[From] Vacuum launch request","links":["46d0996b.fc20f8"],"x":275,"y":440,"wires":[["6178e8fc.2802f8"]]},{"id":"6cee879e.ce5228","type":"link out","z":"1087ef6c.254cb1","name":"[To] MQTT","links":["22bd5ceb.f4eee4"],"x":815,"y":440,"wires":[]},{"id":"6496a615.9f8208","type":"switch","z":"1087ef6c.254cb1","name":"","property":"data.event.new_state.attributes.valetudo_state.id","propertyType":"msg","rules":[{"t":"eq","v":"17","vt":"str"},{"t":"eq","v":"6","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1290,"y":340,"wires":[["ffc94ef7.6ca94"],["37cb80a9.7caad"]]},{"id":"53e92ec8.f06ca","type":"api-call-service","z":"1087ef6c.254cb1","name":"Pause vacuum","server":"d43fd5d8.55f3b8","version":1,"debugenabled":false,"service_domain":"vacuum","service":"pause","entityId":"vacuum.rockrobo","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":440,"wires":[["c3bb40af.c7ffa"]]},{"id":"c3bb40af.c7ffa","type":"api-call-service","z":"1087ef6c.254cb1","name":"send vac home","server":"d43fd5d8.55f3b8","version":1,"debugenabled":false,"service_domain":"vacuum","service":"return_to_base","entityId":"vacuum.rockrobo","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1460,"y":440,"wires":[["9fdf9438.0bc7d8"]]},{"id":"9fdf9438.0bc7d8","type":"ha-wait-until","z":"1087ef6c.254cb1","name":"","server":"d43fd5d8.55f3b8","outputs":1,"entityId":"vacuum.rockrobo","property":"state","comparator":"is","value":"returning","valueType":"str","timeout":0,"timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1640,"y":440,"wires":[[]]},{"id":"aafaed8f.f5707","type":"inject","z":"1087ef6c.254cb1","name":"","topic":"vacuum_iddle","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1030,"y":440,"wires":[["53e92ec8.f06ca"]]},{"id":"c4d023c0.db0ee","type":"delay","z":"1087ef6c.254cb1","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1140,"y":340,"wires":[["6496a615.9f8208"]]},{"id":"d43fd5d8.55f3b8","type":"server","z":"","name":"Home Assistant (docker)","legacy":false,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true},{"id":"97a9fda1.0cc2f","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.133","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]