Hi, all! i’m struggling to achieve goal of creating working script for my robot vacuum mijia m40 (xiaomi.vacuum.d110ch) to do room selected cleaning
my script now is looking like this
vacuum_rooms_clean:
alias: "robot-vacuum clean selected rooms2"
description: Start robot-vacuum cleaning task
variables:
# # queue: input_text.deebot_cheryl_queue
vacuum_bot: vacuum.xiaomi_d110ch_95ed_robot_cleaner
mode: single
sequence:
- alias: Get room numbers
variables:
rooms: >-
{% set x = expand('input_boolean.main_bedroom_vacuum', 'input_boolean.small_bedroom_vacuum',
'input_boolean.storeroom_vacuum', 'input_boolean.bathroom_vacuum',
'input_boolean.toilet_vacuum', 'input_boolean.small_hallway_vacuum',
'input_boolean.garderob_vacuum', 'input_boolean.lobby_vacuum', 'input_boolean.boilroom_vacuum',
'input_boolean.big_hallway_vacuum', 'input_boolean.livingroom_vacuum','input_boolean.kitchen_vacuum') | map(attribute='state') | list %}
{% set y = ['10,1,3,2,1', '7,1,3,2,1', '3,1,3,2,1', '12,1,3,2,1', '8,1,3,2,1', '6,1,3,2,1', '4,1,3,2,1', '5,1,3,2,1', '11,1,3,2,1', '2,1,3,2,1', '1,1,3,2,1', '9,1,3,2,1'] %} {% set ns =
namespace (z=[]) %} {% for i in x %}
{% if i == 'on' %}
{% set ns.z = ns.z + [y[loop.index-1]] %}
{% endif %}
{% endfor%} {% set out = ns.z|join('],[') %} {{ out }}
- alias: Send cleaning job to vacuum
action: xiaomi_miot.call_action
data:
entity_id: "{{ vacuum_bot }}"
siid: 4
aiid: 1
params:
- piid: 1
value: 18
- piid: 10
value: >-
{\"selects\":[[{{rooms}}]]}
force_params: true
Rooms id for my robot have to be like [1,1,3,2,1] where first number is room id. So room1 [1,1,3,2,1], room2 [2,1,3,2,1]. room3 [3,1,3,2,1] etc.
This version of script correctly get my rooms id but the second part of script (sending job to robot) is not executing properly and i think it’s bc of double quotes that need to be around of value
So correct command for my robot that do cleaning for only one selected room is looking like this
action: xiaomi_miot.call_action
data:
entity_id: vacuum.xiaomi_d110ch_95ed_robot_cleaner
siid: 4
aiid: 1
params:
- piid: 1
value: 18
- piid: 10
value: "{\"selects\":[[4,1,3,2,1]]}"
force_params: true
if it will have single quotes around value it will not work. It’s only work if it have double quotes
When i try to do debug of my script in HA it shows that script is working, rooms id properly inserted but script add single quotes around of final value and robot not accept it
I understand that problem is bc of escaping special symbols but i’m not good with jinja and googling not helps much
Will be very grateful If someone could give me advise or working solution
Using Xiaomi Miot For HomeAssistant integration to send commands to robot!
p.s. English is not my main language so please take my apologies
p.p.s There is no integration at this moment for showing map and select rooms to clean for this model of robot