mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-11 14:18:50 +00:00
fix: Home Assistant: add missing device_class for some current and power entities (#26324)
This commit is contained in:
@@ -1019,6 +1019,14 @@ export default class HomeAssistant extends Extension {
|
||||
if (firstExpose.unit && ['Wh', 'kWh'].includes(firstExpose.unit)) {
|
||||
Object.assign(extraAttrs, {device_class: 'energy', state_class: 'total_increasing'});
|
||||
}
|
||||
// If a variable includes A or mA, mark it as current
|
||||
else if (firstExpose.unit && ['A', 'mA'].includes(firstExpose.unit)) {
|
||||
Object.assign(extraAttrs, {device_class: 'current', state_class: 'measurement'});
|
||||
}
|
||||
// If a variable includes mW, W, kW mark it as power
|
||||
else if (firstExpose.unit && ['mW', 'W', 'kW'].includes(firstExpose.unit)) {
|
||||
Object.assign(extraAttrs, {device_class: 'power', state_class: 'measurement'});
|
||||
}
|
||||
|
||||
let key = firstExpose.name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user