Hello,
i have a list of input_boolean, 1 for each room.
I want to conctened all the room number that as to be cleaned and send it to the vacuum with:
service: vacuum.send_command
data:
command: app_segment_clean
params:
- segments:
i made a template sensor that check the input boolean and concatened the value and then the script send it to the vacuum.
SENSOR:
- platform: template
sensors:
room_to_clean:
friendly_name: pièce a nettoyer
value_template: >
{% set segm = "[" %}
{% if is_state('input_boolean.aspi_cuisine','on') %}
{% set segm = segm ~ 16 %}
{% endif %}
{% if is_state('input_boolean.aspi_salleamanger','on') %}
{% if segm == "[" %}
{% set segm = segm ~ 17 %}
{% else %}
{% set segm = segm ~ "," ~ 17 %}
{% endif %}
{% endif %}
{% if is_state('input_boolean.aspi_salon','on') %}
{% if segm == "[" %}
{% set segm = segm ~ 18 %}
{% else %}
{% set segm = segm ~ "," ~ 18 %}
{% endif %}
{% endif %}
{% if is_state('input_boolean.aspi_couloir','on') %}
{% if segm == "[" %}
{% set segm = segm ~ 19 %}
{% else %}
{% set segm = segm ~ "," ~ 19 %}
{% endif %}
{% endif %}
{% set segm = segm ~ "]" %}
{{ segm }}
SCRIPT:
- service: vacuum.send_command
data:
command: app_segment_clean
params:
- segments: "{{states('sensor.room_to_clean') }}"
repeat: 1
target:
entity_id:
- vacuum.roborock_s7
It work fine but i would like to make the concatened work in a script instead as use a sensor.
I tried with variable but i can’t manage to make the variable concatening.
Can anyone please help me?