Is it possible to set an initial state for an ESPHome light component as shown in HA on HA restart? I may just be missing something with the Sonoff Basic set up with the configuration below…
When I restart HA, light.under_stair_cupboard shows as on, regardless of the actual state of the device. I tried setting the initial state off in customize.yaml, but it did not have any effect.
Thanks.
# Substitutions
substitutions:
devicename: light_under_stair_cupboard
staticip: 192.168.xxx.xxx
mqttclientid: lt_under_stair_cupboard
birthtopic: light_status/under_stair_cupboard/availability
lwttopic: light_status/under_stair_cupboard/availability
lightid: under_stair_light
lightname: "Under Stair Cupboard"
binarysensorid: under_stair_cupboard_light_toggle
esphome:
name: $devicename
platform: ESP8266
board: esp01_1m
# Enable WiFi
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pwd
manual_ip:
static_ip: $staticip
gateway: 192.168.xxx.xxx
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
# MQTT
mqtt:
broker: !secret mqtt_broker
port: !secret mqtt_port
client_id: $mqttclientid
username: !secret mqtt_username
password: !secret mqtt_password
discovery: clean
birth_message:
topic: $birthtopic
payload: 'online'
will_message:
topic: $lwttopic
payload: 'offline'
keepalive: 5s
# Set up output to control relay - Required for light platform to control relay
output:
- platform: gpio
pin: GPIO12
id: relay
# Set up light in light platform for HA
light:
- platform: binary
name: $lightname
output: relay
id: $lightid
# Set up binary sensor tied to Sonoff button and hide it from HA
binary_sensor:
- platform: gpio
pin: GPIO0
on_press:
then:
- light.toggle: $lightid
id: $binarysensorid
internal: true
status_led:
pin:
number: GPIO13
inverted: false