Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device_class not propagated as expected to MQTT #1218

Closed
pvyleta opened this issue Mar 5, 2024 · 2 comments
Closed

device_class not propagated as expected to MQTT #1218

pvyleta opened this issue Mar 5, 2024 · 2 comments

Comments

@pvyleta
Copy link
Sponsor

pvyleta commented Mar 5, 2024

Description

I hope this is not a rookie mistake, but I am lost after several hours of trying.

I want to properly show the values of my Heat Recovery Unit in HomeAssistant with the right category of data, e.g. for carbon dioxide, I want them to be shown as such. For this I made change in mqtt-hassio.cfg in type_switch-number

type_switch-number =
    sensor,,total_increasing = poweron|count,
    sensor,temperature,measurement = temp|,°C$
    sensor,temperature,measurement = temp|,K$
    sensor,power_factor,measurement = power*%%
    sensor,power,measurement = power|,kW$|,W$
    sensor,voltage,measurement = volt|,V$
    sensor,current,measurement = current,|,A$
    sensor,,measurement = integral|,°min$
    sensor,energy,total_increasing = energy|,Wh$
    sensor,yield,total_increasing = total*,Wh$
    sensor,duration,total_increasing = hours|days|,h$
    sensor,,total_increasing = starts*,$
    sensor,pressure,measurement = bar$|Pa$
    sensor,gas,measurement = gas*/min$
    sensor,gas,total_increasing = air*total*,m³$
    sensor,volume,total_increasing = total*,m³$
    sensor,volume,measurement = m³$
    sensor,volume_flow_rate,measurement = m³/h$
    sensor,carbon_dioxide,measurement = *co2*,ppm$
    sensor,humidity,measurement = humid*%%$
    sensor,, =

This does work for pressure, duration and volume, however, my added definition for gas (air*total*,m³$), volume_flow_rate (m³/h$) and carbon_dioxide (*co2*,ppm$) is failing to be picked up, as can be seen from the default icons here:

image

but mainly from the logs:

2024-03-05 23:10:08.337 [mqtt debug] publish homeassistant/sensor/ebusd_test_device_AirflowTotal_0/config {
  "unique_id":"ebusd_test_device_AirflowTotal_0",
  "name":"AirflowTotal ",
  "device":{
   "identifiers":"ebusd_test_device",
   "manufacturer":"ebusd.eu",
   "name":"ebusd test_device",
   "via_device":"ebusd",
   "sw_version":"23.2",
   "suggested_area":"Heating"
  },
  "value_template":"{{value_json[\"0\"].value}}",
  "state_topic":"ebusd/test_device/AirflowTotal",
  "unit_of_measurement":"m³",
  "state_class":"total_increasing",
  "device_class":"volume"
 }
2024-03-05 23:10:08.342 [mqtt debug] publish homeassistant/sensor/ebusd_test_device_IntakeAirPressure_0/config {
  "unique_id":"ebusd_test_device_IntakeAirPressure_0",
  "name":"IntakeAirPressure ",
  "device":{
   "identifiers":"ebusd_test_device",
   "manufacturer":"ebusd.eu",
   "name":"ebusd test_device",
   "via_device":"ebusd",
   "sw_version":"23.2",
   "suggested_area":"Heating"
  },
  "value_template":"{{value_json[\"0\"].value}}",
  "state_topic":"ebusd/test_device/IntakeAirPressure",
  "unit_of_measurement":"Pa",
  "state_class":"measurement",
  "device_class":"pressure"
 }
2024-03-05 23:10:08.344 [mqtt debug] publish homeassistant/sensor/ebusd_test_device_OperatingHoursTotal_0/config {
  "unique_id":"ebusd_test_device_OperatingHoursTotal_0",
  "name":"OperatingHoursTotal ",
  "device":{
   "identifiers":"ebusd_test_device",
   "manufacturer":"ebusd.eu",
   "name":"ebusd test_device",
   "via_device":"ebusd",
   "sw_version":"23.2",
   "suggested_area":"Heating"
  },
  "value_template":"{{value_json[\"0\"].value}}",
  "state_topic":"ebusd/test_device/OperatingHoursTotal",
  "state_class":"total_increasing",
  "device_class":"duration"
 }
