Skip to content

Commit 7fb65d9

Browse files
committed
Add consumed Ah and alarm sensors for completeness.
Bump victron-ble to 0.8.0
1 parent bc76333 commit 7fb65d9

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ __pycache__
44
*.egg-info
55
*/build/*
66
*/dist/*
7+
.venv
78

89

910
# misc

custom_components/victron_ble/device.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class VictronSensor(StrEnum):
4141
AC_INPUT_STATE = "ac_input_state"
4242
AC_INPUT_POWER = "ac_input_power"
4343
AC_OUTPUT_POWER = "ac_output_power"
44+
ALARM_REASON = "alarm_reason"
45+
ALARM_NOTIFICATION = "alarm_notification"
46+
CONSUMED = "consumed"
4447

4548

4649
class VictronBluetoothDeviceData(BluetoothData):
@@ -113,6 +116,21 @@ def _process_mfr_data(
113116
device_class=SensorDeviceClass.DURATION,
114117
)
115118

119+
self.update_sensor(
120+
key=VictronSensor.CONSUMED,
121+
name="Consumed",
122+
native_unit_of_measurement="Ah",
123+
native_value=parsed.get_consumed_ah(),
124+
)
125+
126+
self.update_sensor(
127+
key=VictronSensor.ALARM_REASON,
128+
name="Alarm",
129+
native_unit_of_measurement=None,
130+
native_value=enum_to_native_value(parsed.get_alarm()),
131+
device_class=SensorDeviceClass.ENUM,
132+
)
133+
116134
aux_mode = parsed.get_aux_mode()
117135
self.update_sensor(
118136
key=VictronSensor.AUX_MODE,
@@ -289,5 +307,12 @@ def _process_mfr_data(
289307
native_value=parsed.get_ac_out_power(),
290308
device_class=SensorDeviceClass.POWER,
291309
)
310+
self.update_sensor(
311+
key=VictronSensor.ALARM_NOTIFICATION,
312+
name="Alarm",
313+
native_unit_of_measurement=None,
314+
native_value=enum_to_native_value(parsed.get_alarm()),
315+
device_class=SensorDeviceClass.ENUM,
316+
)
292317

293318
return

custom_components/victron_ble/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"integration_type": "device",
1515
"iot_class": "local_push",
1616
"issue_tracker": "https://github.com/keshavdv/victron-hacs/issues",
17-
"requirements": ["git+https://github.com/j9brown/victron-ble.git@main#victron_ble==0.7.5"],
18-
"version": "0.1.8"
17+
"requirements": ["git+https://github.com/j9brown/victron-ble.git@main#victron_ble==0.8.0"],
18+
"version": "0.1.9"
1919
}

custom_components/victron_ble/sensor.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from homeassistant.helpers.sensor import sensor_device_info_to_hass_device_info
2525
from sensor_state_data.data import SensorUpdate
2626
from sensor_state_data.units import Units
27-
from victron_ble.devices.base import ACInState, ChargerError, OffReason, OperationMode
27+
from victron_ble.devices.base import ACInState, AlarmNotification, AlarmReason, ChargerError, OffReason, OperationMode
2828
from victron_ble.devices.battery_monitor import AuxMode
2929

3030
from .const import DOMAIN
@@ -90,6 +90,16 @@
9090
device_class=SensorDeviceClass.ENUM,
9191
options=[x.lower() for x in ChargerError._member_names_],
9292
),
93+
(VictronSensor.ALARM_REASON, None): SensorEntityDescription(
94+
key=VictronSensor.ALARM_REASON,
95+
device_class=SensorDeviceClass.ENUM,
96+
options=[x.lower() for x in AlarmReason._member_names_],
97+
),
98+
(VictronSensor.ALARM_NOTIFICATION, None): SensorEntityDescription(
99+
key=VictronSensor.ALARM_NOTIFICATION,
100+
device_class=SensorDeviceClass.ENUM,
101+
options=[x.lower() for x in AlarmNotification._member_names_],
102+
),
93103
(VictronSensor.EXTERNAL_DEVICE_LOAD, Units.ELECTRIC_CURRENT_AMPERE): SensorEntityDescription(
94104
key=VictronSensor.EXTERNAL_DEVICE_LOAD,
95105
device_class=SensorDeviceClass.CURRENT,
@@ -102,6 +112,11 @@
102112
native_unit_of_measurement=Units.TIME_MINUTES,
103113
state_class=SensorStateClass.MEASUREMENT,
104114
),
115+
(VictronSensor.CONSUMED, "Ah"): SensorEntityDescription(
116+
key=VictronSensor.CONSUMED,
117+
native_unit_of_measurement="Ah",
118+
state_class=SensorStateClass.MEASUREMENT,
119+
),
105120
(
106121
VictronSensor.INPUT_VOLTAGE,
107122
Units.ELECTRIC_POTENTIAL_VOLT,

0 commit comments

Comments
 (0)