I don’t get a prompt for username and password - only the discovery checkbox.
Do you still have entries in configuration.yaml?
I don’t get a prompt for username and password - only the discovery checkbox.
Do you still have entries in configuration.yaml?
Hi David,
Could you please let me know where I’m going wrong here? I have some Sonoff’s with Tasmota set up in Hassio using Mosquitto and everything works fine. I have Integrations set up and it picks up a few shelly switches but not my Sonoff’s? In my confi.yaml I tried removing everything and that didn’t work, so then I tried it with just
`mqtt:
broker: core-mosquitto
discovery: true
discovery_prefix: homeassistant`
Also, these are the versions that the sonoff’s are running.
showing and that still doesn’t work? I’ve tried restarting Mosquitto and still nothing shows.
Do I need to remove something else from another file in HA?
First - thank you so much for stepping in
Not to my knowledge, I have double-checked again now. Every line related to MQTT and Sonoff is commented out. I have also tried several times to delete the integration, restart HA, recreate the integration, added MQTT broker IP and accepted ok.
I can see in Mosquitto that the Sonoffs connect as they should.
I still have some Lovelace cards left in HA from my previous setup which obviously now fail as they refer to non-existing devices. I assumed that since I didn’t change any Tasmota device names, the cards (HA) would pick up the same names and restore as soon as the integration was successful. Am I right?
What else should I be looking for apart from mqtt: and switch: sections in config.yaml?
Sounds like we both have the exact same issue.
Ok for a start… Tasmota 5.12.0 doesn’t support discovery so far as I know.
So start by upgrading all of them to 6.7.1 - Note you may need to use Reset 5 before flashing them.
If you are using hass.io and using the core Mosquitto addon, then you don’t need to define anything for MQTT or lights or switches in configuration.yaml so remove all those and restart home assistant.
Next, create a Home Assistant User for MQTT - if you have already configured a username/password for MQTT in Tasmota configuration, use that exact same username/password for the Home Assistant user you create. If you are using anonymous connections, Stop! That just complicates things and you will need an ACL file. Just don’t. Set all your devices to use this new username and password.
Then with the Mosquitto addon, you can just use the DEFAULT settings.
Lastly, if you already have a MQTT integration, remove it and restart Home Assistant and then when restarted, add it back. It should then only ask for you to check a box for Discovery. It shuld not ask for username/password for broker.
Lastly, in the console of the Tasmota devices, SetOption19 On
Then the devices should appear in home assistant. You might need to restart home assistant again before they show up in the integration.
If you use discovery, you should not define them manually at all in configuration.yaml
That works!! On the one that has the latest version I ran SetOption19 in the console and now it shows up, no need to re-start.
I have been struggling to update the rest of the sonoff’s, I’m getting these two errors in tasmoadmin, I don’t suppose you know where I’m going wrong with this one?
I don’t know - but I’d just download the minimal and release binaries manually from github and specifying those in the fields below your screenshot.
Actually the error might be because it’s no longer sonoff-tasmota as they renamed the repo to tasmota. I am seeing 404 errors in my tasmoadmin as well now I look there. I think tasmoadmin needs an update.
https://github.com/arendst/Tasmota/releases/download/v6.7.1/sonoff-minimal.bin
and
https://github.com/arendst/Tasmota/releases/download/v6.7.1/sonoff.bin
Thanks, but that still doesn’t update it, the files updates correctly and it looks like it’s worked. But when I click back to the device list they are all still on the same version?
Try a reset 5 in the console and try again.
I would download the firmware files (both of them) and using the webUI update minimal and then full one device at a time rather than using TasmoAdmin. Also note the upgrade path as well…
Thanks for your help David, that also didn’t work, I might just pull them out of the wall and flash them.
Well that sucks!
No big deal, two down 5 to go.
I’m not exactly sure what you mean by “If you use discovery…” ?
I know that Integrations/Discovery and configuration.yaml is an either/or game.
I had configuration.yaml up until yesterday. Now I have removed everything from configuration.yaml, and my plan is to try to move over to Integration/Discovery. That’s where things fail - I guess mainly because I cannot find ample documentation anywhere.
Your help is much appreciated, Sir.
How did you get your MQTT devices to show in integrations?
I activated mqtt discovery and added a simple mqtt sensor in the configuration.yaml:
sensor ds18b20:
- platform: mqtt
state_topic: "home/pi/t"
name: "MQTT Sensor 1"
unit_of_measurement: kwh
icon: mdi:car-traction-control
unique_id: 00112233445566
mqtt:
discovery: true
I learned in this thread that you need unique_id for the mqtt sensors to show up in the entities list of home assistant. What I didnt get working so far is for my mqtt devices to show in integrations just like in your screenshot.
The documentation says the following:
Two parts are required on the device side: The configuration topic which contains the necessary device type and unique identifier and the remaining device configuration without the device type.
However, I cannot find anything in the documentation on how to define the device type.
Any ideas?
If you define it in configuration.yaml then it’s not using discovery. They’re two different methodologies.
For autoconfig you have to publish JSON formatted data so for example I can publish to the topic
homeassistant/light/216773570734218542/config - The light part of the topic is the device type. The unique ID is contained within the payload but I also use it as the objectID to make the topic unique
The contents of the payload look something like
{
"name": "KitchenBulb3",
"unique_id": "216773570734218542",
"command_topic": "light/Kitchen/KitchenBulb3/216773570734218542/switch",
"state_topic": "light/Kitchen/KitchenBulb3/216773570734218542/status",
"brightness_command_topic": "light/Kitchen/KitchenBulb3/216773570734218542/brightness/set",
"brightness_state_topic": "light/Kitchen/KitchenBulb3/216773570734218542/brightness",
"availability_topic": "light/Kitchen/KitchenBulb3/216773570734218542/LWT",
"brightness_scale": 100,
"qos": 0,
"payload_on": "1",
"payload_off": "0",
"optimistic": "false"
}
Which contains all the information necessary for the device.
Read through https://www.home-assistant.io/docs/mqtt/discovery/ it describes all the device types
Let me see if I understand that correctly.
When im using MQTT discovery, I cannot define “state_topic” for each sensor individually anylonger, because everything gets handled by HA. That would explain the errors in configuration when I try to do so.
I would have to configure e.g. my microcontroller to publish something along the lines of “homeassistant/light/216773570734218542/config” when im using “discovery_prefix: homeassistant” in HA, want the device type to be “light” and the unique id to be “216773570734218542”.
Im using pubsubclient for my ESP8266. Publishing on there works like this:
#### int publish (topic, payload)
Publishes a string message to the specified topic.
##### Parameters
* topic - the topic to publish to (const char[])
* payload - the message to publish (const char[])
##### Returns
* false - publish failed, either connection lost, or message too large
* true - publish succeeded
Right now im publishing like this:
client.publish(“esp/test”, “Hello from ESP8266”);
Would rewriting it to the following do the trick or am I fundamentally getting something wrong here:
client.publish(“homeassistant/light/216773570734218542/config”, “Hello from ESP8266”);
I have the feeling that pubsubclient does not support sending the kind of payload you posted.
Autodiscover only works with a full JSON payload your example of “Hello from ESP8266” doesn’t provide any setup data. The payload has to include pretty much everything that you had in your configuration.yaml so you would send a payload like:
{"name":"Sensor1","unique_id":"00112233445566","state_topic":"home/pi/t","unit_of_measurement":"kwh"}
To a topic of:
homeassistant/sensor/00112233445566/config
Thank you, I get the concept now. Appreciate the time you took.
I will have to test whether the const char[] of .publish() will accept JSON arguments passed. Im afraid it will not and some converting will be needed. That will definately take some time to get it to work on my ESP. Considering I have little to no actual advantages from auto discovering MQTT devices (over manual entry), I will get back to it later when I feel more confident.
Thanks again!
I use ArduinoJson.h and build a JsonObject to pass the config
void publishTempConfig() {
const size_t bufferSize = JSON_OBJECT_SIZE(8);
DynamicJsonBuffer jsonBuffer(bufferSize);
JsonObject& root = jsonBuffer.createObject();
root["name"] = TEMP_NAME;
root["dev_cla"] = TEMP_CLASS;
root["stat_t"] = TOPIC_STATE;
root["unit_of_meas"] = "°F";
root["val_tpl"] = "{{value_json.temperature}}";
root["pl_avail"] = "online";
root["pl_not_avail"] = "offline";
root.prettyPrintTo(Serial);
Serial.println("");
char message[256];
root.printTo(message, sizeof(message));
client.publish(TOPIC_TEMP_CONF, message, true);
}