Why would this ems-esp device not be created with MQTT Auto Discovery?

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

Moderator: leecollings

User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Hi Forum,
I'm trying to understand better why a certain device is not created via MQTT Auto Discovery. I'm using the ems-esp gateway (firmware 3.6.5) and after setting it up, several devices are created and working as expected in Domoticz (2024.7). I'm using the Mosquitto broker and both run on a RPI4. Some ems-esp devices are however not created. Here is an example of such device:

The MQTT Auto Discovery config message:

Code: Select all

domoticz/number/ems-esp2/boiler_selflowtemp/config 

{
  "uniq_id" : "boiler_selected_flow_temperature",
  "obj_id" : "boiler_selected_flow_temperature",
  "cmd_t" : "ems-esp2/boiler/selflowtemp",
  "mode" : "box",
  "step" : 1,
  "min" : 0,
  "max" : 90,
  "ic" : "mdi:coolant-temperature",
  "name" : "Selected flow temperature",
  "stat_t" : "ems-esp2/boiler_data",
  "val_tpl" : "{{value_json.selflowtemp if value_json.selflowtemp is defined else 0}}",
  "avty" : [ ],
  "dev" : {
    "ids" : [ "ems-esp2-boiler" ],
    "name" : "ems-esp2 Boiler"
  }
}
The MQTT topic "ems-esp2/boiler_data" contains a message which regularly provides updates on the value "selflowtemp":

Code: Select all

ems-esp2/boiler_data 

{
  "heatingoff" : "off",
  "heatingactive" : "off",
  "tapwateractive" : "off",
  "selflowtemp" : 5,
  "heatingpumpmod" : 0,
  "curflowtemp" : 40.9,
  "rettemp" : 24.3,
  "switchtemp" : 22.4,
  "syspress" : 1.3,
  "burngas" : "off",
  "burngas2" : "off",
  "flamecurr" : 0.0,
  "fanwork" : "off",
  "ignwork" : "off",
  "oilpreheat" : "off",
  "burnminpower" : 0,
  "burnmaxpower" : 100,
  "burnminperiod" : 10,
  "boilhyston" : -6,
  "boilhystoff" : 6,
  "boil2hyston" : 0,
  "boil2hystoff" : 0,
  "curveon" : "off",
  "curvebase" : 20,
  "curveend" : 90,
  "summertemp" : 16,
  "nofrostmode" : "off",
  "nofrosttemp" : 5,
  "heatingactivated" : "on",
  "heatingtemp" : 55,
  "heatingpump" : "off",
  "pumpmodmax" : 71,
  "pumpmodmin" : 40,
  "pumpmode" : "proportional",
  "pumpdelay" : 5,
  "setflowtemp" : 0,
  "setburnpow" : 0,
  "selburnpow" : 0,
  "curburnpow" : 0,
  "burnstarts" : 23106,
  "burnworkmin" : 432470,
  "burn2workmin" : 0,
  "heatworkmin" : 403045,
  "heatstarts" : 18122,
  "ubauptime" : 2164753,
  "lastcode" : "2E(207) 176.32.2000 137:00 (0 min)",
  "servicecode" : "0H",
  "servicecodenumber" : 203,
  "maintenancemessage" : "H00",
  "maintenance" : "off",
  "maintenancetime" : 6000,
  "maintenancedate" : "01.01.2015",
  "nompower" : 30,
  "nrgtotal" : 11.66,
  "nrgheat" : 4.94
}
Could it be related to the fact that in this example MQTT AD wants to create a 'number' device in Domoticz?
Final words: do not exclude the possibility I made a mistake ;) !
Thanks in advance,
Last edited by Domoberry on Friday 18 October 2024 9:07, edited 1 time in total.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by waltervl »

Code: Select all

"val_tpl" : "{{value_json.selflowtemp if value_json.selflowtemp is defined else 0}}",
As far as I know this "if then else" is not supported by Domoticz MQTT AD config value templates. Just simple value templates. Search the github issues for examples, I am not a programmer.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
gizmocuz
Posts: 2394
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by gizmocuz »

this should work

