Skip to content

Commit 1e656c2

Browse files
authored
fix: Home Assistant: add missing device_class for some current and power entities (#26324)
1 parent ba76533 commit 1e656c2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/extension/homeassistant.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,14 @@ export default class HomeAssistant extends Extension {
10191019
if (firstExpose.unit && ['Wh', 'kWh'].includes(firstExpose.unit)) {
10201020
Object.assign(extraAttrs, {device_class: 'energy', state_class: 'total_increasing'});
10211021
}
1022+
// If a variable includes A or mA, mark it as current
1023+
else if (firstExpose.unit && ['A', 'mA'].includes(firstExpose.unit)) {
1024+
Object.assign(extraAttrs, {device_class: 'current', state_class: 'measurement'});
1025+
}
1026+
// If a variable includes mW, W, kW mark it as power
1027+
else if (firstExpose.unit && ['mW', 'W', 'kW'].includes(firstExpose.unit)) {
1028+
Object.assign(extraAttrs, {device_class: 'power', state_class: 'measurement'});
1029+
}
10221030

10231031
let key = firstExpose.name;
10241032

0 commit comments

Comments
 (0)