Page 2 of 2

Re: Autodiscovery with TheengsGateway

Posted: Monday 16 January 2023 13:37
by StephenR
Thanks waltervl!

I have resubmitted the PR on the development branch so hope it is better this time!

@Doler
If you would were able to test, that would be superb!

It is now on the dev branch so much easier. Just need to do a normal build but using https://github.com/StephenR1/domoticz.git as the source.

All else should be the same.

In case it does not work...

If you run with debug turned on for hardware, you should see messages for every topic coming in and saying whether or not the wildcarded subscription matches the message topic which was received.

You should (probably) see only one match for each message.

Re: Autodiscovery with TheengsGateway

Posted: Monday 16 January 2023 16:03
by gizmocuz
There should be no issue with ' | is_defined' , it is stipped, so there is no need to use OpenHABDiscovery for this

Re: Autodiscovery with TheengsGateway

Posted: Monday 16 January 2023 21:34
by Doler
StephenR wrote: Monday 16 January 2023 13:37 Thanks waltervl!

I have resubmitted the PR on the development branch so hope it is better this time!

@Doler
If you would were able to test, that would be superb!

It is now on the dev branch so much easier. Just need to do a normal build but using https://github.com/StephenR1/domoticz.git as the source.

All else should be the same.

In case it does not work...

If you run with debug turned on for hardware, you should see messages for every topic coming in and saying whether or not the wildcarded subscription matches the message topic which was received.

You should (probably) see only one match for each message.
Thank you for this update. The good news is that it's working: I now get 3 devices (temp/humi, battery% and voltage) for each of my 2 LYWSD03MMC thermometers. So great work!

One question left: is there a possibility to skip the creation of the other 19 devices (most of them settings for OpenMQTTGateway)? I guess they could be used in HASS but here it's of no use nor does it hold useful information.

Re: Autodiscovery with TheengsGateway

Posted: Monday 16 January 2023 22:41
by StephenR
Thanks Doler. That is good news!
I think OpenMQTTGateway is basically identical to Theengs Gateway (other than target platform) and Theengs has an option to filter out messages:

-Df DISCOVERY_FILTER [DISCOVERY_FILTER ...], --discovery_filter DISCOVERY_FILTER [DISCOVERY_FILTER ...]
Device discovery filter list for Home Assistant

Maybe does OpenMQTTGateway support that?

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 10:10
by MichelFrance
Hello,

I read these posts with much interest.

I am using the openMQTTGateway on an ESP32 to monitor a few 433 devices in Domoticz through Mosquitto. It works, but I noticed a small problem: previously I was using and rfxTRX433 usb device and each sensor was combined [ie. a temp + humidity sensor ends to a single temp + humidity (+signal strength) in Domoticz], now, in Domoticz, I have 4 devices created for each 433 sensor: One for the temperature, one for the humidity one for the signal strength (but with the "sound level" type!) and one for the battery.

When reading your posts, it seems that in the same (nearly) situation, you have a combined temp+humidity device in Domoticz.

I don't find any way to get a combined device. Could you help me?

He is some detailed information:
About Domoticz
Version: 2025.1
Build Hash: 89d5c900d
Compile Date: 2025-05-05 09:02:49
dzVents Version: 3.1.8
Python Version: 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0]

trace from the openMQTTGateway:

Code: Select all

N: [ OMG->MQTT ] topic: home/OMG_multi_receiver/RTL_433toMQTT/Ambientweather-F007TH/2/154 msg: {"model":"Ambientweather-F007TH","id":154,"channel":2,"battery_ok":0,"temperature_C":25.05556,"humidity":63,"mic":"CRC","protocol":"Ambient Weather F007TH, TFA 30.3208.02, SwitchDocLabs F016TH temperature sensor","rssi":-51,"duration":215996} 

or
 
N: [ OMG->MQTT ] topic: home/OMG_multi_receiver/RTL_433toMQTT/Nexus-TH/1/117 msg: {"model":"Nexus-TH","id":117,"channel":1,"battery_ok":1,"temperature_C":26.1,"humidity":56,"protocol":"Nexus, FreeTec NC-7345, NX-3980, Solight TE82S, TFA 30.3209 temperature/humidity sensor","rssi":-17,"duration":986996}
MQTT autodiscovery config topics

