I am quite new to using home assistant so dont judge me on my bad code! Just wanted to share something I cooked up in 10 mins on my home assistant install
I created a counter helper called counter.Monitor_helper and then wrote the code. I have also adapted this code to work with switching through scenes.
alias: Monitor_Lights
description: ''
trigger:
- platform: device
domain: mqtt
device_id: e97ba687d53960f4cca6762267c66265
type: action
subtype: single
discovery_id: 0x00158d0006726fe9 action_single
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: counter.monitor_helper
above: '6'
below: '20'
sequence:
- service: counter.reset
target:
entity_id: counter.monitor_helper
- service: light.turn_on
data:
rgb_color:
- 255
- 0
- 0
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '6'
sequence:
- service: light.turn_on
data:
rgb_color:
- 255
- 200
- 50
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '5'
sequence:
- service: light.turn_on
data:
rgb_color:
- 255
- 255
- 0
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '4'
sequence:
- service: light.turn_on
data:
rgb_color:
- 0
- 255
- 0
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '3'
sequence:
- service: light.turn_on
data:
rgb_color:
- 0
- 255
- 255
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '2'
sequence:
- service: light.turn_on
data:
rgb_color:
- 0
- 0
- 255
target:
entity_id: light.monitor_lights
- conditions:
- condition: state
entity_id: counter.monitor_helper
state: '1'
sequence:
- service: light.turn_on
data:
rgb_color:
- 255
- 0
- 255
target:
entity_id: light.monitor_lights
default: []
- service: counter.increment
target:
entity_id: counter.monitor_helper
mode: queued
max: 10
I know it may be messy and a lot of repeating code, but it works and is quite quick to run on a raspberry pi 4 4GB. Let me know what you think of my code and if you have any ways of improving it