"val_tpl" : "{{ value_json.selflowtemp }}"
Quality outlives Quantity!
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Thanks for the reply!
Yet, in same setup, there is another device "boiler_curflowtemp” which does have a corresponding device created by MQTT AD whereas the "boiler_selflowtemp" config message did not result in a device created in Dz.
Also, "boiler_curflowtemp” in Dz is updated based on MQTT data and also uses the mentioned "if then else" in JSON.
Here is the config message of the MQTT AD created (and working) Dz device:

Code: Select all

domoticz/sensor/ems-esp2/boiler_curflowtemp/config
{
  "uniq_id" : "boiler_current_flow_temperature",
  "obj_id" : "boiler_current_flow_temperature",
  "name" : "Current flow temperature",
  "stat_t" : "ems-esp2/boiler_data",
  "val_tpl" : "{{value_json.curflowtemp if value_json.curflowtemp is defined else 0}}",
  "avty" : [ ],
  "unit_of_meas" : "°C",
  "stat_cla" : "measurement",
  "dev_cla" : "temperature",
  "dev" : {
    "ids" : [ "ems-esp2-boiler" ],
    "name" : "ems-esp2 Boiler"
  }
}
A key difference I noted between the two MQTT AD config messages is the topic:
domoticz/number/ems-esp2/boiler_selflowtemp/config (<= no device created)
versus
domoticz/sensor/ems-esp2/boiler_curflowtemp/config (<= device created and working)

I took a look at the wiki https://www.domoticz.com/wiki/MQTT#Add_ ... Gateway.22 and noted that the second parameters in the MQTT AD config topic refers to the device type to be created, e.g. in the failing case 'number', in the working case 'sensor'. The wiki mentions both as supported, yet with 'number' it states: "Numbers (through hardware mqtt Autodiscover setup)". I do not understand what that addition refers to. Should something additionally be done to create a 'number' device'?

In any case, I will manually try sending the config message with the 'if then else' removed (and a slightly different ID) to see if that does create a Dz device.
Last edited by Domoberry on Friday 18 October 2024 9:07, edited 1 time in total.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by waltervl »

If it is a number device it will be shown in the MQTT AD Setup list https://www.domoticz.com/wiki/MQTT#MQTT ... very_Setup
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Thanks Walter, found the same.
In fact, the (number) device I miss is shown in that list, as well as several more which are also not available as 'normal' Dz devices.
Can these 'number devices' also be made available as a 'normal' Dz devices? Or, would you know how I can use these devices within Dz?
Last edited by Domoberry on Friday 18 October 2024 9:08, edited 1 time in total.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by waltervl »

No as they should not be number devices.
Perhaps you can influence the MQTT AD config topic the ESP is sending.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by Domoberry »

