Skip to content

Commit 29352e0

Browse files
committed
Add support for VE.Bus devices such as the Multiplus ii
1 parent 8e9eca8 commit 29352e0

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ Supported Devices & Entities:
3030
- AC Voltage (V)
3131
- AC Current (A)
3232
- AC Apparent Power (VA)
33+
- VE.Bus Adapter (works with Multiplus Inverters)
34+
- Device State (Off, Inverting)
35+
- Battery Voltage (V)
36+
- Battery Current (A)
37+
- Battery Temperature (°C)
38+
- Battery State of Charge (%)
39+
- AC Input State (AC_IN_1, AC_IN_2, NOT_CONNECTED)
40+
- AC Input Power (W)
41+
- AC Output Power (W)
3342

3443
# Installation
3544

custom_components/victron_ble/device.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from victron_ble.devices.dcdc_converter import DcDcConverterData
1414
from victron_ble.devices.inverter import InverterData
1515
from victron_ble.devices.solar_charger import SolarChargerData
16+
from victron_ble.devices.vebus import VEBusData
1617

1718
_LOGGER = logging.getLogger(__name__)
1819

@@ -30,9 +31,14 @@ class VictronSensor(StrEnum):
3031
MIDPOINT_VOLTAGE = "midpoint_voltage"
3132
TIME_REMAINING = "time_remaining"
3233
BATTERY_VOLTAGE = "battery_voltage"
34+
BATTERY_CURRENT = "battery_current"
35+
BATTERY_TEMPERATURE = "battery_temperature"
3336
AC_VOLTAGE = "ac_voltage"
3437
AC_CURRENT = "ac_current"
3538
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"
3642

3743

3844
class VictronBluetoothDeviceData(BluetoothData):
@@ -235,5 +241,51 @@ def _process_mfr_data(
235241
device_class=SensorDeviceClass.APPARENT_POWER,
236242
)
237243

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+
)
238290

239291
return

custom_components/victron_ble/sensor.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@
160160
native_unit_of_measurement=Units.ELECTRIC_POTENTIAL_VOLT,
161161
state_class=SensorStateClass.MEASUREMENT,
162162
),
163+
(VictronSensor.BATTERY_CURRENT, Units.ELECTRIC_CURRENT_AMPERE): SensorEntityDescription(
164+
key=VictronSensor.BATTERY_CURRENT,
165+
device_class=SensorDeviceClass.CURRENT,
166+
native_unit_of_measurement=Units.ELECTRIC_CURRENT_AMPERE,
167+
state_class=SensorStateClass.MEASUREMENT,
168+
),
169+
(VictronSensor.BATTERY_TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
170+
key=VictronSensor.BATTERY_TEMPERATURE,
171+
device_class=SensorDeviceClass.TEMPERATURE,
172+
native_unit_of_measurement=Units.TEMP_CELSIUS,
173+
state_class=SensorStateClass.MEASUREMENT,
174+
),
163175
(VictronSensor.AC_VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
164176
key=VictronSensor.AC_VOLTAGE,
165177
device_class=SensorDeviceClass.VOLTAGE,
@@ -178,6 +190,23 @@
178190
native_unit_of_measurement=Units.POWER_VOLT_AMPERE,
179191
state_class=SensorStateClass.MEASUREMENT,
180192
),
193+
(VictronSensor.AC_INPUT_STATE, None): SensorEntityDescription(
194+
key=VictronSensor.AC_INPUT_STATE,
195+
device_class=SensorDeviceClass.ENUM,
196+
options=[x.lower() for x in ACInState._member_names_],
197+
),
198+
(VictronSensor.AC_INPUT_POWER, Units.POWER_WATT): SensorEntityDescription(
199+
key=VictronSensor.AC_INPUT_POWER,
200+
device_class=SensorDeviceClass.POWER,
201+
native_unit_of_measurement=Units.POWER_WATT,
202+
state_class=SensorStateClass.MEASUREMENT,
203+
),
204+
(VictronSensor.AC_OUTPUT_POWER, Units.POWER_WATT): SensorEntityDescription(
205+
key=VictronSensor.AC_OUTPUT_POWER,
206+
device_class=SensorDeviceClass.POWER,
207+
native_unit_of_measurement=Units.POWER_WATT,
208+
state_class=SensorStateClass.MEASUREMENT,
209+
),
181210
}
182211

183212

0 commit comments

Comments
 (0)