Code: Select all

homeassistant/sensor/Ambientweather-F007TH-2-154-humidity/config
{"stat_t":"+/+/RTL_433toMQTT/Ambientweather-F007TH/2/154","dev_cla":"humidity","unit_of_meas":"%","name":"Humidity","uniq_id":"Ambientweather-F007TH-2-154-humidity","val_tpl":"{{ value_json.humidity | is_defined }}","stat_cla":"measurement","device":{"ids":["Ambientweather-F007TH-2-154"],"cns":[["mac","Ambientweather-F007TH-2-154"]],"mdl":"Ambientweather-F007TH","name":"Ambientweather-F007TH-2-154","via_device":"OMG_multi_receiver"}}

homeassistant/sensor/Ambientweather-F007TH-2-154-rssi/config
{"stat_t":"+/+/RTL_433toMQTT/Ambientweather-F007TH/2/154","dev_cla":"signal_strength","unit_of_meas":"dB","name":"RSSI","uniq_id":"Ambientweather-F007TH-2-154-rssi","val_tpl":"{{ value_json.rssi | is_defined }}","stat_cla":"measurement","device":{"ids":["Ambientweather-F007TH-2-154"],"cns":[["mac","Ambientweather-F007TH-2-154"]],"mdl":"Ambientweather-F007TH","name":"Ambientweather-F007TH-2-154","via_device":"OMG_multi_receiver"}}

homeassistant/sensor/Ambientweather-F007TH-2-154-temperature_C/config
{"stat_t":"+/+/RTL_433toMQTT/Ambientweather-F007TH/2/154","dev_cla":"temperature","unit_of_meas":"°C","name":"Temperature","uniq_id":"Ambientweather-F007TH-2-154-temperature_C","val_tpl":"{{ value_json.temperature_C | is_defined }}","stat_cla":"measurement","device":{"ids":["Ambientweather-F007TH-2-154"],"cns":[["mac","Ambientweather-F007TH-2-154"]],"mdl":"Ambientweather-F007TH","name":"Ambientweather-F007TH-2-154","via_device":"OMG_multi_receiver"}}

homeassistant/binary_sensor/Ambientweather-F007TH-2-154-battery_ok/config
{"stat_t":"+/+/RTL_433toMQTT/Ambientweather-F007TH/2/154","dev_cla":"battery","name":"Battery","uniq_id":"Ambientweather-F007TH-2-154-battery_ok","val_tpl":"{{ value_json.battery_ok | is_defined }}","pl_on":"0","pl_off":"1","device":{"ids":["Ambientweather-F007TH-2-154"],"cns":[["mac","Ambientweather-F007TH-2-154"]],"mdl":"Ambientweather-F007TH","name":"Ambientweather-F007TH-2-154","via_device":"OMG_multi_receiver"}}

homeassistant/sensor/Nexus-TH-1-117-humidity/config
{"stat_t":"+/+/RTL_433toMQTT/Nexus-TH/1/117","dev_cla":"humidity","unit_of_meas":"%","name":"Humidity","uniq_id":"Nexus-TH-1-117-humidity","val_tpl":"{{ value_json.humidity | is_defined }}","stat_cla":"measurement","device":{"ids":["Nexus-TH-1-117"],"cns":[["mac","Nexus-TH-1-117"]],"mdl":"Nexus-TH","name":"Nexus-TH-1-117","via_device":"OMG_multi_receiver"}}

homeassistant/sensor/Nexus-TH-1-117-rssi/config
{"stat_t":"+/+/RTL_433toMQTT/Nexus-TH/1/117","dev_cla":"signal_strength","unit_of_meas":"dB","name":"RSSI","uniq_id":"Nexus-TH-1-117-rssi","val_tpl":"{{ value_json.rssi | is_defined }}","stat_cla":"measurement","device":{"ids":["Nexus-TH-1-117"],"cns":[["mac","Nexus-TH-1-117"]],"mdl":"Nexus-TH","name":"Nexus-TH-1-117","via_device":"OMG_multi_receiver"}}

