I’m hoping someone with a big brain can help me with my script (pasted at the bottom of this post) because I don’t have a good handle on how templates, and what I have doesn’t work. I presume because of restrictions with how data templates work.
I have a card that calls this script. Now within the script I want to be able to check whether input_boolean.deebot_lounge_rug is on. If it is I want the script to output from the tempate
- service: vacuum.send_command
data:
command: spot_area
entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2
params:
map: 200.0,2000.0,1800.0,-1300.0
otherwise I want it to output
- service: vacuum.send_command
data:
command: spot_area
entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2
params:
area: *## and then whatever number is on*
Here’s my script
vacuum_clean_zone:
alias: Cleaning Zone
sequence:
- service: vacuum.send_command
data_template:
command: spot_area
entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2
params: >-
{% if is_state('input_boolean.deebot_lounge_rug', 'on') %}
map: >-
{%- set x = "" %}
{% if is_state('input_boolean.deebot_lounge_rug', 'on') %}
{% set x = x + "200.0,2000.0,1800.0,-1300.0 " %}
{% endif %}
{{x[:-1]}}
{% else %}
area: >-
{%- set x = "" %}
{% if is_state('input_boolean.deebot_kitchen', 'on') %}
{% set x = x + "5," %}
{% endif %}
{% if is_state('input_boolean.deebot_masterwir', 'on') %}
{% set x = x + "2," %}
{% endif %}
{% if is_state('input_boolean.deebot_guest','on') %}
{% set x = x + "4," %}
{% endif %}
{% if is_state('input_boolean.deebot_flynnbed','on') %}
{% set x = x + "7," %}
{% endif %}
{% if is_state('input_boolean.deebot_masterbed', 'on') %}
{% set x = x + "1," %}
{% endif %}
{% if is_state('input_boolean.deebot_mainbath', 'on') %}
{% set x = x + "3," %}
{% endif %}
{% if is_state('input_boolean.deebot_lounge', 'on') %}
{% set x = x + "0," %}
{% endif %}
{{x[:-1]}}
{% endif %}
# cleanings: >-
# {%- if is_state('input_boolean.deebot_times', 'on') -%}2{%- else
# -%}1{%- endif -%}
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_kitchen
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_masterwir
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_guest
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_flynnbed
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_masterbed
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_mainbath
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_lounge
- service: input_boolean.turn_off
data:
entity_id: input_boolean.deebot_lounge_rug
vacuum_script_set_water:
alias: set vacuum water level
sequence:
- service: vacuum.send_command
data:
command: set_water_level
entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2
params:
level: low|medium|high