BMS: Fix sensor device_class and state_class (#331)

Several sensors had a device_class that did not match their unit, so
Home Assistant shows warnings and handles them wrongly (unit
conversion, statistics).

- Power sensors in W used device_class 'current'; now 'power'
  (BASEN RS485, DEYE CAN module full/minimal, FAKE).
- Ah sensors had a device_class that does not accept Ah ('battery',
  'energy', 'energy_storage'). Removed it, since Home Assistant has no
  device_class for Ah (BASEN RS485, DEYE CAN module/top full/minimal,
  JK RS485 Display, Modbus client).
- DEYE battery capacity used state_class 'total_increasing', but the
  value is not a counter. Changed to 'measurement'.
This commit is contained in:
Sebastian authored and Sleeper85 committed 2026-11-08 23:08:33 +01:00
1 parent 0fb9cc8116
commit 4a23cb6b47
8 files changed
+30 -41

No files matched your search

@@ -1,5 +1,5 @@
# Updated : 2026.08.29
# Version : 1.2.2
# Updated : 2026.10.18
# Version : 1.2.3
# GitHub : https://github.com/syssi/esphome-jk-bms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -297,7 +297,6 @@ sensor:
update_interval: ${bms_update_interval}
accuracy_decimals: 0
unit_of_measurement: Ah
device_class: energy_storage
filters:
- or:
- throttle: 10s
@@ -312,7 +311,6 @@ sensor:
update_interval: ${bms_update_interval}
accuracy_decimals: 0
unit_of_measurement: Ah
device_class: energy_storage
filters:
- or:
- throttle: 10s
+2 -4
View File
@@ -1,5 +1,5 @@
# Updated : 2026.08.14
# Version : 1.3.2
# Updated : 2026.10.18
# Version : 1.3.3
# GitHub : https://github.com/Sleeper85/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -226,7 +226,6 @@ sensor:
value_type: U_WORD
accuracy_decimals: 0
unit_of_measurement: Ah
device_class: energy_storage
filters:
- lambda: if (!id(bms${bms_id}_online_status).state) return 0; else return x;
- multiply: 1
@@ -248,7 +247,6 @@ sensor:
value_type: U_WORD
accuracy_decimals: 0
unit_of_measurement: Ah
device_class: energy_storage
filters:
- lambda: if (!id(bms${bms_id}_online_status).state) return 0; else return x;
- multiply: 1
@@ -1,5 +1,5 @@
# Updated : 2026.03.15
# Version : 1.2.5
# Updated : 2026.10.18
# Version : 1.2.7
# GitHub : https://github.com/GHswitt/esphome-basen
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -596,7 +596,7 @@ sensor:
id: bms${bms_id}_charging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -609,7 +609,7 @@ sensor:
id: bms${bms_id}_discharging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -619,7 +619,6 @@ sensor:
# Remaining capacity: Calculated from capacity and SoC
- platform: template
unit_of_measurement: 'Ah'
device_class: 'battery'
state_class: 'measurement'
accuracy_decimals: 0
id: bms${bms_id}_capacity_remaining_ah
@@ -1,5 +1,5 @@
# Updated : 2026.02.21
# Version : 1.2.2
# Updated : 2026.10.18
# Version : 1.2.3
# GitHub : https://github.com/GHswitt/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -336,7 +336,7 @@ sensor:
device_id: bms_${bms_id}
name: "battery power"
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -352,7 +352,7 @@ sensor:
id: bms${bms_id}_charging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -369,7 +369,7 @@ sensor:
id: bms${bms_id}_discharging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -399,8 +399,7 @@ sensor:
id: bms${bms_id}_battery_capacity
device_id: bms_${bms_id}
unit_of_measurement: 'Ah'
device_class: 'energy'
state_class: 'total_increasing'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
uint8_t module_count = id(deye${deye_id}_module_amount).state;
@@ -415,7 +414,6 @@ sensor:
id: bms${bms_id}_capacity_remaining_ah
device_id: bms_${bms_id}
unit_of_measurement: 'Ah'
device_class: 'battery'
state_class: 'measurement'
accuracy_decimals: 0
filters:
@@ -1,5 +1,5 @@
# Updated : 2026.02.21
# Version : 1.2.2
# Updated : 2026.10.18
# Version : 1.2.3
# GitHub : https://github.com/GHswitt/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -193,7 +193,7 @@ sensor:
device_id: bms_${bms_id}
name: "battery power"
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -209,7 +209,7 @@ sensor:
id: bms${bms_id}_charging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -226,7 +226,7 @@ sensor:
id: bms${bms_id}_discharging_power
device_id: bms_${bms_id}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -256,8 +256,7 @@ sensor:
id: bms${bms_id}_battery_capacity
device_id: bms_${bms_id}
unit_of_measurement: 'Ah'
device_class: 'energy'
state_class: 'total_increasing'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
uint8_t module_count = id(deye${deye_id}_module_amount).state;
@@ -272,7 +271,6 @@ sensor:
id: bms${bms_id}_capacity_remaining_ah
device_id: bms_${bms_id}
unit_of_measurement: 'Ah'
device_class: 'battery'
state_class: 'measurement'
accuracy_decimals: 0
filters:
@@ -1,5 +1,5 @@
# Updated : 2026.02.21
# Version : 1.1.6
# Updated : 2026.10.18
# Version : 1.1.7
# GitHub : https://github.com/GHswitt/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -642,8 +642,7 @@ sensor:
id: deye${deye_id}_battery_capacity
device_id: deye_${deye_id}
unit_of_measurement: 'Ah'
device_class: 'energy'
state_class: 'total_increasing'
state_class: 'measurement'
accuracy_decimals: 0
filters:
- throttle: ${bms_update_interval}
@@ -1,5 +1,5 @@
# Updated : 2026.02.23
# Version : 1.1.6
# Updated : 2026.10.18
# Version : 1.1.7
# GitHub : https://github.com/GHswitt/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -221,8 +221,7 @@ sensor:
id: deye${deye_id}_battery_capacity
device_id: deye_${deye_id}
unit_of_measurement: 'Ah'
device_class: 'energy'
state_class: 'total_increasing'
state_class: 'measurement'
accuracy_decimals: 0
filters:
- throttle: ${bms_update_interval}
+4 -4
View File
@@ -1,5 +1,5 @@
# Updated : 2026.08.28
# Version : 1.3.1
# Updated : 2026.10.18
# Version : 1.3.2
# GitHub : https://github.com/Sleeper85/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -429,7 +429,7 @@ sensor:
name: "battery power charging"
update_interval: ${bms_update_interval}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-
@@ -443,7 +443,7 @@ sensor:
name: "battery power discharging"
update_interval: ${bms_update_interval}
unit_of_measurement: 'W'
device_class: 'current'
device_class: 'power'
state_class: 'measurement'
accuracy_decimals: 0
lambda: |-