No new Humidity Device created [SOLVED]

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
rwblinn
Posts: 72
Joined: Wednesday 10 June 2015 21:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 4
Location: Hamburg (Germany)/Middelburg (NL)
Contact:

No new Humidity Device created [SOLVED]

Post by rwblinn »

Testing the "MQTT Auto Discovery Client Gateway with LAN" hardware using terminal commands via mosquitto_pub.
Setup Hardware: Remote Address=localhost, port=1883, Auto Discovery Prefix=domoticz
Domoticz version 2023.1 build: 15182 BETA channel on a Raspberry Pi 4B.

Issue
No new Domoticz device created from below command. No error in the log. Also after Domoticz restart, no new device.
EDIT: SOLVED - see next post.

Terminal command
This command is taken from the HA documentation > topic Sensors (https://www.home-assistant.io/integrati ... -discovery)

Code: Select all

mosquitto_pub -r -h localhost -p 1883 -t "domoticz/sensor/sensorGardenH/config" -m '{"name": "Garden Hum", "device_class": "humidity", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.humidity}}", "unit_of_measurement": "%RH", "unique_id": "SGH001"}'
Domoticz Log
Status

Code: Select all

2023-04-16 11:07:17.623 Status: MQTTADGateway: connected to: localhost:1883
2023-04-16 11:07:24.561 Status: MQTTADGateway: discovered: SGH001/Garden Hum (unique_id: SGH001)
Debug

Code: Select all

2023-04-16 11:07:07.238 Debug: MQTTADGateway: topic: domoticz/sensor/sensorGardenH/config, message:
2023-04-16 11:07:14.404 Debug: : MQTT PublishSchema 1 (1), Retain 0
2023-04-16 11:07:14.405 Debug: : MQTT PublishSchema 0 (0), Retain 0
2023-04-16 11:07:17.924 Debug: MQTTADGateway: topic: domoticz/status, message: online
2023-04-16 11:07:24.560 Debug: MQTTADGateway: topic: domoticz/sensor/sensorGardenH/config, message: {"name": "Garden Hum", "device_class": "humidity", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.humidity}}", "unit_of_measurement": "%RH", "unique_id": "SGH001"} 
Last edited by rwblinn on Sunday 16 April 2023 12:29, edited 2 times in total.
rwblinn
Posts: 72
Joined: Wednesday 10 June 2015 21:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 4
Location: Hamburg (Germany)/Middelburg (NL)
Contact:

Re: No new Humidity Device created [SOLVED]

Post by rwblinn »

UPDATE
Tested further:
After setting a value, the humidity device has been created but wrong type = General instead Humidity.
After changing the unit of measurement (took a lookup in the Domoticz source code) from %RH to %, the correct device was created:

Code: Select all

mosquitto_pub -r -h localhost -p 1883 -t "domoticz/sensor/sensorGardenH/config" -m '{"name": "Garden Hum", "device_class": "humidity", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.humidity}}", "unit_of_measurement": "%", "unique_id": "SGH001"}'
After setting a value, the device has been created from Type Humidity:

Code: Select all

mosquitto_pub -h 127.0.0.1 -p 1883 -t "domoticz/sensor/sensorGarden/state" -m '{"humidity":72}'
In addition created a second device Temperature:

Code: Select all

mosquitto_pub -r -h localhost -p 1883 -t "domoticz/sensor/sensorGardenT/config" -m '{"name": "Garden Temp", "device_class": "temperature", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.temperature}}", "unit_of_measurement": "°C", "unique_id": "SGT001"}'
After setting a value, the device has been created from Type Temp:

Code: Select all

mosquitto_pub -h 127.0.0.1 -p 1883 -t "domoticz/sensor/sensorGarden/state" -m '{"temperature":23.1}'
SUMMARY
Create two devices Temperature & Humidity:

Code: Select all

mosquitto_pub -r -h localhost -p 1883 -t "domoticz/sensor/sensorGardenH/config" -m '{"name": "Garden Hum", "device_class": "humidity", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.humidity}}", "unit_of_measurement": "%", "unique_id": "SGH001"}'

mosquitto_pub -r -h localhost -p 1883 -t "domoticz/sensor/sensorGardenT/config" -m '{"name": "Garden Temp", "device_class": "temperature", "state_topic": "domoticz/sensor/sensorGarden/state", "value_template": "{{value_json.temperature}}", "unit_of_measurement": "°C", "unique_id": "SGT001"}'
Publish to Set values:

Code: Select all

mosquitto_pub -h 127.0.0.1 -p 1883 -t "domoticz/sensor/sensorGarden/state" -m '{"temperature":22.1,"humidity":64}'
Subscribe to Get values:

Code: Select all

mosquitto_sub -h localhost -p 1883 -t "domoticz/sensor/sensorGarden/#"

Code: Select all

{"temperature":22.1,"humidity":64}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest