@dawsonweb wrote:
Hello. Home Assistant Noob here.
So… after many, many hours, days even, i’ve managed to get my HASS configured with 3 lamps and a Xiaomi button. Using input_select i’ve been able to configure the button so each single press cycles through 4 states:
The lamps are called “Hall”, “Stairs” and “Snooker”
Lamp Hall on
Lamp Hall/Stairs on
Lamp Hall/Stairs/Snooker on
Lamps off
It works like a charm.
I’m hoping someone can give me some advise to reduce this code as I feel it’s inefficient. First here’s the configuration.yamlscene: - name: Hall Light entities: switch.sonoffsocket01: state: 'on' switch.0x000d6ffffe6248f5_switch: state: 'off' switch.sonoffsocket03: state: 'off' - name: Hall Stairs Light entities: switch.sonoffsocket01: state: 'on' switch.0x000d6ffffe6248f5_switch: state: 'on' switch.sonoffsocket03: 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' 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 #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: Hall Light description: '' trigger: - entity_id: input_select.hall_scenes platform: state to: Hall Light condition: [] action: - scene: scene.hall_light - alias: Hall Stairs Light description: '' trigger: - entity_id: input_select.hall_scenes platform: state to: Hall Stairs Light condition: [] action: - scene: scene.hall_stairs_light - alias: Snooker Hall Stairs Light description: '' trigger: - entity_id: input_select.hall_scenes platform: state to: Snooker Hall Stairs Light condition: [] action: - scene: scene.snooker_hall_stairs_light - alias: Hall Off description: '' trigger: - entity_id: input_select.hall_scenes platform: state to: Hall Off condition: [] action: - scene: scene.hall_off
My feeling is that the last 4 events could be combined into one event that passes the scene name as part of the action.
Any ideas?
Thanks in advance.
- Michael D
Posts: 3
Participants: 2