Tasmota - Entity Not Available

If I restart HA I always end up with all my tasmota devices showing as entity not available.
To get these back, I have to publish a SetOption19 1 command to all devices and then they appear correctly in HA again. is there something I should be doing so that they dont become not availabel in the first place?

Thank you

What version of Tasmota are you using ?

Hello

Mostly 6.6

What you could do is create an automation like this :

- id: '1565194745362'
  alias: Status on startup HA
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - data:
      payload: ''
      topic: sonoffs/cmnd/status
    service: mqtt.publish

This will make all Tasmota devices report their status when HA restarts.

Yes or wait for the Tele period to expire and republish the state to HA (can take up to 5 minutes)

Thank you, I’ll give it a go and see how I get on.

After looking at it more though, I think it may also be a case that a tasmota device drops it’s internet connection for a moment and changes to entity not available, then when it reconnects to the internet, it doesn’t come back into HA but I can still access it directly by its IP???

See my message about the Tele period above. Even if it’s dropping off the network, when it reconnects it will send status again at the expiry of the teleperiod (default is 300 seconds)
You can also play with retain settings in Tasmota (then HA will get the status from the broker automatically when it connects)

Hi David,

Thanks for the message.

These stay as entity not available for more than 300 seconds. My electric fire for example, is on a POW R2. The Tele period is set to just 5 seconds so that I can get a power reading more regular (to know the status of the fires heat output) but this is a regular for appearing as an entity no available. But is always available by going to its IP. However, it’s not until I do a SetOption19 that it appears again in HA??

I know very little about tasmota as I just flashes about 20 devices in one day and have not needed to look at it again since, so am unsure if it’s just a very simple thing I am missing.

I also get confused with MQTT so the two together…!!!

SetOption19 On… that enables MQTT discovery. It’s a once off.

Setting it again no doubt prompts the status command to be sent.

Try these commands…

SwitchRetain 0
ButtonRetain 0
PowerOnState 3
PowerRetain 1
SensorRetain 1

They will be remembered and only need executing once.

Also if you use MQTT explorer, you should see the messages in the broker.

I also have this automation:

- id: '1532478833428'
  alias: Power State Tasmota on HA Start-Up
  trigger:
  - event: start
    platform: homeassistant
  action:
  - service: script.turn_on
    data:
      entity_id: script.startupalltasmota

And the script

startupalltasmota:
  alias: Tasmota Restore State at Startup
  sequence:
  - data:
      payload: ''
      topic: sonoffs/cmnd/state
    service: mqtt.publish

Which makes Tasmota send the state to HA on HA startup. In my case for my Temperature/pressure/humidity sensors I needed SensorRetain On as per above otherwise it took a while to publish to HA…

Are you sending any other commands or anything to your devices that might cause discovery to be disabled?

Even those automations and scripts won’t help if it’s wifi issue but the retain settings should fix that anyway.

Thanks @DavidFW1960.
Ive just sent all them commands to all my tasmotas - thank godness for Tasmo Admin!!

Can you just explain the difference between sonoffs/cmnd/state and sonoffs/cmnd/status which I have just implement this morning following @francisp advice.

Thank you

Just tried it out :

SonoffBasic3/cmnd/status returns :

SonoffBasic3/stat/STATUS
{“Status”:{“Module”:1,“FriendlyName”:[“SonoffBasic3”],“Topic”:“SonoffBasic3”,“ButtonTopic”:“0”,“Power”:1,“PowerOnState”:3,“LedState”:1,“LedMask”:“FFFF”,“SaveData”:1,“SaveState”:1,“SwitchTopic”:“0”,“SwitchMode”:[0,0,0,0,0,0,0,0],“ButtonRetain”:0,“SwitchRetain”:0,“SensorRetain”:0,“PowerRetain”:0}}

SonoffBasic3/cmnd/state returns 3 messages :