2024-03-05 23:10:24.451 [mqtt debug] publish homeassistant/sensor/ebusd_test_device_AirflowWithFilter_0/config {
  "unique_id":"ebusd_test_device_AirflowWithFilter_0",
  "name":"AirflowWithFilter ",
  "device":{
   "identifiers":"ebusd_test_device",
   "manufacturer":"ebusd.eu",
   "name":"ebusd test_device",
   "via_device":"ebusd",
   "sw_version":"23.2",
   "suggested_area":"Heating"
  },
  "value_template":"{{value_json[\"0\"].value}}",
  "state_topic":"ebusd/test_device/AirflowWithFilter",
  "unit_of_measurement":"m³",
  "state_class":"measurement",
  "device_class":"volume"
 }
2024-03-05 23:10:24.456 [mqtt debug] publish homeassistant/sensor/ebusd_test_device_CO2Sensor1LowerLimit_0/config {
  "unique_id":"ebusd_test_device_CO2Sensor1LowerLimit_0",
  "name":"CO2Sensor1LowerLimit ",
  "device":{
   "identifiers":"ebusd_test_device",
   "manufacturer":"ebusd.eu",
   "name":"ebusd test_device",
   "via_device":"ebusd",
   "sw_version":"23.2",
   "suggested_area":"Heating"
  },
  "value_template":"{{value_json[\"0\"].value}}",
  "state_topic":"ebusd/test_device/CO2Sensor1LowerLimit",
  "unit_of_measurement":"ppm"
 }

The corresponding .csv file looks like this:

# type (r[1-9];w;u),circuit,name,[comment],[QQ],ZZ,PBSB,[ID],field1,part (m/s),datatypes/templates,divider/values,unit,comment,field2,part (m/s),datatypes/templates ,divider/values,unit,comment,field3,part (m/s),datatypes/templates,divider/values,unit,comment,field4,part (m/s),datatypes/templates,divider/values,unit,comment,field5,part (m/s),datatypes/templates,divider/values,unit,comment
*r,test_device,,,,3c,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
r1,,DaysWithFilter,,,,4050,22,,,UIR,,, 
r1,,IntakeAirPressure,,,,4022,14,,,UIR,10,Pa,
r1,,OperatingHoursTotal,,,,4050,24,,,SIR,,,
r1,,AirflowTotal,,,,4050,25,,,SIR,-1000,m³,
r1,,AirflowWithFilter,,,,4050,23,,,UIR,-1000,m³,
r1,,CO2Sensor1LowerLimit,,,,4050,34,,,UIR,,ppm,
r1,,AirFlowLevel0,,,,4050,21,,,SIR,,m³/h,

Actual behavior

"device_class": is missing from the published value type

Expected behavior

"device_class": is present based on the pattern provided in type_switch-number

ebusd version

23.2

ebusd arguments

ebusd --foreground --mqtthost=core-mosquitto --mqttport=1883 --mqttuser=addons --mqttpass=Rae9ooYeekaigi9OoPhoodahCheel7aequaidiis1oocee8iw5ieG3maingietho --scanconfig --mqttjson --mqttlog --configpath=/config/ebusd-configuration/latest/en --mqttint=/config/ebusd/contrib/etc/ebusd/mqtt-hassio.cfg --mqtttopic=ebusd --device=ens:192.168.100.60:9999 --log=all:debug --log=bus:notice

Operating system

other (HomeAssistant OS)

CPU architecture

arm64 (RPi4)

Dockerized

other (Using the HA Addon)

Hardware interface

Adapter Shield v5 via WiFi

Related integration

MQTT Home Assistant via mqtt-hassio.cfg

Logs

See description

@pvyleta
Copy link
Sponsor Author

pvyleta commented Mar 28, 2024

So far, I identified that *co2*,ppm$ does not work as expected for me, but co2*,ppm$ does - the star sympol will apparently not match the beginning of string which is quite different to other regex implementations. Woudl it be possible to unigy the behavior?

For the others, I made no progress whatsoever in decoding the issue.

@john30
Copy link
Owner

john30 commented Mar 29, 2024

from the docs here and here:
"*" matches a single arbitrary length wildcard part in the middle
as such it is not supposed to be more than once per entry, i.e. "ab" is similar to regexp "a.b", but "abc" does not work.

@john30 john30 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2024
john30 added a commit that referenced this issue Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants