Thanks @Bieniu, changing from hass to homeassistant for the discovery prefix fixed the problem. Don’t know how I missed it, but you might change it in your example automation to match the default.
I will check with Shelly support as to why the MAC doesn’t match the reported MAC
Hello @Bieniu and thanks for this beautiful script !
I’m trying to use it with my Shelly HT , and i feel like i’m not far from succeed but I don’t know what i’m missing.
I’m using embeded MQTT on home assistant on docker, i’m receiving well MQTT messages from my shelly , but no entity are created, do you know what I should watch next ?
Thanks again for your answer, sorry i’m a bit new to MQTT.
From what I understand I need to subscribe with a MQTT client to directly read the shellies topic, right ?
my MQTT server isn’t exposed from outside so I can’t use an MQTT client right now, i’ll try tonight at home.
The only thing I can provide right now is the HA logs, where just before the “Transmitting messages” the MQTT component is logging the received message, which seems not that much verbose :
So, I have updated the Shelly HT firmware, it seems better , but still no entities showing
There is one error showing 10 sec after your python script is processed , don’t know if it’s related :
Are there any MQTT or Discovery errors in log associated? I can’t help if I don’t know where the problem is. You use the built-in MQTT broker. Have you considered installing the Mosquitto? The built-in broker has issues and will soon be removed from HA.
I finally got it working, it was much more simple than I thought, I think this is basic for MQTT users, but for begginers like me it was not obvious. Maybe this should be written in your prerequierements :
Don’t use GUI MQTT configuration, configure MQTT in yaml file to put the discovery variable to true :
This is what was missing for me for this to work :
discovery: true discovery_prefix: homeassistant
Now I have another issue with the auto discover script. Even with the retain label on, sensors are getting unavailable in HA. I tried to create the sensor manually in the configuration.yaml and I don’t have this issue (left sensors auto discovered with your script, right manual with configuration.yaml) :
Do I understand correctly that the graph for the sensor is drawn but the state is unvailable? ShellyH&T connects to the network only from time to time and that is why most of the time is unavailable.