Howto: Xiaomi/Roborock Room Cleaning By Buttons with Queuing

Hey @neil_pdj,

well, the robot will switch the maps and the second floor should start with ID 15 as well.

I indeed have “hardwired” one-room name per button. The secondary toggle switch is for an automation which keeps track of the motion sensor/exhaust-hood usage etc. and if there are more than 15 minutes of continuous activity in the kitchen, it will set the “kitchen_needs_cleaning” boolean.

If the kitchen has half an hour no motion detection, my vacuum will do a swipe through the kitchen.

Similarly, I use the front door sensor and count the usages, if it’s been used 10 times the vacuum gets started for the hallway after a while.

So the whole idea behind my script is, to automate the cleaning of individual rooms and make sure that the automation is just “stacking” the jobs instead of canceling each other.

Btw the “Return to Dock Automation” seems to have issues. Turning the script off and on again makes the script unusable until I reload the scripts. I removed the turn off/on stuff in my automation and just send it back for the current job.

@RubenKelevra - ahh, that makes sense. I’ll give that a go tomorrow when the kids are awake! Thanks so much. I also love your ideas for automatically tracking when rooms may need cleaning - another excuse to buy some more sensors :grinning:
Thanks for the heads-up on the automation too. I know it’s working for me as the wife just paused the vac from coming to the kitchen as we’re sitting here now and 5 mins later it took itself home again. Motion sensor for kitchen on order!
Appreciate your time. :+1:

This might be a little off topic. But have anyone having issue with all of hassio roborock command? Every since HA core 8.0 updated none of the vacuum core command work. I.e vacuum.locate, vacuum.start, etc… I’m still able to read all my roborocks stats but that it.

Yeah returning works fine. But the robot will refuse to do anything afterwards, as the script will get “stuck” in HA itself.

Not sure if that’s an issue with my script or HA itself.

So better just end the current job and maybe just run it to the next room.

Hey @jztan79,

not sure what you mean - updating the core shouldn’t have any influence on the component. :thinking:

I always update as soon as any update is available and didn’t noticed any issues.

Thanks @RubenKelevra for this great script. It is all working as expected with my S5 including queuing, except for one thing: When I click a button to start room cleaning, ALL the buttons light up. I can click others and those rooms will be added to the queue but all buttons stay lit. They all go off when the vacuum is returning to the dock to charge at the end of the job.

What could I have done wrong to cause this deviation from your described behavior?

The only part of your description that was not clear was the definition of room numbers to rooms. For N rooms, I have ended up with N separate Helpers which seemed a bit clumsy. I suppose I was expecting some single (to speak Fortran) declaration statement table that listed room names and the corresponding room number.

Anyway, I’m much enjoying using your script and am so grateful that you shared it

1 Like

That’s the expected behavior since the buttons won’t “know” with which parameter the script has been started. So they just show that the script / robot is running. I think you can select a static icon, so you won’t have any feedback on them.

But I don’t know how to easily set them lit for each room individually without a proxy script for each room - which defeat the purpose a bit.

Yeah, if you see a way to avoid this, that would be great :slight_smile:

Hey @da3mon,

sorry for not getting back to you sooner… looks like you found and fixed your issue? :slight_smile:

Hahaha sorry, I already saw my problem answered above.
Thank you again.

How are you? I’m going to leave this question, except that when I finish writing it I see that you have already done it … hahaha I can’t find how to leave the button icons in the off state, I prefer that to all of them turn on. Another thing that would be useful is that when a stop occurs, the entire queue stops. Now what happens is that if I choose 3 environments and press stop (in Xiaomi Home) I must stop 3 times. It’s like every stop stops an environment … can you do that? Thanks. A hug.

Have some problems getting the script to work. How do I find my device_id to replace this line with the correct ID?

device_id: 1234567

Hey @samuel.bagfors,

I don’t know how to find it easier than this (there’s probably a “correct” way):

  • Create a new automation
  • Go to the command section
  • Select the vacuum you want to control
  • Switch to the YAML-view via the dots on the top right corner

And the device number should be displayed there

Hey @da3mon,

You do two service calls, turning the script off and on again. This clears the queue running for the script.

I used this method previously on the “return to home” script, as I don’t want the robot to continue on the next job when it got stopped somewhere.

The issue is, that something in HA seems to break and won’t let you run the script at all when you do this. Reloading the script section of HA seems to work around this issue and let you continue using scripts.

Not sure if that’s an issue with HA or my script.

Can I add how many repetitions the robot should do somewhere in the script? Would be nice to achieve the new “crisscross pattern” with this “blueprint”

1 Like

@johfo

you can use something like this.

  • Create input_number helper in range between 1 - 3. Let’s call it input_number.vacuum_repeat
  • Change {% set room_id = states("input_number.roborock_room_enum_" + room) | int %} {{ room_id }} in main script to something like this
{% set room_id = states("input_number.roborock_room_enum_" + room) | int %}
{% set repeat = states("input_number.vacuum_repeat") | int %}
[{"segments":[{{ room_id  }}],"repeat":{{ repeat }}}]
  • Add input_number.vacuum_repeat at the top or at the bottom of your card… Or wherever you please, and adjust accordingly before pressing the button to start main script.

This works because app_segment_clean can accept either a room number as a parameter, or json string consiting of multiple parameters, in our case specifying segments (rooms) and repeat number.

Thanks for taking time helping out. I have tested the code but it will not repeat 2 or 3 times according to what I enter in my “input_number.vacuum_repeat”, always cleaning once only then going back to dock. Might be something simple like that I have entered the code wrong but it is not complaining about it…any thoughts on what it could be?

Can you share the code you’ve used?
I use a modified version of this… Actually, i use my own python script to do all the logic, but the parameters that are sent to the vacuum using send_command are pretty much the same as the one I’ve previusly sent.

Sure, this is the main script: Roblox - Pastebin.com