Skip to content

Actions | Various Service Templates

xbmcnut edited this page Nov 4, 2020 · 1 revision

When used directly in an Action sequence:

- service_template: "{% if is_state('media_player.sony_bravia_tv' , 'on')
         %} rest_command.androidtv_doorbell
         {% endif %}"

Used in a script:

script:
  toggle_lock:
    alias: 'Toggle Front Door Deadbolt'
    sequence:
      - service_template: >
          {% if is_state('lock.frontdoor_deadbolt', 'unlocked') %}
            lock.lock
          {% else %}
            lock.unlock
          {% endif %}
        entity_id: lock.frontdoor_deadbolt

Another example:

action:
     - service_template: "{% if is_state('sensor.pir_motion_sensor_status' , '1')
        %} light.turn_on {% else %}
        light.turn_off {% endif %}"
       entity_id: light.pir_motion_sensor