Skip to content

Commit

Permalink
Integration of Victron SmartShunt via VE.Direct (#452)
Browse files Browse the repository at this point in the history
* Move Mppt logic to subclass

* Added Definitions for Shunts and restructering

* First integration of SmartShunt data into Web Interface

* Code cleanup

* VE.Direct: whitespace cleanup

* VE.Direct: manage HardwareSerial in unique_ptr

* VE.Direct: _efficiency is only needed by MPPT

* VE.Direct: keep as many members private as possible

* VE.Direct: use int8_t for pins (as before)

* VictronSmartShunt: _verboseLogging is not used

* VE.Direct: OR (off reason) is MPPT specific

it also applies to Phoenix inverters and Smart BuckBoost, but since
there is no support for those, the code is moved to the MPPT controller.

* Added Shunt alarms to liveview
Changed from double to int for several readings

* Update build.yml to allow manual builds

---------

Co-authored-by: Philipp Sandhaus <philipp.sandhaus@cewe.de>
Co-authored-by: Bernhard Kirchen <schlimmchen@posteo.net>
  • Loading branch information
3 people authored Sep 22, 2023
1 parent 160d3f2 commit 7142921
Show file tree
Hide file tree
Showing 27 changed files with 746 additions and 358 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
paths-ignore:
- docs/**
- '**/*.md'
workflow_dispatch:

jobs:
get_default_envs:
Expand Down
25 changes: 25 additions & 0 deletions include/BatteryStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "AsyncJson.h"
#include "Arduino.h"
#include "JkBmsDataPoints.h"
#include "VeDirectShuntController.h"

// mandatory interface for all kinds of batteries
class BatteryStats {
Expand Down Expand Up @@ -98,3 +99,27 @@ class JkBmsBatteryStats : public BatteryStats {
mutable uint32_t _lastMqttPublish = 0;
mutable uint32_t _lastFullMqttPublish = 0;
};

class VictronSmartShuntStats : public BatteryStats {
public:
void getLiveViewData(JsonVariant& root) const final;
void mqttPublish() const final;

void updateFrom(VeDirectShuntController::veShuntStruct const& shuntData);

private:
float _voltage;
float _current;
float _temperature;
uint8_t _chargeCycles;
uint32_t _timeToGo;
float _chargedEnergy;
float _dischargedEnergy;
String _modelName;

bool _alarmLowVoltage;
bool _alarmHighVoltage;
bool _alarmLowSOC;
bool _alarmLowTemperature;
bool _alarmHighTemperature;
};
5 changes: 3 additions & 2 deletions include/MqttHandleVedirect.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "VeDirectFrameHandler.h"
#include "VeDirectMpptController.h"
#include "Configuration.h"
#include <Arduino.h>

Expand All @@ -18,7 +18,8 @@ class MqttHandleVedirectClass {
void init();
void loop();
private:
veStruct _kvFrame{};

VeDirectMpptController::veMpptStruct _kvFrame{};

// point of time in millis() when updated values will be published
uint32_t _nextPublishUpdatesOnly = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/MqttHandleVedirectHass.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once

#include <ArduinoJson.h>
#include "VeDirectFrameHandler.h"
#include "VeDirectMpptController.h"

class MqttHandleVedirectHassClass {
public:
Expand Down
16 changes: 16 additions & 0 deletions include/VictronSmartShunt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "Battery.h"

class VictronSmartShunt : public BatteryProvider {
public:
bool init(bool verboseLogging) final;
void deinit() final { }
void loop() final;
std::shared_ptr<BatteryStats> getStats() const final { return _stats; }

private:
std::shared_ptr<VictronSmartShuntStats> _stats =
std::make_shared<VictronSmartShuntStats>();
};
2 changes: 1 addition & 1 deletion include/WebApi_ws_vedirect_live.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "ArduinoJson.h"
#include <ESPAsyncWebServer.h>
#include <VeDirectFrameHandler.h>
#include <VeDirectMpptController.h>

class WebApiWsVedirectLiveClass {
public:
Expand Down
Loading

0 comments on commit 7142921

Please sign in to comment.