Wrong., They show up in the integration perfectly and don’t set a retained message at all - no idea where you are getting that from.
MQTT Discovery works brilliantly! It even worked for a nodemcu with a BME280 and BH1750 (??) sensor for me this week - the temp/humidity/pressure and illuminance sensors just showed up in the integration. Everything you osted about MQTT Discovery is WRONG.
In that case I will need to check my installation and I apologize.
That said, not everything I said is wrong as Discovery does use a MQTT topic and retained message. I am obviously just wrong about it showing in the integration section.
I have used discovery and I see the discovery topic and the retained MQTT message on the discovery topic, but I have never seen them show in integrations, with the only way to remove them being to send a blank message to the particular discovery topic in question.
I will investigate this further
I have no configuration at all for MQTT in my configuration.yaml… not the broker and nothing else either. I just use the Hass.io MQTT Broker (with a Home Assistant User - no local user - so the broker settings=the default except I change Active to true) Then on the Sonoffs, just setoption19 on and the above is the result. Everything is configured in the integration by MQTT discovery and has been for a long time - it’s not new - it might have been sonoff firmware version 6.x that introduced it…
People manually configuring the switches etc invariable incorrectly follow some guide or example from somewhere with retain: true set and this causes grief with retained messages and switches doing odd things. It is correct to set retain true in Tasmota though.
Great video here:
In Tasmota, these settings will ‘fix’ retain issues.
switchretain off
buttonretain on
buttonretain off
poweronstate 3
powerretain on
I don’t have them manually configured either. My previous post just mentioned you can still do that.
I am using discovery, but for some reason my auto discovered devices are not showing in integrations, despite the correct discovery topic being sent by the devices.
This must be something in my setup. I use ESPeasy and Tasmota mostly, with a couple of test devices on ESPurna. All three natively support discovery.
Great link though. Rob is great with his videos in general. Between his channel and DrZzs you can do virtually anything.
Digiblur is good too
Indeed - no idea what though. In the past with these kinds of issues I’ve nuked all MQTT stuff and even edited files in .storage and started again. It is weird though.
Shudder… lol. Tasmota all the way for me.
Yeah DrZzs, Rob and Digiblur are great info for sure.
You could try deleting the MQTT integration and manually adding it back after restarting.
What firmware version do you have for Tasmota? Discovery only started working properly after version 6 AFAICR
I see retained messages in MQTT Explorer but they are there because of the above settings in Tasmota - not because of discovery in HA.
That is why. 6.4.x introduced support for Discovery - and that is when I switched from a manual config to discovery for MQTT.
I recommend 6.6.x - just make sure you use core 2.3.0 not 2.5.2 or any 2.4.x release as those ones are nasty! I’m actually using the latest dev 6.6.0.4 with the pre-core 2.6 and I have had no mqtt or wifi dropouts in weeks that I didn’t cause.
Not true. If you have retain: true in Home Assistant your devices will do weird things when they reconnect to the broker.
The component - at least with Tasmota - remembers it’s settings regardless of retain. HA will need to wait for the telemetry period to expire before they update HA status on a restart but you can shortcut that by requesting a status message when HA restarts.
Well, then YOU have a problem. I’m using retain-on with several sensor, etc., and I never had a problem with HA. Not everything that happens in you system happens to every other HA-user.
Glad I stumbled on this, decided to start completely from scratch to use integrations properly as well as fix my zigbee2mqtt. Was starting to get really annoyed because nothing would appear and lost count of the times I deleted and reset Mosquito, mine were all 6.2.1! Doesn’t help that setting that option appears to work on older versions but obviously achieves nothing.
@DavidFW1960 Could you elaborate if you use the embedded MQTT broker of HA (which is now marked deprecrated) or the Mosquitto Hassio addon? Because https://www.home-assistant.io/docs/mqtt/discovery/ only describes the setup with the embedded MQTT broker if I understood this correctly.
If I try to add
mqtt:
...
to my configuration it will automatically cause home assistant to try to start the embedder broker:
5:48 ERROR (MainThread) [hbmqtt.broker] Broker startup failed: [Errno 98] error while attempting to bind on address ('0.0.0.0', 1883): address in use
2019-09-24 15:35:48 INFO (MainThread) [transitions.core] Exited state starting
2019-09-24 15:35:48 INFO (MainThread) [transitions.core] Entered state not_started
2019-09-24 15:35:48 ERROR (MainThread) [homeassistant.components.mqtt.server] Error initializing MQTT server
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/hbmqtt/broker.py", line 276, in start
loop=self._loop)
File "/usr/local/lib/python3.7/asyncio/streams.py", line 114, in start_server
return await loop.create_server(factory, host, port, **kwds)
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1374, in create_server
% (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 1883): address in use
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/server.py", line 47, in async_start
yield from broker.start()
File "/usr/local/lib/python3.7/site-packages/hbmqtt/broker.py", line 297, in start
raise BrokerException("Broker instance can't be started: %s" % e)
hbmqtt.broker.BrokerException: Broker instance can't be started: [Errno 98] error while attempting to bind on address ('0.0.0.0', 1883): address in use
2019-09-24 15:35:48 ERROR (MainThread) [homeassistant.components.mqtt] Unable to start embedded MQTT broker
2019-09-24 15:35:48 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 3.3 seconds.
2019-09-24 15:35:48 ERROR (MainThread) [homeassistant.setup] Setup failed for mqtt: Integration failed to initialize.
@DavidFW1960 Thanks for the answer,
How did you configure the discovery then? E.g. the documentation demands to set a discovery prefix for the topic path where my MQTT things should publish (e.g. “homeassistant”).
Could you show me an example how you configured it in your setup? I really struggle to do this, without the error message mentioned above.
E.g. according to the documentation, this MQTT message received by HA should automatically cause discovery of the component.
Message 1 received on homeassistant/sensor/rfidreader1/config at 14:55:
{
"name": "rfidreader1",
"device_class": "sensor",
"state_topic": "ident/rfid/reader1/data"
}
I don’t have any manual configuration at all for MQTT. All my devices run Tasmota and discovery is enabled on the device. I do have the MQTT integration as well and devices are discovered and show up in there.
Okay, I read the logs and I shouldn’t have used "device_class". Since it is already set by the discovery component. Then, it works like a charm.
Still, doesn’t show up on the integration page
@DavidFW1960, Do you know if a user-friendly documentation exist somewhere, detailing step-by-step how to use HA MQTT Front end Integration instead of config.yaml?
I currently have several Tasmotized Sonoff Basic switches configured in config.yaml and everything works just fine, but I have no usernames or passwords anywhere - neither on the broker, nor on each device. I was under the impression that it was possible to clean my config.yaml and go directly to Front end Integration and AutoDiscovery, but I got stuck already on the first step: The dialog box:
I have no idea what to type in that box, and I haven’t been able so far to find any explanations anywhere in the HA Docs. Wherever I search, it all refers to config.yaml stuff - which supposedly is a thing of the past ?