13
13
from victron_ble .devices .dcdc_converter import DcDcConverterData
14
14
from victron_ble .devices .inverter import InverterData
15
15
from victron_ble .devices .solar_charger import SolarChargerData
16
+ from victron_ble .devices .vebus import VEBusData
16
17
17
18
_LOGGER = logging .getLogger (__name__ )
18
19
@@ -30,9 +31,14 @@ class VictronSensor(StrEnum):
30
31
MIDPOINT_VOLTAGE = "midpoint_voltage"
31
32
TIME_REMAINING = "time_remaining"
32
33
BATTERY_VOLTAGE = "battery_voltage"
34
+ BATTERY_CURRENT = "battery_current"
35
+ BATTERY_TEMPERATURE = "battery_temperature"
33
36
AC_VOLTAGE = "ac_voltage"
34
37
AC_CURRENT = "ac_current"
35
38
AC_APPARENT_POWER = "ac_apparent_power"
39
+ AC_INPUT_STATE = "ac_input_state"
40
+ AC_INPUT_POWER = "ac_input_power"
41
+ AC_OUTPUT_POWER = "ac_output_power"
36
42
37
43
38
44
class VictronBluetoothDeviceData (BluetoothData ):
@@ -235,5 +241,51 @@ def _process_mfr_data(
235
241
device_class = SensorDeviceClass .APPARENT_POWER ,
236
242
)
237
243
244
+ elif isinstance (parsed , VEBusData ):
245
+ self .update_sensor (
246
+ key = VictronSensor .OPERATION_MODE ,
247
+ native_unit_of_measurement = None ,
248
+ native_value = parsed .get_device_state ().name .lower (),
249
+ device_class = SensorDeviceClass .ENUM ,
250
+ )
251
+ self .update_sensor (
252
+ key = VictronSensor .BATTERY_VOLTAGE ,
253
+ native_unit_of_measurement = Units .ELECTRIC_POTENTIAL_VOLT ,
254
+ native_value = parsed .get_battery_voltage (),
255
+ device_class = SensorDeviceClass .VOLTAGE ,
256
+ )
257
+ self .update_sensor (
258
+ key = VictronSensor .BATTERY_CURRENT ,
259
+ native_unit_of_measurement = Units .ELECTRIC_CURRENT_AMPERE ,
260
+ native_value = parsed .get_battery_current (),
261
+ device_class = SensorDeviceClass .CURRENT ,
262
+ )
263
+ self .update_sensor (
264
+ key = VictronSensor .BATTERY_TEMPERATURE ,
265
+ native_unit_of_measurement = Units .TEMP_CELSIUS ,
266
+ native_value = parsed .get_battery_temperature (),
267
+ device_class = SensorDeviceClass .TEMPERATURE ,
268
+ )
269
+ self .update_predefined_sensor (
270
+ SensorLibrary .BATTERY__PERCENTAGE , parsed .get_soc ()
271
+ )
272
+ self .update_sensor (
273
+ key = VictronSensor .AC_INPUT_STATE ,
274
+ native_unit_of_measurement = None ,
275
+ native_value = parsed .get_ac_in_state ().name .lower (),
276
+ device_class = SensorDeviceClass .ENUM ,
277
+ )
278
+ self .update_sensor (
279
+ key = VictronSensor .AC_INPUT_POWER ,
280
+ native_unit_of_measurement = Units .POWER_WATT ,
281
+ native_value = parsed .get_ac_in_power (),
282
+ device_class = SensorDeviceClass .POWER ,
283
+ )
284
+ self .update_sensor (
285
+ key = VictronSensor .AC_OUTPUT_POWER ,
286
+ native_unit_of_measurement = Units .POWER_WATT ,
287
+ native_value = parsed .get_ac_out_power (),
288
+ device_class = SensorDeviceClass .POWER ,
289
+ )
238
290
239
291
return
0 commit comments