Hate to bring this up again, but is it a switch or a light? I am trying this but am getting errors.
ID 'blue_led' of type esp8266_pwm::ESP8266PWM doesn't inherit from switch_::Switch.
Please double check your ID is pointing to the correct value.
id: blue_led [source /config/esphome/switch_back_4ch.yaml:95]`
This is what I have in the yaml…
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff 4CH Blue LED"
output: blue_led
interval:
- interval: 1s
then:
if:
condition:
wifi.connected:
then:
- switch.turn_on: blue_led
else:
- switch.turn_on: blue_led
I am also getting errors with light.turn_on as well. What should I be using? Thanks in advance.
Tom, thanks for this! I “took the liberty” to use your solution in my setup, too. However, i modified it a bit, so i get a blinking led. I guess that as a side effect i’ll get a visual indication if by any chance module freezes (led will stop blinking).
I went a bit further: i programmed my LED so that i know if it’s only connected to wifi or if it’s also connected to HA. “Wifi only” shows by steady 0,5s flashing, while api connected i get pulsed flashing. Ok, i admit, usability is questionable at this point… maybe it will prove usefull.
True, but in this case you don’t know if esp module by any chance locks up, or in any way “go south”. Although rare, it may happen, so it’s better to make led flash in regular intervals.
I think this solution is better because when I was using the condition api.connected, it was triggering also if any other api connected, not just home assistant.
Only downside I have encountered with this new approach is that sometimes it takes about 1-2min till the esp realizes that it connected/disconnected to home assistant.
Hm…
first “error” i see in your version is this situation:
wifi connects → blink slow = ok
api connects → blink fast = ok
(later) if api disconnects → led off = NOT ok → you can’t tell if esp is still connected to wifi or not, since this command turns off led, while wifi component doesnt turn on slow blink again. So, here more sophisticated “if” would be required, like if wifi is connected → slow blink, otherwise → led off.
However, i can’t really see why there would be 1-2 minutes delay here…?
My version with interval is now a bit different - it uses flash lentgh:
(substitution “connected_pin” must be defined)
But, i think that even in my config there is an option to include “client_info” or “client_ip” into condition. It’s just a matter of knowledge (or trial/error)