so the idea for the script of selected rooms was to built a string of the selected segments and parse it to the action call. Here is my current script (I omitted all rooms except of 20/22 to make it shorter for this post):
It generates the right string (based on selection of rooms, and runs without errors, but does not start the cleaning. When looking in the traces of the script, I see that there is an additionally “|-” added after the “params:”
and I guess this is the culprit causing that the command is not understood by the roborock. I tried different formatting of the template in the script, but do not get rid of the “|-”. Does anyone encounterd the same or has any suggestions for me?
Those hyphens in the segments section are not part of the value, they are YAML list item separators. You need to provide an actual list, not just a list-shaped string.
I would probably approach it a different way. Instead of stacking If’s and running them through an input, process the booleans and build your list of segments in variables:
Please double check the correlations between segment ID numbers and input boolean entity IDs. I couldn’t tell if there was a typo in the original post or if I just didn’t understand exactly what you were going for…
This is of course much more tidy solution! I think in general I can undestand what you are doing there (only starting with templating / more complex scripts), so you define first boolean variables for each room helper entitiy, then select only the ones in on state to the segs list, and only the onces in the seg list for the ents list (to turn them off at the end).
However, when I try to run the script, I get a error message:
UndefinedError: str object has no element 1
which seems to be caused by the “selectattr(1, …)” for the segs variable. Unfortunately don’t know how to fix/approach this (as said only starting with the templating ).
I extended the code to contain all rooms (as in your version it’s short enough to include everything), but the error is already occuring even in the total unaltered version:
Strangely, the robot is still not starting (though it’s now exactly same format as what is behind the working buttons) - but I guess this is now not a script problem anymore!
Anyway, will then go on to figure that out. Thanks a lot again for the rapid answers and for letting me learn new things about templates and variables in scripts!!
For completeness: Now everything works - I still needed one change in the script to convince the roborock to start: The service is expecting the additional “-” before “segments” in the params. I missed this when initially evaluating the script trace. So after adding a “-” before the params template now the roborock gets it and starts cleaning of the selected rooms. Here the final script, and thanks once more to Didgeridrew!!