Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Next Scene in Area
- sequence:
- - variables:
- next_scene: |
- {% set current_scene = states(current_scene_entity) %}
- {% set scenes = expand(area_entities(scene_area))
- | selectattr('domain', 'eq', 'scene')
- | map(attribute='entity_id')
- | list | sort %}
- {% set current_index = scenes.index(current_scene)
- if current_scene in scenes
- else -1 %}
- {% set next_index = (current_index + 1) % scenes | length %}
- {{ scenes[next_index] }}
- - action: scene.turn_on
- metadata: {}
- data:
- entity_id: "{{ next_scene }}"
- - action: input_text.set_value
- metadata: {}
- target:
- entity_id: "{{ current_scene_entity }}"
- data:
- value: "{{ next_scene }}"
- fields:
- current_scene_entity:
- selector:
- entity:
- filter:
- domain: input_text
- name: Current Scene Entity
- required: true
- description: Text entity to store the active scene.
- scene_area:
- selector:
- area: {}
- name: Scene Area
- description: >-
- Scenes must be attached to the selected area to be recognised by this
- script.
- required: true
- description: Go to the next scene (a-z) in the specified area.
- icon: mdi:lightbulb-multiple-outline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement