Hass "forgets" tasmota devices, though they are configured correctly - have to be manually restored

Hi everybody,

I just recently switched from using my tasmota flashed devices via mqtt to their native Home Assistant protocol.

I did so by typing SetOption19 1 in the terminal; each of those devices is running tasmota v > 7, so this should be fine (I believe the feature was introduced in version 6.3 or similar). All the devices show up in Home Assistant and I can control them (switch on/off) and read their stats (i.e. energy consumption).

However, it seems like those devices are gone when I restart Home Assistant. I restarted last night (home server reboot due to unrelated problems with another app) and at first, things went fine. For example, I started the bedroom fan when going to bed and set a timer. The fan was still on this morning, so I investigated. I was not able to control the fan via alexa, and it was gone in lovelace (I use custom:button-cards for my main homeview lovelace, and in the place where the fan would be was just an empty card). It gets weirder. I was able to control the fan just fine via tasmota webUI (toggle on/off).

The console showed that the device was still using the correct topic for Home Assistant discovery, for example tasmota-9B8A3/tele/HASS_STATE. So no problem there. I could also not detect anything wrong with mqtt. So I typed SetOption19 1 once more into the console - and the device was right back in Home Assistant.

How is this possible? I have this problem with almost all tasmota devices at the moment. When I just type SetOption19, it will return SetOption19 1 (or ON), indicating that, indeed, Home Assistant discovery is still enabled. However, until I re-enabled this already enabled feature manually, they will not show up in Home Assistant.

I can think of three options:

  1. go back to manual mqtt for each device; while this should work, it is a big pain, for example, all energy measuring devices need multiple sensors that I’d have to set up per device, which is a lot of woring even when using yaml anchords
  2. try restarting Home Assistant less, then always manually re-enabling SetOption19 (obviously very annoying option)
  3. I have an existing automation prompting all tasmota devices for their status upon starting Home Assistant; I could alter this script so that it would send payload 1 to tasmota/cmnd/setoption19 (which is the group topic for all tasmota devices) upon (re)starting Home Assistant

While option 3 seems the most sensible to me at the moment, I don’t like it. This should work, and I believe it did work just fine until recently, so sending repetitive payloads is something I’d like to avoid. My Home Assistant configuration is not at the point where everything works as I want it to (meaning I constantly add new features, which I have to test multiple times in the process), which means that there are days where I restart Home Assistant multiple times per hour. I am not quite sure, but I believe the tasmota devices restart when you enable SetOption19, which would mean that each device would restart multiple times per day when I am testing and therefore constantly restarting Home Assistant.

Until just recently, I had sleep 0 on all my tasmota devices, which means they don’t go into deep sleep mode, which is supposed to conserve some energy. Now that I had the native Home Assistant support enabled, I also tested sleep 50, which means all devices go to sleep for 50 milliseconds constantly. This is, however, a value that should work just fine (I believe 50 is even the value set when using the pre-build binaries), so it should not do any harm. I will revert back to sleep 0 for now, but I doubt (or hope?) that this has nothing to do with the problem described above.

Any advice how I can fix this? Excepts for some LEDs, all my Christmas automations are done by tasmota relays as well, and currently none of them work due to this problem.

Thank you for your ideas :slight_smile:

Well that is bizarre! You don’t have a script or automation that is publishing something to them? Or a backlog command?

Have you checked buttonretain on, powerretain on etc…
SwitchRetain 0; ButtonRetain 0; PowerOnState 3; PowerRetain 1

I have a script I can run with my Tasmota settings and you could publish SetOption19 On at startup as well - publish to the sonoff group…

But really bizarre behaviour.

I guess you are using the tasmota 7.x branch ? There seems to be a bug in it regarding HA auto discovery. Easiest solution is to downgrade to 6.7.1.

I’m using 7.1.2.4 and no problems but I’m guessing you weren’t asking me?

@DavidFW1960 I don’t think I have any automations publishing to them, at least I couldn’t find anything when going through my files just now. I believe that I am already using your script template (at least I know that I got the script from this forum), and just added the Setoption19 1 command to it, so on every startup it will publish this.

I do have different PowerOnStates; usually it is 3, but some devices have different values (for example, dishwasher is always on, garage light is always off; unless manually switched), the other settings are as you posted them.

@francisp thank you! While it’s good to know that there is a fix, it’d suck having to downgrade all my tasmota devices. Do you know whether this is a bug in tasmota or home assistant and/or if it is supposed to be fix any time soon?

It does not seem to affect devices that are upgraded from 6.x, but only to newly flashed ones.

Edit : devices that were auto discovered with 6.X and upgraded later.

Hmm that is weird. Some of those devices were newly flashed (finally got tuya-convert working so I had to get some test devices ^^), but most of them were already running 6.x; I upgraded those by flashing the sonof-minima.bin, then the then current 7.1.0.1

Interesting… I know there was talk of doing a Reset 5 - maybe that was 7.x? They fixed that pretty quick.
@prankousky mine remember whatever state they were on before the restart. All of mine run the exact same settings (except the SV’s which have a 200ms pulse time)

I’m also having the same issue when restarting HA. I’ll try adding tasmota/cmnd/setoption19 to my HA start automation.