SonoffBasic3/tele/STATE
{“Time”:“2019-12-30T16:22:37”,“Uptime”:“1T00:39:10”,“UptimeSec”:88750,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“SNOW”,“BSSId”:“00:E0:4B:E4:1F:6A”,“Channel”:2,“RSSI”:52,“Signal”:-74,“LinkCount”:1,“Downtime”:“0T00:00:12”}}

SonoffBasic3/tele/HASS_STATE
{“Time”:“2019-12-30T16:23:43”,“Uptime”:“1T00:40:16”,“UptimeSec”:88816,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“SNOW”,“BSSId”:“00:E0:4B:E4:1F:6A”,“Channel”:2,“RSSI”:54,“Signal”:-73,“LinkCount”:1,“Downtime”:“0T00:00:12”}}

SonoffBasic3/stat/RESULT
{“Version”:“8.1.0(tasmota)”,“BuildDateTime”:“2019-12-25T12:33:25”,“Core”:“2_6_1”,“SDK”:“2.2.2-dev(38a443e)”,“Module”:“Sonoff Basic”,“RestartReason”:“Software/System restart”,“Uptime”:“1T00:39:10”,“WiFi LinkCount”:1,“WiFi Downtime”:“0T00:00:12”,“MqttCount”:1,“BootCount”:22,“SaveCount”:87,“IPAddress”:“10.0.0.163”,“RSSI”:“52”,“LoadAvg”:19}

Thank you.

I just accidentally knocked the power off to by server and when turning back on, all my entities are unavailable;

I have then tried sending both MQTT commands (state and status) as you can see below all all sonoff, and although they receive it and they publish their state/status, this does not make the entities reappear in HA.

Furthermore, the server has been online now for 18 minutes so more than enough time for the tele period to have passed.

Any ideas?

I have over 30 tasmota devices, all except 2 on the 6.6 branch (1 on 7.x, 1 on 8.1), non of them show this behavior.

If setoption19 1 really works, you could try this automation :

- id: '1565194745362'
  alias: Status on startup HA
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - data:
      payload: 'setoption19 1'
      topic: sonoffs/cmnd/backlog
    service: mqtt.publish
1 Like

Hi Francis,

Yeh, its odd. I get the same issue with my defang hacks camera mqtt controls too - so I think it may be more to do with my mqtt broker??

I’ve just update my start up automation to something similar to what you posted above, basically posting setoption19 to all my devices so will see if this fixes my (tasmota at least) issues going forward.

Thank you.

Which Tasmota version do you have installed? I mean which bin file did you select… some binaries don’t include discovery.

Also, I’m not sure how you used TasmoAdmin? Or did you just use that to access the web interface of each device? Those commands are entered in the console of the device.

Hey,

I used tasmota.bin, so that includes auto discovery (I believe). Version varying from 6.6 >

In Tasmoadmin you can send commands to the the console of each device, rather than having to do it 20 times in 20 different consoles. It’s really handy.

So I’d try the console on one device first and see what it returns as you enter the commands one by one and also setoption19 on… what does it show you there?
Also can you see the messages in MQTT Explorer?
You may yet have an issue in Home Assistant… So lets see if MQTT Explorer is talking to the broker and also the devices.

Hi David,

I can see when sending commands from Tasmoadmin that they reaching all devices as im in one of the consoles at the same time.

That said, ive turned on all the settings you mentioned above but i still got issues keeping entities available.

However, publishing “SetOption19 1” to everything on HA restart appears to have fixed my problem.

No idea why the state/status messages wouldnt fix it, but at least its good… for now

THanks for your help

You really need to get it fixes as the write to flash constantly will kill them eventually. Have you thought about trying the Tasmota Discord? Also you have not mentioned trying MQTT Explorer…
What do you see in the console if you type in SetOption19 with no parameters? It will tell you if it’s on or off.

Hi David,

So, if i turn off my current “Fix” (Setting SetOption19 1 as an automation on HA start), I dont get my sensor info through;

However, there is MQTT messages flowing into HA;

And checking SetOption19 in the console, confirms it is still on;

And still, as per previous behaviour, if I set SetOption19 1, everything starts to show up again in HA. Very odd.