Hi,
I have two colour led connected to node mcu32 (red and green), in esphome it is defined as follows:
light:
- platform: monochromatic
output: led32
id: red_led
name: Red
effects:
- pulse:
name: "Slow Pulse"
transition_length: 1s
update_interval: 2s
min_brightness: 0%
max_brightness: 35%
- pulse:
name: "Medium Pulse"
transition_length: 1s
update_interval: 1s
min_brightness: 0%
max_brightness: 65%
- pulse:
name: "Fast Pulse"
transition_length: 250ms
update_interval: 400ms
min_brightness: 0%
max_brightness: 100%
- strobe:
name: "Strobe Red"
colors:
- state: false
duration: 1s
- state: true
brightness: 75%
duration: 1s
- platform: monochromatic
output: led33
id: green_led
name: Green
effects:
- pulse:
name: "Slow Pulse"
transition_length: 1s
update_interval: 2s
min_brightness: 0%
max_brightness: 35%
- pulse:
name: "Medium Pulse"
transition_length: 1s
update_interval: 1s
min_brightness: 0%
max_brightness: 65%
- pulse:
name: "Fast Pulse"
transition_length: 250ms
update_interval: 400ms
min_brightness: 0%
max_brightness: 100%
- strobe:
name: "Strobe Green"
colors:
- state: true
brightness: 75%
duration: 1s
- state: false
duration: 1s
I also have a text sensor defined as follows:
text_sensor:
- platform: homeassistant
id: battery_power
entity_id: sensor.battery_power
this returns value of my home battery. When the values are negative i.e. -200 the battery is charging, when 200 the battery is charging
What I now want is to use that two colour led to indicate what is happening with the battery:
- battery discharging > 1700
green led off,
red led flashing (effect Fast Pulse) - battery discharging rate from 1000 to 1700
red led flashing (effect Medium Pulse), green off - battery discharging rate from 1 to 1000
red led flashing (effect Slow Pulse), green off - battery @ 0 (sitting idle) - red and green are flashing (effects strobe red and strobe green)
- battery charging (basically reverse of discharging but the green is doing all the flashing and red is off)
Sounds simple on the paper but I’m not sure how to code it in esphome - I suspect dreadful lambdas will have to be used?
Can any point me in the right direction?
Thanks