Hi, I’m new to Hass, ESPHome and YAML and need some help to start.
I have a MagicHome UFO RGBW controller, which works fine with the latest tasmota firmware. But now I want to migrate to ESPHome.
Previously I used the tasmota template from Magic UFO RGBW LED Controller (26-011-945) Configuration for Tasmota
How do I “translate” this config to an esphome <device>.yaml?
My current configuration to create the *.bin file is the following:
esphome:
name: led-controller-ufo-9f7c14
platform: ESP8266
board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "MagicUfo-9F7C14-Fallback"
password: "espfallback"
captive_portal:
web_server:
port: 80
# MagicHome UFO RGBW LED controller
light:
- platform: rgbw
name: "MagicHome 9F7C14"
red: pwm_r
green: pwm_g
blue: pwm_b
white: pwm_w
# general information
sensor:
- platform: wifi_signal
name: "WiFi Signal (RSSI)"
- platform: uptime
name: "Uptime"
# color output
output:
# Red
- platform: esp8266_pwm
id: pwm_r
pin: GPIO14
frequency: 1000 Hz
# Green
- platform: esp8266_pwm
id: pwm_g
pin: GPIO5
frequency: 1000 Hz
# Blue
- platform: esp8266_pwm
id: pwm_b
pin: GPIO12
frequency: 1000 Hz
# White
- platform: esp8266_pwm
id: pwm_w
pin: GPIO13
frequency: 1000 Hz
# TODO reset button: restart esp device or wifi
# binary_sensor:
# - platform: gpio
# pin: GPIO0
# name: "Reset"
# LED: power - always on, no gpio (820R to 3V3)
# TODO LED: info
# status_led:
# pin: GPIO15
# id: state_info
# TODO LED: network
# status_led:
# pin: GPIO2
# id: state_link
I copied most of the code from the other MagicHome rgb controller and changed the pins. Is this correct?
How do I get the button and status leds to work?
The button shall reset the device or the wifi connection → doesn’t matter
network/link led shall be on, if connection ist established (bonus: flash while connecting)
info led shall be on, if … (configurable? e.g. mqtt connection or something)
Looks good to me. About the button - you can use the restart switch functionality and use the on_press method for the physical button to call it. Look here and here for inspiration.
For the status LED, I don’t think you can link it to network activity. It has a predefined function defined here and you cannot change that.
Thanks for your reply.
I added fast_connect: true to my config, because the wifi is hidden and removed the web_server section.
Then I tried flashing the binary file via esphomeflasher, but after restart the device does not connect to my network. I saw that esphomeflasher sets the clock to 40 MHz, but the board seems to operate at 26 MHz?
Serial port /dev/ttyUSB0
Connecting........___
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
Crystal is 26MHz
[..]
So I flashed this binary again with esptool: esptool.py -b 460800 write_flash -e -ff 26m -fm dout -fs 1MB 0x00048000 magichome_ufo.bin But even with that I had no success. The blue and red (GPIO2) LED are permanently on and no connection is established. The fallback WiFi is also not visible.
Sadly, the device is still not running correctly at all:
The status_led flashes slowly (one time per second), but wifi signal is strong enough and it’s still connected.
The device is auto-discovered in hass, but if i try to connect to, it tells me, that my config shall include an api: line, but it does.
After 15 minutes the device automatically reboots due to a missing api connection:
[18:25:56][D][sensor:125]: 'Uptime': Sending state 876.98297 s with 0 decimals of accuracy
[18:26:17][D][sensor:125]: 'WiFi Signal (RSSI)': Sending state -51.00000 dBm with 0 decimals of accuracy
[18:26:24][E][api:123]: No client connected to API. Rebooting...
[18:26:24][I][app:127]: Forcing a reboot...
[18:26:24][W][wifi_esp8266:483]: Event: Disconnected ssid='removed' bssid=removed reason='Association Leave'
[18:26:24]
[18:26:24] ets Jan 8 2013,rst cause:1, boot mode:(3,0)
[..]
My configuration:
esphome:
name: led-controller-ufo-9f7c14
platform: ESP8266
board: esp8285
platformio_options:
board_build.f_flash: 26000000L
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "MagicUfo-9F7C14-Fallback"
password: "espfallback"
captive_portal:
# ESP configuration:
# RGBW platform for MagicHome UFO LED controller
light:
- platform: rgbw
name: "MagicHome 9F7C14"
red: pwm_r
green: pwm_g
blue: pwm_b
white: pwm_w
# General information
sensor:
- platform: wifi_signal
name: "WiFi Signal (RSSI)"
- platform: uptime
name: "Uptime"
# Color output
output:
# Red
- platform: esp8266_pwm
id: pwm_r
pin: GPIO14
frequency: 1000 Hz
# Green
- platform: esp8266_pwm
id: pwm_g
pin: GPIO5
frequency: 1000 Hz
# Blue
- platform: esp8266_pwm
id: pwm_b
pin: GPIO12
frequency: 1000 Hz
# White
- platform: esp8266_pwm
id: pwm_w
pin: GPIO13
frequency: 1000 Hz
# TODO reset button: restart esp device or wifi
#binary_sensor:
# - platform: gpio
# pin: GPIO0
# name: "Reset Button"
# LED: power - always on, no gpio (820R to 3V3)
# LED: info
status_led:
pin:
number: GPIO15
inverted: yes
id: state_info
# TODO LED: network (maybe from rssi value?)
#status_led:
# pin:
# number: GPIO2
# inverted: yes
# id: state_link
I already updated ESPHome, the binary, HassOS and restarted everything, but cannot connect anyway.
I saw the other thread about the same issue. I added a password to the api: section and now, hass can connect to the device without a problem. Maybe it’s a bug? The status_led is also not flashing anymore.
Only thing I have to correct is that green and red channel are interchanged (it’s a problem of wrong led stripe markings).
Does anybody know, how to use the binary_sensor as gpio output? All examples I found, only show the use as input. But how do i set a gpio pin to low or high?