Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MQTT Discovery: missing state_class for power sensors in Home Assistant
#1
Hello,
I noticed an issue with the MQTT Discovery configuration generated by the N30 when the device is integrated into Home Assistant.
For example, Home Assistant creates the following entity:
Code:
sensor.n30_d0cf13020244_energy2_ch2_power
The N30 publishes this MQTT Discovery payload:
Code:
{
  "uniq_id": "D0CF13020244_sensor_energy2_power_ch2",
  "~": "homeassistant/sensor/D0CF13020244energy2_power_ch2",
  "name": "energy2_ch2.power",
  "device": {
    "name": "N30-D0CF13020244",
    "identifiers": "D0CF13020244",
    "manufacturer": "KinCony",
    "model": "N30"
  },
  "config_topic": "~/config",
  "avty_t": "D0CF13020244/avail",
  "unit_of_meas": "W",
  "dev_cla": "power",
  "val_tpl": "{{ value | float | round(1) }}",
  "stat_t": "~/state"
}
In Home Assistant, the entity is therefore detected with:
Code:
device_class: power
unit_of_measurement: W
but without:
Code:
state_class: measurement
The missing field in the MQTT Discovery payload is:
Code:
"stat_cla": "measurement"
Interestingly, some other N30 power sensors are correctly detected by Home Assistant with:
Code:
state_class: measurement
unit_of_measurement: W
device_class: power
For example,
Code:
sensor.n30_bl0910_1_power_6
already has the correct
Code:
state_class
.
This suggests that the issue is specific to some of the MQTT Discovery configurations generated by the N30 firmware, particularly the
Code:
energy*_ch*_power
sensors.
Could you please check the N30 firmware and add:
Code:
"stat_cla": "measurement"
to the MQTT Discovery configuration of all instantaneous power sensors?
The expected configuration would be:
Code:
"unit_of_meas": "W",
"dev_cla": "power",
"stat_cla": "measurement"
This would allow Home Assistant to correctly identify these entities as power measurements and use them properly for statistics and energy-related features.
Thank you.
Reply
#2
we will check and feedback later.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)