Hi all,
First up, I have had home assistant for years but have only just started diving into anything beyond some buttons for irrigation solenoids, my knowledge is limited but growing fast.
I have a roborock vacuum which can take multiple room segment id’s in the form of {x,xx,xxx].
In order to dynamically clean multple rooms I have several input_booleans for rooms to select and I have arduously put together a template sensor as follows:
- platform: template
sensors:
rooms_to_clean:
friendly_name: "Rooms to Clean"
value_template: >
{% set rooms = [
{'name': 'input_boolean.clean_entrance', 'number': 19},
{'name': 'input_boolean.clean_kitchen', 'number': 24},
] %}
{% set cleaned = rooms | selectattr('name', 'in', states.input_boolean | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list) | map(attribute='number') | list %}
{% if cleaned | length > 0 %}
[{{ cleaned | join(',') }}]
{% else %}
"None"
{% endif %}
This displays correctly as [19,24] when I show the values in dev tools or on the dashboard. My issues arise when I try and use this in the segments specification for the button to start vacuuming. See first a working dashboard button that cleans both rooms:
- show_name: true
show_icon: true
type: button
entity: vacuum.q7_max
name: Testing (Entry, Kitchen)
icon: mdi:alert
tap_action:
action: perform-action
perform_action: vacuum.send_command
data:
command: app_segment_clean
params:
- segments: [19,24]
repeat: 1
target:
entity_id: vacuum.q7_max
icon_height: 30px
And now this, which calls the sensor, but does not work:
- show_name: true
show_icon: true
type: button
entity: vacuum.q7_max
name: Testing (Entry, Kitchen)
icon: mdi:alert
tap_action:
action: perform-action
perform_action: vacuum.send_command
data:
command: app_segment_clean
params:
- segments: {{states(sensor.cleaned_rooms)}}
repeat: 1
target:
entity_id: vacuum.q7_max
icon_height: 30px
I have tried several variations of calling the sensor values. I assume, but cannot find, information to support the idea that integrations may either not accept template values, or perhaps the string is not accepted?
If anyone is able to enlighten me on where I am going wrong it would be a great learning opportunity appreciated, cheers.