Skip to content

Commit c7f7bad

Browse files
committed
Add time remaining
1 parent 83c8b29 commit c7f7bad

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

custom_components/victron_ble/device.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class VictronSensor(StrEnum):
2727
CHARGER_ERROR = "charger_error"
2828
STARTER_BATTERY_VOLTAGE = "starter_battery_voltage"
2929
MIDPOINT_VOLTAGE = "midpoint_voltage"
30+
TIME_REMAINING = "time_remaining"
3031

3132

3233
class VictronBluetoothDeviceData(BluetoothData):
@@ -91,6 +92,14 @@ def _process_mfr_data(
9192
SensorLibrary.BATTERY__PERCENTAGE, parsed.get_soc()
9293
)
9394

95+
self.update_sensor(
96+
key=VictronSensor.TIME_REMAINING,
97+
name="Time remaining",
98+
native_unit_of_measurement=Units.TIME_MINUTES,
99+
native_value=parsed.get_remaining_mins(),
100+
device_class=SensorDeviceClass.DURATION,
101+
)
102+
94103
aux_mode = parsed.get_aux_mode()
95104
self.update_sensor(
96105
key=VictronSensor.AUX_MODE,

custom_components/victron_ble/sensor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@
9191
options=[x.lower() for x in ChargerError._member_names_],
9292
),
9393
(VictronSensor.EXTERNAL_DEVICE_LOAD, None): SensorEntityDescription(
94-
key=f"{SensorDeviceClass.CURRENT}_{Units.ELECTRIC_CURRENT_AMPERE}",
94+
key=VictronSensor.EXTERNAL_DEVICE_LOAD,
9595
device_class=SensorDeviceClass.CURRENT,
9696
native_unit_of_measurement=Units.ELECTRIC_CURRENT_AMPERE,
9797
state_class=SensorStateClass.MEASUREMENT,
9898
),
99+
(VictronSensor.TIME_REMAINING, Units.TIME_MINUTES): SensorEntityDescription(
100+
key=VictronSensor.TIME_REMAINING,
101+
device_class=SensorDeviceClass.DURATION,
102+
native_unit_of_measurement=Units.TIME_MINUTES,
103+
state_class=SensorStateClass.MEASUREMENT,
104+
),
99105
(
100106
VictronSensor.INPUT_VOLTAGE,
101107
Units.ELECTRIC_POTENTIAL_VOLT,

0 commit comments

Comments
 (0)