homeassistant/sensor/Nexus-TH-1-117-temperature_C/config
{"stat_t":"+/+/RTL_433toMQTT/Nexus-TH/1/117","dev_cla":"temperature","unit_of_meas":"°C","name":"Temperature","uniq_id":"Nexus-TH-1-117-temperature_C","val_tpl":"{{ value_json.temperature_C | is_defined }}","stat_cla":"measurement","device":{"ids":["Nexus-TH-1-117"],"cns":[["mac","Nexus-TH-1-117"]],"mdl":"Nexus-TH","name":"Nexus-TH-1-117","via_device":"OMG_multi_receiver"}}

homeassistant/binary_sensor/Nexus-TH-1-117-battery_ok/config
{"stat_t":"+/+/RTL_433toMQTT/Nexus-TH/1/117","dev_cla":"battery","name":"Battery","uniq_id":"Nexus-TH-1-117-battery_ok","val_tpl":"{{ value_json.battery_ok | is_defined }}","pl_on":"0","pl_off":"1","device":{"ids":["Nexus-TH-1-117"],"cns":[["mac","Nexus-TH-1-117"]],"mdl":"Nexus-TH","name":"Nexus-TH-1-117","via_device":"OMG_multi_receiver"}}
And the result in Domoticz:
117-154.jpg
117-154.jpg (92.87 KiB) Viewed 312 times

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 15:30
by Doler
I probably had a combined temperature/humidity device but in the mean time I hacked these meters to use the Zigbee protocol as that is an interface I already used.
I do have some DIY temperature meters based on ESP32 that I programmed for auto discovery in Domoticz. From that I learned that Domoticz tries to combine device attributes when the device name is the same. I guess that in your case Domoticz gets confused since all device attributes have the same device name (eg "mdl":"Nexus-TH","name":"Nexus-TH-1-117"). When battery and signal strength would have different names Domoticz would combine temperature + humidity.

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 15:52
by gizmocuz
It is the way the config objects are created.
For example, my zigbee temp+hum+baro is combined into one

For example when using the below config payloads, it creates one combined sensor.
Maybe you could ask openMQTTGateway to do the same

(have a look at the unique_id)

Code: Select all

homeassistant/sensor/0x00158d0004a98668/temperature/config
{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"hw_version":30,"identifiers":["zigbee2mqtt_0x00158d0004a98668"],"manufacturer":"Aqara","model":"Temperature and humidity sensor","model_id":"WSDCGQ11LM","name":"Temp_BuitenSensor","sw_version":"3000-0001","via_device":"zigbee2mqtt_bridge_0x00124b0021cc4112"},"device_class":"temperature","enabled_by_default":true,"object_id":"temp_buitensensor_temperature","origin":{"name":"Zigbee2MQTT","sw":"2.3.0-dev","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Temp_BuitenSensor","unique_id":"0x00158d0004a98668_temperature_zigbee2mqtt","unit_of_measurement":"°C","value_template":"{{ value_json.temperature }}"}

homeassistant/sensor/0x00158d0004a98668/humidity/config
{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"hw_version":30,"identifiers":["zigbee2mqtt_0x00158d0004a98668"],"manufacturer":"Aqara","model":"Temperature and humidity sensor","model_id":"WSDCGQ11LM","name":"Temp_BuitenSensor","sw_version":"3000-0001","via_device":"zigbee2mqtt_bridge_0x00124b0021cc4112"},"device_class":"humidity","enabled_by_default":true,"object_id":"temp_buitensensor_humidity","origin":{"name":"Zigbee2MQTT","sw":"2.3.0-dev","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Temp_BuitenSensor","unique_id":"0x00158d0004a98668_humidity_zigbee2mqtt","unit_of_measurement":"%","value_template":"{{ value_json.humidity }}"}

