emsesp / EMS-ESP32

ESP32 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
https://emsesp.github.io/docs
GNU Lesser General Public License v3.0
566 stars 101 forks source link

MQTT discovery of custom entity doesn't consider type of data #1587

Closed SSSlee closed 6 months ago

SSSlee commented 7 months ago

The datatype of a customized entity isn't mentioned in the belonging MQTT Discovery:

image

Corresponding MQTT discovery:

{ "stat_t": "ems-esp/custom_data", "val_tpl": "{{value_json['RFM200'] if value_json['RFM200'] is defined}}", "obj_id": "custom_RFM200", "uniq_id": "custom_RFM200", "name": "RFM200", "dev": { "name": "ems-esp Custom", "mf": "EMS-ESP", "mdl": "Custom", "via_device": "ems-esp", "ids": [ "ems-esp-custom" ] } "avty": [ { "t": "ems-esp/status", "val_tpl": "{{'online' if value == 'online' else 'offline'}}" }, { "t": "ems-esp/custom_data", "val_tpl": "{{'online' if value_json['RFM200'] is defined else 'offline'}}" } ], "avty_mode": "all" }`

Discovery for a temperature datatype (in comparsion):

{ "uniq_id": "thermostat_dampedoutdoortemp", "obj_id": "thermostat_dampedoutdoortemp", "stat_t": "ems-esp/thermostat_data", "name": "Damped outdoor temperature", "unit_of_meas": "°C", "val_tpl": "{{value_json.dampedoutdoortemp if value_json.dampedoutdoortemp is defined else 0}}", "stat_cla": "measurement", "dev_cla": "temperature", "dev": { "ids": [ "ems-esp-thermostat" ], "name": "ems-esp Thermostat" }, "avty": [ { "t": "ems-esp/status", "val_tpl": "{{'online' if value == 'online' else 'offline'}}" }, { "t": "ems-esp/thermostat_data", "val_tpl": "{{'online' if value_json.dampedoutdoortemp is defined else 'offline'}}" } ], "avty_mode": "all" }

proddy commented 7 months ago

looks like we need to add both "unit_of_meas" and the "stat_cla"

proddy commented 7 months ago

@SSSlee if you add those two manually to the discovery topic (using MQTT Explorer) does it fix your issue? Worth trying before I change the EMS-ESP code and unintentionally break something else.

proddy commented 7 months ago

fixed in dev13

mattblonski commented 4 months ago

Hi, Noticed in v. 3.6.5 MQTT discovery of external temperature sensor for HA is missing "stat_cla" attribute. So this entity is not recored, nor cannot be added to any statistics card. image I added the attribute manually via MQTT Explorer and HA starts recording it. image

proddy commented 4 months ago

thanks, created new bug for this