I have a sonoff switch running tasmota (5.12.0). I can see all the stats etc in the HASS (0.65.3) front end perfectly fine. What is bothering me is I have powerretain 1 set on the sonoff POW and it does not appear to be working. I can see it ‘on’ in HASS but once I reboot HASS, it goes back to off. I can see in MQTT.fx the retained Power ON state on the MQTT server (mosquitto running in Docker). But HASS seems to ignore it. FWIW: I’m using MQTT discovery to pick up the sonoff in question.
any ideas?
This log from the sonoff is right after I toggled it:
Screenshot from MQTT.fx - shows retained and POWER On
That’s an interesting solution to the problem - I hate band-aiding something like this that ‘should’ be working from what I can tell - but I might run down this path if needed - thanks for the idea!
@VDRainer - thank you for that link - much appreciated. So if I’m using discovery, I guess that’s out the door if I want retained? I tried setting retain: true under MQTT component the other night - and HASS throws an error when it started as a result. So if I can’t use discovery, so be it - but trying confirm that it can or cannot be used if I want retain.
Hey @vexter0944 how did you solve it? I have the same problem when using tasmota with autodiscovery. The PowerRetain flag is set to On, but HA only discovers the device itself, not its power state - although i can confirm that the topic is set, indeed.
I could use @mcfrojd s approach now, but what’s the point of autodiscovery if i still have to add each new device to the config somewhere? For now, i am resigning from autodiscovery and specify each device manually in the MQTT switch config. This requires me to add each device manually as well, but it’s less lines of code than to add a bunch of automations to the config - but no approach feels like a real solution, just like a workaround.
I just ran into the same problem. My solution was to create an automation that is triggered when Home Assistant starts and performs a mqtt.publish to “cmnd/sonoff/POWER2”. This causes tasmota to update the status of “stat/sonoff/POWER2” (assuming your state_topic: stat/sonoff/POWER2)
- id: '1545179894309'
alias: Tasmota Status Update
trigger:
- event: start
platform: homeassistant
condition: []
action:
- delay: '60' #This may not be necessary
- data:
topic: cmnd/sonoff/POWER2
service: mqtt.publish
I only have 1 Tasmota device right now but if I end up with more than a few I’ll probably throw the mqtt.publish into a script and have the automation call it.
I was just tinkering with the auto discovery.
Then I tested the behaviour with “powerretain on” for some sonoff devices and a home assistant restart.
It does not work.
Adding a automation for every device ( like 10) or just configuring them manually seems like almost the same effort.
I think I will switch back and won’t use auto discovery of this is the case.