Page 1 of 1

No new Humidity Device created [SOLVED]

Posted: Sunday 16 April 2023 11:16
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"} 

Re: No new Humidity Device created [SOLVED]

Posted: Sunday 16 April 2023 12:11
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}