Ok, if you want to feed it multiple rooms like @123 is eluding, you’ll have to make the template differently.
- variables:
div: >
{% set which = divisao if divisao is iterable and divisao is not string else [ divisao ] %}
{% set items = {
"pais": 3,
"sala": 6,
"meninos": 7,
"gonçalo": 8,
"cozinha": 9,
"escritório": 12
} %}
{% set ret = items.items() | list | selectattr('0', 'in', which) | map(attribute='1') | list %}
{% set ret = ret + [1,11] if 'corredor' in divisao else ret %}
{{ ret | sort }}
Then later on in your service call…
- service: xiaomi_miot.call_action
target:
entity_id: vacuum.viomi_v18_e271_robot_cleaner
data:
siid: 4
aiid: 13
params: [0, 1, "{{ div | join(', ') }}" ]
secondly, if you’re using the template editor, you it won’t create the variables for you. You have to create them.
In order to test the the first template…
{% set divisao = 'sala', 'corredor' %}
{% set which = divisao if divisao is iterable and divisao is not string else [ divisao ] %}
{% set items = {
"pais": 3,
"sala": 6,
"meninos": 7,
"gonçalo": 8,
"cozinha": 9,
"escritório": 12
} %}
{% set ret = items.items() | list | selectattr('0', 'in', which) | map(attribute='1') | list %}
{% set ret = ret + [1,11] if 'corredor' in divisao else ret %}
{{ ret | sort }}
in order to test the second template…
{% set divisao = 'sala', 'corredor' %}
{% set which = divisao if divisao is iterable and divisao is not string else [ divisao ] %}
{% set items = {
"pais": 3,
"sala": 6,
"meninos": 7,
"gonçalo": 8,
"cozinha": 9,
"escritório": 12
} %}
{% set ret = items.items() | list | selectattr('0', 'in', which) | map(attribute='1') | list %}
{% set ret = ret + [1,11] if 'corredor' in divisao else ret %}
{% set div = ret | sort %}
params: [0, 1, "{{ div | join(', ') }}" ]