Hi, i’m not great at yaml but i’ve managed to piece together a lovely little scene rotator driven from a Xiaomi button… it’s just not perfect. It’s designed to rotate through the scenes on single clicks but on a long click it turns everything off. So far so good. Problem is after long click, i want the scene selection to start from the beginning not pickup where it left off.
I hope that makes sense. Code below. Scenes on lines 53-56.
Cycle hall lights is the singe rotate event.
Long press hall off is the one I want to trigger scene “hall off” but also reset the scene rotation back to “hall off” too.
#Scenes
scene:
- name: Hall Light
entities:
switch.sonoffsocket01:
state: 'on'
switch.0x000d6ffffe6248f5_switch:
state: 'off'
switch.sonoffsocket03:
state: 'off'
switch.sonoffsocket06:
state: 'off'
switch.0x14b457fffe4ceb8b_switch:
state: 'off'
- name: Hall Stairs Light
entities:
switch.sonoffsocket01:
state: 'on'
switch.0x000d6ffffe6248f5_switch:
state: 'on'
switch.sonoffsocket03:
state: 'off'
switch.sonoffsocket06:
state: 'off'
switch.0x14b457fffe4ceb8b_switch:
state: 'off'
- name: Snooker Hall Stairs Light
entities:
switch.sonoffsocket01:
state: 'on'
switch.0x000d6ffffe6248f5_switch:
state: 'on'
switch.sonoffsocket03:
state: 'on'
- name: Hall Off
entities:
switch.sonoffsocket01:
state: 'off'
switch.0x000d6ffffe6248f5_switch:
state: 'off'
switch.sonoffsocket03:
state: 'off'
switch.sonoffsocket05:
state: 'off'
input_select:
hall_scenes:
name: Hall Scenes
options:
- Hall Light
- Hall Stairs Light
- Snooker Hall Stairs Light
- Hall Off
initial: Hall Off
icon: mdi:lightbulb-on-outline
study_scenes:
name: Study Scenes
options:
- Study Spots
- Study Off
initial: Study Off
icon: mdi:lightbulb-on-outline
#Cycle Hall Lights
automation:
- alias: Cycle Hall Lights
trigger:
- entity_id: sensor.0x00158d0003614c8f_click
platform: state
to: single
action:
service: input_select.select_next
data:
entity_id: input_select.hall_scenes
- alias: Trigger Scene
description: ''
trigger:
- entity_id: input_select.hall_scenes
platform: state
condition: []
action:
- service: scene.turn_on
data_template:
entity_id: scene.{{ trigger.to_state.state.replace(' ','_').lower() }}
- alias: Cycle Study Lights
trigger:
- entity_id: sensor.0x00158d000407e37f_click
platform: state
to: single
action:
service: input_select.select_next
data:
entity_id: input_select.study_scenes
- alias: Trigger Scene
description: ''
trigger:
- entity_id: input_select.study_scenes
platform: state
condition: []
action:
- service: scene.turn_on
data_template:
entity_id: scene.{{ trigger.to_state.state.replace(' ','_').lower() }}
- alias: Long Press Hall Off
description: ''
trigger:
- entity_id: sensor.0x00158d0003614c8f_click
platform: state
to: long
condition: []
action:
- service: scene.turn_on
data_template:
entity_id: scene.hall_off
1 post - 1 participant