Tasmota - Entity Not Available

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.

What do you see in the console if you enter SetOption19 without any parameter - it will say if it is on or off… I see from last screenshot it is ON but was that before you turned it on? The HASS_STATE status is sent when discovery is on. So what does it show before you enter SetOption19 On?
If it is in fact on (it should be persistent) then you should ask the guys on the Tasmota Discord why it’s not getting the status in HA. If it is OFF then you need to find out why it’s not persistent as it should be.

Also if you go into the integration, can you screenshot and show the status entity?

Hi David

Yes the HASS_STATE was coming through before I SetOption19 to 1. I never set it to 1 at all there and it was already on as you can see from the 15:18:25 CMD I sent.

Status of entity is as follows;

Capture

Ill log on the Discord Tasmota server over the weekend and see if they can assist.

Thank you for all your help though.

hmm… ok so setoption19 on IS pereistent… so setting it again is triggering some other messages.

Can you do a SetOption10 On in the console and then copy/paste the output after that command… (Copy/paste, NOT screenshot)

Hi David,

Nothing particular comes up immediately;

10:21:48 CMD: SetOption10 On
10:21:48 MQT: master_bedroom_tv/stat/RESULT = {"SetOption10":"ON"}

No other messages come up then until the end of the telemetry period.

10:20:16 MQT: master_bedroom_tv/tele/STATE = {"Time":"2020-01-04T10:20:16","Uptime":"4T09:28:26","UptimeSec":379706,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":8,"POWER":"ON","Wifi":{"AP":1,"SSId":"xxxx-Bedroom","BSSId":"0E:41:58:01:04:5F","Channel":7,"RSSI":100,"Signal":-49,"LinkCount":3,"Downtime":"0T00:00:18"}}
10:20:16 MQT: master_bedroom_tv/tele/SENSOR = {"Time":"2020-01-04T10:20:16","ENERGY":{"TotalStartTime":"2019-10-06T01:08:26","Total":30.686,"Yesterday":0.172,"Today":0.035,"Period":2,"Power":26,"ApparentPower":4361,"ReactivePower":2878,"Factor":0.01,"Voltage":246,"Current":17.714}} (retained)
10:20:40 MQT: master_bedroom_tv/tele/HASS_STATE = {"Version":"8.1.0(tasmota)","BuildDateTime":"2019-12-25T12:33:25","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"BSD29","RestartReason":"Software/System restart","Uptime":"4T09:28:50","WiFi LinkCount":3,"WiFi Downtime":"0T00:00:18","MqttCount":8,"BootCount":217,"SaveCount":751,"IPAddress":"192.168.1.37","RSSI":"98","LoadAvg":19}
10:21:48 CMD: SetOption10 On
10:21:48 MQT: master_bedroom_tv/stat/RESULT = {"SetOption10":"ON"}
10:25:16 MQT: master_bedroom_tv/tele/STATE = {"Time":"2020-01-04T10:25:16","Uptime":"4T09:33:26","UptimeSec":380006,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":8,"POWER":"ON","Wifi":{"AP":1,"SSId":"xxxxx-Bedroom","BSSId":"0E:41:58:01:04:5F","Channel":7,"RSSI":100,"Signal":-49,"LinkCount":3,"Downtime":"0T00:00:18"}}
10:25:16 MQT: master_bedroom_tv/tele/SENSOR = {"Time":"2020-01-04T10:25:16","ENERGY":{"TotalStartTime":"2019-10-06T01:08:26","Total":30.689,"Yesterday":0.172,"Today":0.037,"Period":2,"Power":27,"ApparentPower":4327,"ReactivePower":2825,"Factor":0.01,"Voltage":245,"Current":17.660}} (retained)
10:25:40 MQT: master_bedroom_tv/tele/HASS_STATE = {"Version":"8.1.0(tasmota)","BuildDateTime":"2019-12-25T12:33:25","Core":"2_6_1","SDK":"2.2.2-dev(38a443e)","Module":"BSD29","RestartReason":"Software/System restart","Uptime":"4T09:33:50","WiFi LinkCount":3,"WiFi Downtime":"0T00:00:18","MqttCount":8,"BootCount":217,"SaveCount":752,"IPAddress":"192.168.1.37","RSSI":"100","LoadAvg":19}

You are showing SetOption10 On not SetOption19 On

Sorry, im having a mare here;

23:56:15 CMD: SetOption19
23:56:15 MQT: master_bedroom_tv/stat/RESULT = {“SetOption19”:“ON”}

hahahaha yeah…
So there must have been messages in the console after you turned it on otherwise turning it on when you restart to make the sensor work wouldn’t do anything related to turning it on or off… I’m just trying to see what happens that ‘fixes’ the problem…

I’d love for you to restart HA and get the blank sensors, then go int the console on one device and

SetOption19

and report what it shows… it SHOULD be saying

23:56:15 CMD: SetOption19
23:56:15 MQT: master_bedroom_tv/stat/RESULT = {“SetOption19”:“ON”}

as per above as it is a persistent option.
Then do this:

SetOption19 On

and report the output (not a screenshot but copy/paste) so I can see what it is doing when you do that…