Changing the ems-esp code is 'a bit' (few hundred miles...) out of my comfort zone :(
Yet, it seems like a logical approach to change the MQTT AD config message such that - for example - a 'sensor' device is created.
With the help of AI (let's hope no hallucination) I understand that Home Assistent does interpret the 'number' device and integrates it in the HA UI (see https://www.home-assistant.io/integrations/number.mqtt/). So, based on my current understanding, my best bet would be the Domoticz MQTT AD team including this as well in a next update.
Thanks again for your feedback.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this device not be created with MQTT Auto Discovery?

Post by waltervl »

You could also modify the config topic and resend it with MQTT explorer. When you send it as retained the MQTT broker/server will remember it when Domoticz restarts.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Thanks! I did as you suggested and 'published' a config message using my MQTT tool to a new topic. With the config message I informed the MQTT AD sytem about creating a 'sensor' device with the parameter I wanted. This resulted in the wanted temperature device in Domoticz.
I have also learned that the original implementation, which asks for 'number' devices in the config message, this specifically done for writable parameters. Using the 'sensor' type I obviously do not have the ability to send a new value, I can only 'read' the value. This is fine for now. I have added the topic and payload used below for reference.
Last question: would it make sense to request to "Dz MQTT AD team" to consider full support for 'number' devices (the EMS-ESP gateway uses about 33 of them...) or is such likely on the roadmap anyhow?

MQTT message used:

Code: Select all

domoticz/sensor/ems-esp2/boiler_ro_selflowtemp/config

{
  "uniq_id" : "boiler_ro_sel_flow_temperature",
  "obj_id" : "boiler_ro_sel_flow_temperature",
  "name" : "RO Selected flow temperature",
  "stat_t" : "ems-esp2/boiler_data",
  "val_tpl" : "{{value_json.selflowtemp if value_json.selflowtemp is defined else 0}}",
  "avty" : [ ],
  "unit_of_meas" : "C",
  "stat_cla" : "measurement",
  "dev_cla" : "temperature",
  "dev" : {
    "ids" : [ "ems-esp2-boiler" ],
    "name" : "ems-esp2 Boiler"
  }
}
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by waltervl »

The Number devices should only be used for 1 time configuration settings in HA AutoDiscover environments. So it seems the EMS-ESP is doing something wrong it seems. But again, I am not an expert on this matter.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Update on above as per my understanding.
The workaround of manually sending a mqtt-ad config message for a 'sensor' device instead of a 'number' device does the trick. Thanks again for the tip!
I have also posted a related question with the team developing the EMS-ESP software (https://github.com/emsesp/EMS-ESP32/dis ... t-11054102), which connects a growing number of Bosch and equivalent boilers and heat pumps to mqtt using HA's mqtt-ad. See https://github.com/emsesp/EMS-ESP32 for the gateway software and for a gateway solution https://bbqkees-electronics.nl/.
I understood the Bosch (heat pump) stuff I'm using is relatively new and better supporting ems-esp gateway software is under development. I tested the latest dev version and noted less mqtt-ad compatibility.
In my humble opinion as an average Dz user, it would be interesting if experts could look how to best plan mqtt-ad compatibility. Obviously my interest is to see continued improvement in Domoticz Bosch heat pumps etc. integration :-)
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

@waltervl There are active Github discussions on the EMS-ESP gateway for the Bosch/Nefit boilers, heatpumps, etc. interfacing to Domoticz. One of the questions circulating is on how Domoticz has implemented certain elements of HA's mqtt discovery. More specfically on which UOM's (unit of measure) are supported for which mqtt-ad device types (numbers, sensors, etc.). Would you know where this information could be found?
Update: please ignore question above, I understood the answer can be found in the code, see this post: https://github.com/emsesp/EMS-ESP32/issues/2177. Apologies for any confusion I might have caused.
Last edited by Domoberry on Tuesday 05 November 2024 9:33, edited 1 time in total.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by waltervl »

That is not documented as such. You probably will find the supported UOM in the source code of MQTT Autodiscover: https://github.com/domoticz/domoticz/bl ... scover.cpp

edit: tip: search for "szunit" in that file.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

That seems an even better resource, thanks!
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

@waltervl, picked up a question from the EMS-ESP team, hope you can provide a suggestion. It is still about the firmware update for the EMS Gateway, on the mqtt-ad <> Domoticz part: "I'm not sure how to handle the uom for sensors without a uom (like a number). It's not clear from the Domoticz c++ code how they handle this".
An example of such a device is the Service-Code the system report, or things like Number-of-Starts, etc.
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by waltervl »

I am sorry, that is out of my knowledge range.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by waltervl »

I got a tip that it should be a sensor with unit text. That would create a text device.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by Domoberry »

Thanks for the quick reply Waltervl! I'll forward the tip!
To anyone reading this post: Who would be the best person to ask? I would like to help the EMS team create a better Bosch/Nefit gateway for Domoticz :)
brugje
Posts: 8
Joined: Monday 13 February 2023 19:36
Target OS: Windows
Domoticz version: 2024.4
Location: NL (Echtenerbrug)
Contact:

Re: Why would this ems-esp device not be created with MQTT Auto Discovery?

Post by brugje »

Can this device been discovered by domoticz mqtt as a (thermostat) setpoint device? What is needed to read and set the temperature on ems-esp. I'm not a programmer. I hope domoticz and ems-esp come to a solution.
praet mar frysk
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests