Shelly H&T with MQTT

Hi,

I bought a couple of Shelly H&T devices to monitor the temperature in different parts of my house.
The built in fw support MQTT so I chose to use this instead of the app to connect to HA.
This is my first contact with MQTT but installing mosquitto through hassio was easy. Once setup I found a post here on the forum from elRadix that showed the config/topics to add.

At first I didn’t get any values in HA, just said unknown. This was late last night, in the morning now when I checked I do get values reported in HA but the mosquitto log is filled with these errors:

1552128272: New connection from 192.168.0.51 on port 1883.
1552128272: New client connected from 192.168.0.51 as shellyht-58FCBD (c1, k60, u’xxx’).
1552128288: Socket error on client shellyht-58FCBD, disconnecting.

Should I get these errors every time the devices wakes up and reports its values?

Mosquitto config look like this:

{
“log_level”: “info”,
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”,
“web”: {
“enabled”: true,
“ssl”: false
},
“broker”: {
“enabled”: true,
“enable_ws”: true,
“enable_mqtt”: true,
“enable_ws_ssl”: false,
“enable_mqtt_ssl”: false,
“allow_anonymous”: false
},
“mqttusers”: [
{
“username”: “xxx”,
“password”: “xxx”,
“readonly”: false,
“topics”: [
“#”
]
}
]
}

The Shelly H&T devices has the following settings:

You can use this script to easy add Shelly H&T sensors to the HA.

Thank you, this script does indeed make it easy to add the Shelly devices but I don’t think this is the issue.

I’m pretty sure the manual entries I have made are correct, I’m just a little confused regarding all the socket errors in the mosquitto log. If there is an issue or maybe this is correct that battery powered devices throws these errors in log as they only wake up and then go to sleep.

I have same behavior, I think this is the default behavior for Shellies that runs on battery indeed.

The @Bieniu script has the same behavior for battery powered, they are “unavailable” when they shutdown from wifi.

I’m using this conf in configuration.yaml to make them showing the last updated value (with the retain ticket on the Shelly web interface)

  - platform: mqtt
name: "Humiditée Chambre"
state_topic: "shellies/shellyht-58FA2E/sensor/humidity"
unit_of_measurement: '%'
expire_after: 86400
force_update: true
json_attributes_topic: "shellies/shellyht-58FA2E/sensor/humidity"

Hi,
Try with QoS = 1…