From 4e46b85c4e93e8d6c56cdf1650d003625d728972 Mon Sep 17 00:00:00 2001
From: Tobias Rosenstock
Date: Sun, 5 Feb 2023 00:08:31 +0100
Subject: [PATCH 1/5] Added support for Orion Smart DC/DC converters
---
plugin.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/plugin.py b/plugin.py
index 5ef470c..7303459 100644
--- a/plugin.py
+++ b/plugin.py
@@ -8,7 +8,7 @@
from typing import Optional
from bleak.backends.device import BLEDevice
-from victron_ble.devices import BatteryMonitor, SolarCharger
+from victron_ble.devices import BatteryMonitor, SolarCharger, DcDcConverter
from victron_ble.exceptions import AdvertisementKeyMissingError, UnknownDeviceError
from victron_ble.scanner import Scanner
@@ -52,6 +52,8 @@ def callback(self, bl_device: BLEDevice, raw_data: bytes):
self.log_battery(bl_device, configured_device, data, id_)
elif isinstance(device, SolarCharger):
self.log_solar_charger(bl_device, configured_device, data, id_)
+ elif isinstance(device, DcDcConverter):
+ self.log_dcdc_converter(bl_device, configured_device, data, id_)
else:
logger.debug("Unknown device", device)
@@ -144,6 +146,51 @@ def log_solar_charger(
print(json.dumps(delta))
sys.stdout.flush()
+ def log_dcdc_converter(
+ self,
+ bl_device: BLEDevice,
+ cfg_device: ConfiguredDevice,
+ data: DcDcConverter,
+ id_: str,
+ ):
+ delta = {
+ "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_}.chargingMode.offReason",
+ "value": data.get_off_reason().name.lower(),
+ },
+ ],
+ },
+ ],
+ }
+ logger.info(delta)
+ print(json.dumps(delta))
+ sys.stdout.flush()
+
async def monitor(devices):
scanner = SignalKScanner(devices)
From 24c795fd0cf284ffa885b829c6f4b6ac1aa52116 Mon Sep 17 00:00:00 2001
From: humppafreak <75011426+humppafreak@users.noreply.github.com>
Date: Sun, 5 Feb 2023 00:13:52 +0100
Subject: [PATCH 2/5] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index d0b586b..035499e 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ Currently supported:
* BMV 712 Battery Monitors.
* BlueSolar MPPT chargers (but untested in production).
+* Orion Smart DC/DC chargers/converters.
## Installation
From cd44da2f305123dc654bf476959fb3eff40b0c8b Mon Sep 17 00:00:00 2001
From: humppafreak <75011426+humppafreak@users.noreply.github.com>
Date: Sat, 15 Apr 2023 17:57:23 +0200
Subject: [PATCH 3/5] fixed typo, added DcDcConverter transformer
---
plugin.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plugin.py b/plugin.py
index 5a80385..f2c9269 100644
--- a/plugin.py
+++ b/plugin.py
@@ -8,7 +8,7 @@
from typing import Optional
from bleak.backends.device import BLEDevice
-from victron_ble.devices import AuxMode BatteryMonitor, SolarCharger, DcDcConverter
+from victron_ble.devices import AuxMode, BatteryMonitor, SolarCharger, DcDcConverter
from victron_ble.exceptions import AdvertisementKeyMissingError, UnknownDeviceError
from victron_ble.scanner import Scanner
@@ -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):
From e12a1ff266bd51af576d10b5e80b5985d28f104d Mon Sep 17 00:00:00 2001
From: humppafreak <75011426+humppafreak@users.noreply.github.com>
Date: Sat, 15 Apr 2023 23:04:44 +0200
Subject: [PATCH 4/5] renamed ...chargingMode.offReason to ...chargerOffReason
---
plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin.py b/plugin.py
index f2c9269..b2509d9 100644
--- a/plugin.py
+++ b/plugin.py
@@ -203,7 +203,7 @@ def transform_dcdc_converter_data(
"value": data.get_output_voltage(),
},
{
- "path": f"electrical.converters.{id_}.chargingMode.offReason",
+ "path": f"electrical.converters.{id_}.chargerOffReason",
"value": data.get_off_reason().name.lower(),
},
],
From 16336139154ec2e52f4444eb1e3049c5e4c0b48e Mon Sep 17 00:00:00 2001
From: Stefano Rivera
Date: Sun, 16 Apr 2023 09:13:59 -0400
Subject: [PATCH 5/5] Correct syntax error
---
plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin.py b/plugin.py
index b2509d9..f5a5d6c 100644
--- a/plugin.py
+++ b/plugin.py
@@ -176,7 +176,7 @@ def transform_dcdc_converter_data(
data: DcDcConverter,
id_: str,
):
- return = {
+ return {
"updates": [
{
"source": {