homeassistant/sensor/0x00158d0004a98668/pressure/config
{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"hw_version":30,"identifiers":["zigbee2mqtt_0x00158d0004a98668"],"manufacturer":"Aqara","model":"Temperature and humidity sensor","model_id":"WSDCGQ11LM","name":"Temp_BuitenSensor","sw_version":"3000-0001","via_device":"zigbee2mqtt_bridge_0x00124b0021cc4112"},"device_class":"atmospheric_pressure","enabled_by_default":true,"object_id":"temp_buitensensor_pressure","origin":{"name":"Zigbee2MQTT","sw":"2.3.0-dev","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Temp_BuitenSensor","unique_id":"0x00158d0004a98668_pressure_zigbee2mqtt","unit_of_measurement":"hPa","value_template":"{{ value_json.pressure }}"}

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 18:30
by MichelFrance
Doler wrote: Wednesday 25 June 2025 15:30 From that I learned that Domoticz tries to combine device attributes when the device name is the same. I guess that in your case Domoticz gets confused since all device attributes have the same device name (eg "mdl":"Nexus-TH","name":"Nexus-TH-1-117"). When battery and signal strength would have different names Domoticz would combine temperature + humidity.
Thanks for your answer. Do you mean that Domoticz would combine if there was only temp and humidity, but as there is also battery and signal strength Domoticz has no combined device and decides not to combine temp + humidity on one side and let battery and signal strength single?

By the way when receiving the same device with my rfxTRX433, the single created device has temp + humidity + Signal strength seen in the setup/devices tab and maybe battery state but not directly visible.

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 18:39
by MichelFrance
gizmocuz wrote: Wednesday 25 June 2025 15:52 For example when using the below config payloads, it creates one combined sensor.
Maybe you could ask openMQTTGateway to do the same

(have a look at the unique_id)

Thanks for your answer. Do you mean that the config topics should be:

homeassistant/sensor/Nexus-TH-1-117/humidity/config
homeassistant/sensor/Nexus-TH-1-117/rssi/config
homeassistant/sensor/Nexus-TH-1-117/temperature_C/config (or even .../temperature/...)
homeassistant/binary_sensor/Nexus-TH-1-117/battery_ok/config

instead of

homeassistant/sensor/Nexus-TH-1-117-humidity/config
homeassistant/sensor/Nexus-TH-1-117-rssi/config
homeassistant/sensor/Nexus-TH-1-117-temperature_C/config
homeassistant/binary_sensor/Nexus-TH-1-117-battery_ok/config

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 18:46
by Doler
[/quote]

Thanks for your answer. Do you mean that Domoticz would combine if there was only temp and humidity, but as there is also battery and signal strength Domoticz has no combined device and decides not to combine temp + humidity on one side and let battery and signal strength single?

By the way when receiving the same device with my rfxTRX433, the single created device has temp + humidity + Signal strength seen in the setup/devices tab and maybe battery state but not directly visible.
[/quote]

Correct, see the example above from gizmocuz that combines temp, humi and pressure in one device name "Temp_BuitenSensor". Battery and Signal strength cannot be combined in this 'weather class' so Domoticz gets confused (I guess). rfxTRX433 is handled differently from MQTT. And like gizmocuz said: this should be solved by openMQTTGateway.

Re: Autodiscovery with TheengsGateway

Posted: Wednesday 25 June 2025 18:55
by waltervl
I see a unique_id in the config topic payload that is made up like
ID_type_gateway eg "unique_id":"0x00158d0004a98668_humidity_zigbee2mqtt"
and
"unique_id":"0x00158d0004a98668_temperature_zigbee2mqtt"

Yours is ID-type (so no underscore)
"uniq_id":"Ambientweather-F007TH-2-154-temperature_C" and "uniq_id":"Ambientweather-F007TH-2-154-humidity"

I am not sure what exactly the logic is here to have Domoticz combine the topics.

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 9:12
by gizmocuz
Yes it is the Unique ID you have to look at

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 12:15
by waltervl
gizmocuz wrote: Thursday 26 June 2025 9:12 Yes it is the Unique ID you have to look at
But what is the logic behind it? How should that unique ID look like to get Domoticz combine the Temp+HUM sensor?
When I look at these 2 unique ID's, what is wrong with it?
"uniq_id":"Ambientweather-F007TH-2-154-temperature_C"
"uniq_id":"Ambientweather-F007TH-2-154-humidity"

