I have been using this example code from @frenck
The code works perfect, but i would like that the sonoff showed up in HA as a light, not switch (better for google assistant)
I still want all the “bells and whistles” (led status that is correct, the use of the physical button on the sonoff should work as in this example)
I know i can transform the switch in homassistant to a light, but i was thinking that this must be possible in the ESPHome yaml code itself.
I can figure out how to have the sonoff show up as a light, but then i can’t implement the “bells and whistles”
esphome:
name: mcsonoff03
platform: ESP8266
board: esp01_1m
wifi:
ssid: 'XXXXXXX'
password: 'XXXXXXXX'
fast_connect: true
manual_ip:
static_ip: 192.168.111.32
gateway: 192.168.111.1
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "McSonoff03 Button"
on_press:
- switch.toggle: fakebutton
switch:
- platform: template
name: "McSonoff03 Relay"
optimistic: true
id: fakebutton
turn_on_action:
- switch.turn_on: relay
- light.turn_on: led
turn_off_action:
- switch.turn_off: relay
- light.turn_off: led
- platform: gpio
id: relay
pin: GPIO12
output:
- platform: esp8266_pwm
id: basic_green_led
pin:
number: GPIO13
inverted: True
light:
- platform: monochromatic
name: "McSonoff03 Green LED"
output: basic_green_led
id: led
sensor:
- platform: wifi_signal
name: "McSonoff03 WiFi Signal"
update_interval: 30s
- platform: uptime
name: "McSonoff03 Uptime"
text_sensor:
- platform: version
name: "McSonoff03 ESPHome Version"