Sonoff / Tasmota started regularly showing "Unavailable" on Home Assistant

Bingo!

Might dip my toe back into discovery mode but one question, setting options ie “SetOption19 1” does it stick on the device even after the device is repowered?

Yes. SetOption19 On is persistent. Make sure the integration is configured for discovery as well. (It’s a checkbox when you add the broker). If you have to, remove the integration, restart HA, add the integration and restart again and you’ll be good to go.

1 Like

Thanks David,

Suspected as much.

Any thoughts on why my MQTT Discovery is not working? I originally had then setup manually but I wanted to see how the discovery works but I can’t get anything to show up.
I have version 6.5.0(release-sonoff) flashed with SetOption19 On.
Running Hass.IO 0.90.0
Using the Mosquitto broker plugin, default configuration.
Clicked on the integration and check the discovery checkbox.
Restarted, and still nothing shows up in the integration.
I also commented out the manual settings in the configuration.yaml

Any idea as to what I missed?

So nothing at all in config yaml for mqtt (not even an mqtt section?) No switches defined in yaml?
Did you create a home assistant user or are you using a local user? If a Home Assistant user, did you configure that in the devices mqtt settings?
If a home assistant user did you set active: false?

Just got it to work.
Once the integration and discovery are setup you need to run the SetOption19 1 on the devices again to show up in HA.
I guess this causes a “push” that allows HA to see it.
Now I have all of the other new sensor available :slight_smile:

Thanks for responding.

ah actually, 5 minute wait for the tele period… it’s persistent option for setoption19
Use this automation when you start HA to get Tasmota to publish the state otherwise you will wait 5 mins on Home Assistant after a restart as well

- id: 'sonoffstart'
  alias: Power State Sonoff on HA Start-Up
  trigger:
  - event: start
    platform: homeassistant
  action:
  - data:
      payload: ''
      topic: sonoffs/cmnd/state
    service: mqtt.publish
  initial_state: 'true'
3 Likes

Hi David,

How does discovery work? IE
Does HA query the device or does the device advertises itself every 5 minutes?
And by setting the option 19 does this tells the device to advertise itself every 5 minutes??

No setoption19 on turns on discovery so the device advertises itself… but it only reports the state every 5 minutes so if you restart home assistant it could be 5 minutes before the device is seen… But if you run that automation (posted on the Tasmota Wiki) it will update immediately… so switches already on will show as on in home assistant… or you can wait out the tele period.
All the automation does is syncs up the states in HA on start so they are the same as Tasmota.

1 Like

Thanks again David,

That makes perfect sense.

Now 6.5.0 is out, should we go for that version?

I did… actually went to dev 6.5.0.1 as Adrian fixed the state message so it includes the HASS_STATE message which is really cool but was taking 5 minutes for it to populate…

Tested a couple of devices with release 6.5.0 and works like a charm in discovery mode.
Might have been around on previous versions, but just notice discovery also adds a sensor information of the device…very handy diag. tool.

the sensor information was introduced in a dev version of 6.4.1.x… it’s the main reason I didn’t want to revert to 6.4.1 and core 2.3 and persisted with core 2.5.0 as I couldn’t compile using 2.3.0 until they fixed a bug… Anyway, it’s a great feature.

thought I’d throw this in, all going swimingly on 6.5.0 on all sonoffs (mix of basics and an s20). I’ve even put some more in!

BTW want to shout out to tasmoadmin! fantastic, i can flash everything in one hit, including minimal -> full.

it’s great

TasmoAdmin

6.5.0.1 on core 2.3.0 has fixed my problem. I had Amysen plugs flashed with the bad firmware and the longest they would stay online at one stretch was 6 minutes. Was thinking they had lousy WIFI radios or something until I found this thread. Now they seem completely stable.

I seem to be having the same issue, and none of the above seems to be working for me (exact cant find 6.5.0.1 bin file though). FYI - I am relatively new to HA and new to Tasmota & MQTT

I have flashed 1 device with Tasmota and it often goes to “Unknown” state and also noticed that when I try switch on/off the Sonoff via HA it is sometimes quick, but quite often there is a long delay and the switch reverts to its previous state, then about 10s later the device will switch on/off, but the state in HA does not get updated. Also at times pressing the physical button takes a long time to switch on/off

I am testing with a Sonoff Basic & have tried 6.5.0 & 6.5.0.16 (Core 2.3.0) - WiFi signal is 100%

Using:

NOTE:

Hardware:

  • Installed on a Raspberry Pi Model 3B (32GB SD card)
  • Router is an Asus RT-AC86U running Merlin v384.12

I also had TasmoAdmin setup and experienced the same issues - also sometimes takes a long time using the devices WebUI, so I am thinking maybe its the MQTT broker or hardware?

Not sure what to try next, any ideas?

  • Did I maybe do something wrong in the Tasmota config (or a SetOption that I need to run)?

I would prefer to use Tasmota over original firmware but the current issue makes the devices unusable/unreliable

I am waiting for a better and bigger SD card and was thinking of setting up Hassio on Raspbian Stretch Lite via docker and having a separate docker for MQTT, but not sure if worth doing all that?

What do you see in the status object for the switch? It will list MQTT and WiFi connects in there. It is also possible that you ill get a better result with core 2.4.2 or 2.5.2. Admittedly there is only one person on the forums I have ever seen that has a stable MQTT with core 2.4.2…

1 Like

My 5 cent

I was Having same problem “Unavailable” on one of my Switch “Gosund KS-602S”

so i did a web server upgrade First time every done this
image
after a lot of paying

its worked
image

For Status Object - is it this that you looking for?
{“Status”:{“Module”:1,“FriendlyName”:[“Sonoff Basic Spare 1”],“Topic”:“sonoff-basic-free1”,“ButtonTopic”:“0”,“Power”:0,“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}}

Will try the different core versions and see if that makes any difference