I am trying to figure out how to display the state of a binary sensor using a LED on an ESP8266 … But nothing really happens…
This is my config:
esphome:
name: doorindicator-1
friendly_name: DoorIndicator-1
esp8266:
board: esp01_1m
# Enable logging
logger:
level: debug
# Enable Home Assistant API
api:
encryption:
key: "xxx"
ota:
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Doorindicator-1 Fallback Hotspot"
password: "xxx"
captive_portal:
# Enable On-Board Status LED.
output:
- platform: gpio
id: status_led
pin: GPIO4
binary_sensor:
- platform: homeassistant
id: bryggers_dorlas_contact
entity_id: binary_sensor.bryggers_dorlas_contact
on_state:
then:
- lambda: |-
ESP_LOGD("bin_Sensor","State changed");
if (id(bryggers_dorlas_contact).state) {
id(status_led).turn_on();
} else {
id(status_led).turn_off();
}
When the state of the sensor changes in HA, nothing happens/is logged on the ESP device…
Also - I am not sure what happens on boot of the device - will it read the state of the HA sensor, or will nothing happen before the state actually changes ?
I would really like it to fetch the state on reboot, so that the LED indication always is right…