Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96018

Script service data_template array based on input_boolean

$
0
0

@Seweryn_Zeman wrote:

I’m trying to create an array of elements to be set by input_boolean and used in script service call.

vacuum_zones:
  alias: 'Vacuum zones'
  sequence:
    - service: vacuum.send_command
      data_template:
        entity_id: vacuum.vacuum
        command: zoned_cleanup
        params:
          zone_ids: >-
            {% if is_state('input_boolean.vacuum_zone_corridor', 'on') %}'Corridor'{% endif %}
            {% if is_state('input_boolean.vacuum_zone_kitchen', 'on') %}'Kitchen'{% endif %}
            {% if is_state('input_boolean.vacuum_zone_saloon', 'on') %}'Saloon'{% endif %}
            {% if is_state('input_boolean.vacuum_zone_bathroom', 'on') %}'Bathroom'{% endif %}
            {% if is_state('input_boolean.vacuum_zone_office', 'on') %}'Office'{% endif %}
            {% if is_state('input_boolean.vacuum_zone_bedroom', 'on') %}'Bedroom'{% endif %}

I hope example above is self-explanatory. I’ve found similar data_template and tried to adjust it, but it gives no error in logs and also doesn’t start zoned cleanup.

When i.e. input_boolean.vacuum_zone_kitchen and input_boolean.vacuum_zone_bathroom are on I’d like to send such a service call:

    - service: vacuum.send_command
      data:
        entity_id: vacuum.vacuum
        command: zoned_cleanup
        params:
          zone_ids: ['Kitchen', 'Bathroom']

I believe YAML’s - element work same as [], because I tested example via Dev tools in UI.

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 96018

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>