Is it the missing underscore? Is it the _C on the end for the temperature? is it the gateway "RTL_433toMQTT" missing on the end?

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 13:13
by gizmocuz
These are mine unique-id's

0x00158d0004a98668_temperature_zigbee2mqtt
0x00158d0004a98668_humidity_zigbee2mqtt
0x00158d0004a98668_pressure_zigbee2mqtt

There are no unique id's in the above config. That's a first issue... there is no way telling if they belong to each other

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 13:41
by MichelFrance
gizmocuz wrote: Thursday 26 June 2025 13:13 These are mine unique-id's

0x00158d0004a98668_temperature_zigbee2mqtt
0x00158d0004a98668_humidity_zigbee2mqtt
0x00158d0004a98668_pressure_zigbee2mqtt

There are no unique id's in the above config. That's a first issue... there is no way telling if they belong to each other
By "above" you mean your 3 lines or the 2 ""uniq_id":"Ambientweather-F007TH-2-154-...." lines ? In both case, I do not see the difference except yours begin with a number....

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 13:43
by gizmocuz
No, inside the config object payload

Also strange that the stat payload start with +/+/ ... but that's not related

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 14:50
by waltervl
Ambientweather-F007TH-2-154 seems to be the unique ID string like 0x00158d0004a98668 for zigbee2mqtt.

The +/+ issue was already fixed in 2023 with PR https://github.com/domoticz/domoticz/pull/5548

Re: Autodiscovery with TheengsGateway

Posted: Thursday 26 June 2025 16:17
by gizmocuz
Hmmm I see, it is using the short format of all variables....

there is a "uniq_id"

Ambientweather-F007TH-2-154-temperature_C
Ambientweather-F007TH-2-154-humidity

Ahh pfff now I see

The configs are a bit of a mess... If you use short-format, stick to short format! :mrgreen:

"device" should be "dev"

Or use "device", but use "identifiers" instead of "ids"

But in this case, all is using the short format, so stick with short and don't mix

Re: Autodiscovery with TheengsGateway

Posted: Saturday 28 June 2025 12:33
by MichelFrance
OK, I think I understand.

Would it be hard to allow mixed format to allow ["dev" + "identifier"] and ["device" + "ids"] mixed combinations? maybe (MQTTAutoDiscover.cpp at line 669):

Code: Select all

		rootdev = root["device"];
		if (root["device"].empty()) rootdev = root["dev"];

		if (!rootdev.empty())
		{
			rootids = rootdev.["identifiers"];
			if (rootids.empty()) rootids= rootdev.["ids"];
			
			if (!rootids.empty())
			{
				if (rootids.isArray())
					device_identifiers = rootids[0].asString();
				else
					device_identifiers = rootids.asString();
			}
		}
		else
		{
			//It's optional, but good to supply one
		}
instead of:

Code: Select all

		if (!root["device"].empty())
		{
			if (!root["device"]["identifiers"].empty())
			{
				if (root["device"]["identifiers"].isArray())
					device_identifiers = root["device"]["identifiers"][0].asString();
				else
					device_identifiers = root["device"]["identifiers"].asString();
			}
		}
		else if (!root["dev"].empty())
		{
			if (!root["dev"]["ids"].empty())
			{
				if (root["dev"]["ids"].isArray())
					device_identifiers = root["dev"]["ids"][0].asString();
				else
					device_identifiers = root["dev"]["ids"].asString();
			}
		}
		else
		{
			//It's optional, but good to supply one
		}

Re: Autodiscovery with TheengsGateway

Posted: Monday 30 June 2025 14:16
by gizmocuz
No this is not an issue with Domoticz and has to be fixed by the one creating these config objects.
You, on the other hand, can edit/replace your own config object, and consider this a 'fix'
But it has to be fixed upstream.