Skip to content

Commit

Permalink
Merge pull request #1 from humppafreak/add-dcdc-converter
Browse files Browse the repository at this point in the history
Add dcdc converter
  • Loading branch information
stefanor authored Apr 16, 2023
2 parents 10584a4 + 1633613 commit 38c2451
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Currently supported:

* BMV 712 Battery Monitors.
* BlueSolar MPPT chargers (but untested in production).
* Orion Smart DC/DC chargers/converters.

## Installation

Expand Down
45 changes: 44 additions & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Optional

from bleak.backends.device import BLEDevice
from victron_ble.devices import AuxMode, BatteryMonitor, SolarCharger
from victron_ble.devices import AuxMode, BatteryMonitor, SolarCharger, DcDcConverter
from victron_ble.exceptions import AdvertisementKeyMissingError, UnknownDeviceError
from victron_ble.scanner import Scanner

Expand Down Expand Up @@ -51,6 +51,7 @@ def callback(self, bl_device: BLEDevice, raw_data: bytes):
transformers = {
BatteryMonitor: self.transform_battery_data,
SolarCharger: self.transform_solar_charger_data,
DcDcConverter: self.transform_dcdc_converter_data,
}
for device_type, transformer in transformers.items():
if isinstance(device, device_type):
Expand Down Expand Up @@ -172,6 +173,48 @@ def transform_solar_charger_data(
],
}

def transform_dcdc_converter_data(
self,
bl_device: BLEDevice,
cfg_device: ConfiguredDevice,
data: DcDcConverter,
id_: str,
):
return {
"updates": [
{
"source": {
"label": "Victron",
"type": "Bluetooth",
"src": bl_device.address,
},
"timestamp": datetime.datetime.utcnow().isoformat() + "Z",
"values": [
{
"path": f"electrical.converters.{id_}.chargingMode",
"value": data.get_charge_state().name.lower(),
},
{
"path": f"electrical.converters.{id_}.chargerError",
"value": data.get_charger_error().name.lower(),
},
{
"path": f"electrical.converters.{id_}.input.voltage",
"value": data.get_input_voltage(),
},
{
"path": f"electrical.converters.{id_}.output.voltage",
"value": data.get_output_voltage(),
},
{
"path": f"electrical.converters.{id_}.chargerOffReason",
"value": data.get_off_reason().name.lower(),
},
],
},
],
}


async def monitor(devices):
scanner = SignalKScanner(devices)
Expand Down

0 comments on commit 38c2451

Please sign in to comment.