Hello, I need help with one automation.
In Esphome. The LED on the charging module flashes when the battery is being charged.
This signal is connected to GPIO.
In esphome:
- platform: gpio
pin:
number: 23
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Charger"
id: charger
This means that it sends an ON/OFF status change every approx. 0.5 seconds
How do I set the automation so that it sends the “Charging” status to the text sensor in this state?
So far, I managed to create a sensor with the status “on battery” and “Full battery”
YAML:
binary_sensor:
##CHARGER
- platform: gpio
pin:
number: 23
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Charger"
id: charger
- platform: template
name: "Test sensor"
lambda: |-
if (id(charger).state) {
return true;
} else {
return false;
}
filters:
- delayed_on_off: 1s
id: charger_template
on_state:
then:
- if:
condition:
binary_sensor.is_off: charger_template
then:
- text_sensor.template.publish:
id: power_status
state: "On Battery"
else:
- text_sensor.template.publish:
id: power_status
state: "Full Battery"
text_sensor:
##CHARGER TEXT
- platform: template
name: "${friendly_name} Power"
id: power_status
That means I need three states
- on Battery (GPIO off)
- Charger Battery (GPIO on/off 0.5s)
- Full Battery (GPIO on)
Thanks