Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Nov 16, 2023
2 parents a1d0dad + 0085970 commit e44328b
Show file tree
Hide file tree
Showing 42 changed files with 741 additions and 400 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Gather Environments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.x"

- name: Install PlatformIO
run: |
Expand All @@ -55,7 +55,7 @@ jobs:
matrix:
environment: ${{ fromJSON(needs.get_default_envs.outputs.environments) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get tags
run: git fetch --force --tags origin
Expand All @@ -77,17 +77,17 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.x"

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pip install --upgrade platformio setuptools
- name: Setup Node.js and yarn
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
node-version: "20"
cache: "yarn"
cache-dependency-path: "webapp/yarn.lock"

Expand Down
2 changes: 2 additions & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ struct CONFIG_T {
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
uint32_t WiFi_ApTimeout;

bool Mdns_Enabled;

char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1];
Expand Down
4 changes: 3 additions & 1 deletion include/InverterSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <cstdint>

#define INVERTER_UPDATE_SETTINGS_INTERVAL 60000l

class InverterSettingsClass {
public:
void init();
Expand All @@ -12,4 +14,4 @@ class InverterSettingsClass {
uint32_t _lastUpdate = 0;
};

extern InverterSettingsClass InverterSettings;
extern InverterSettingsClass InverterSettings;
2 changes: 2 additions & 0 deletions include/NetworkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class NetworkSettingsClass {
private:
void setHostname();
void setStaticIp();
void handleMDNS();
void setupMode();
void NetworkEvent(WiFiEvent_t event);
bool adminEnabled = true;
Expand All @@ -76,6 +77,7 @@ class NetworkSettingsClass {
network_mode _networkMode = network_mode::Undefined;
bool _ethConnected = false;
std::vector<NetworkEventCbList_t> _cbEventList;
bool lastMdnsEnabled = false;
};

extern NetworkSettingsClass NetworkSettings;
12 changes: 8 additions & 4 deletions include/SunPosition.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include <mutex>
#include <sunset.h>

#define SUNPOS_UPDATE_INTERVAL 60000l

class SunPositionClass {
public:
SunPositionClass();
Expand All @@ -15,18 +14,23 @@ class SunPositionClass {
bool isSunsetAvailable();
bool sunsetTime(struct tm* info);
bool sunriseTime(struct tm* info);
void setDoRecalc(bool doRecalc);

private:
void updateSunData();
bool checkRecalcDayChanged();
bool getDoRecalc();

SunSet _sun;
bool _isDayPeriod = true;
bool _isSunsetAvailable = true;
uint32_t _sunriseMinutes = 0;
uint32_t _sunsetMinutes = 0;

uint32_t _lastUpdate = 0;
bool _isValidInfo = false;
bool _doRecalc = true;
std::mutex _recalcLock;
uint32_t _lastSunPositionCalculatedYMD = 0;
};

extern SunPositionClass SunPosition;
extern SunPositionClass SunPosition;
2 changes: 2 additions & 0 deletions include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define WIFI_PASSWORD ""
#define WIFI_DHCP true

#define MDNS_ENABLED false

#define NTP_SERVER "pool.ntp.org"
#define NTP_TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
#define NTP_TIMEZONEDESCR "Europe/Berlin"
Expand Down
10 changes: 9 additions & 1 deletion lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "inverters/HMS_1CHv2.h"
#include "inverters/HMS_2CH.h"
#include "inverters/HMS_4CH.h"
#include "inverters/HMT_4CH.h"
#include "inverters/HMT_6CH.h"
#include "inverters/HM_1CH.h"
#include "inverters/HM_2CH.h"
Expand Down Expand Up @@ -52,6 +53,11 @@ void HoymilesClass::loop()

if (iv != nullptr && iv->getRadio()->isInitialized() && iv->getRadio()->isQueueEmpty()) {

if (iv->getZeroValuesIfUnreachable() && !iv->isReachable()) {
Hoymiles.getMessageOutput()->println("Set runtime data to zero");
iv->Statistics()->zeroRuntimeData();
}

if (iv->getEnablePolling() || iv->getEnableCommands()) {
_messageOutput->print("Fetch inverter: ");
_messageOutput->println(iv->serial(), HEX);
Expand Down Expand Up @@ -140,7 +146,9 @@ void HoymilesClass::loop()
std::shared_ptr<InverterAbstract> HoymilesClass::addInverter(const char* name, uint64_t serial)
{
std::shared_ptr<InverterAbstract> i = nullptr;
if (HMT_6CH::isValidSerial(serial)) {
if (HMT_4CH::isValidSerial(serial)) {
i = std::make_shared<HMT_4CH>(_radioCmt.get(), serial);
} else if (HMT_6CH::isValidSerial(serial)) {
i = std::make_shared<HMT_6CH>(_radioCmt.get(), serial);
} else if (HMS_4CH::isValidSerial(serial)) {
i = std::make_shared<HMS_4CH>(_radioCmt.get(), serial);
Expand Down
5 changes: 0 additions & 5 deletions lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,4 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract* inverter, fragment
void RealTimeRunDataCommand::gotTimeout(InverterAbstract* inverter)
{
inverter->Statistics()->incrementRxFailureCount();

if (inverter->getZeroValuesIfUnreachable() && !inverter->isReachable()) {
Hoymiles.getMessageOutput()->println("Set runtime data to zero");
inverter->Statistics()->zeroRuntimeData();
}
}
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMS_1CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool HMS_1CH::isValidSerial(uint64_t serial)

String HMS_1CH::typeName()
{
return "HMS-300, HMS-350, HMS-400, HMS-450, HMS-500";
return "HMS-300/350/400/450/500-1T";
}

const byteAssign_t* HMS_1CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMS_1CHv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool HMS_1CHv2::isValidSerial(uint64_t serial)

String HMS_1CHv2::typeName()
{
return "HMS-500 v2";
return "HMS-500-1T v2";
}

const byteAssign_t* HMS_1CHv2::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMS_2CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool HMS_2CH::isValidSerial(uint64_t serial)

String HMS_2CH::typeName()
{
return "HMS-600, HMS-700, HMS-800, HMS-900, HMS-1000";
return "HMS-600/700/800/900/1000-2T";
}

const byteAssign_t* HMS_2CH::getByteAssignment()
Expand Down
4 changes: 2 additions & 2 deletions lib/Hoymiles/src/inverters/HMS_4CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ HMS_4CH::HMS_4CH(HoymilesRadio* radio, uint64_t serial)

bool HMS_4CH::isValidSerial(uint64_t serial)
{
// serial >= 0x114400000000 && serial <= 0x114499999999
// serial >= 0x116400000000 && serial <= 0x116499999999
uint16_t preSerial = (serial >> 32) & 0xffff;
return preSerial == 0x1164;
}

String HMS_4CH::typeName()
{
return "HMS-1600, HMS-1800, HMS-2000";
return "HMS-1600/1800/2000";
}

const byteAssign_t* HMS_4CH::getByteAssignment()
Expand Down
84 changes: 84 additions & 0 deletions lib/Hoymiles/src/inverters/HMT_4CH.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2023 Thomas Basler and others
*/
#include "HMT_4CH.h"

static const byteAssign_t byteAssignment[] = {
{ TYPE_DC, CH0, FLD_UDC, UNIT_V, 2, 2, 10, false, 1 },
{ TYPE_DC, CH0, FLD_IDC, UNIT_A, 4, 2, 100, false, 2 },
{ TYPE_DC, CH0, FLD_PDC, UNIT_W, 8, 2, 10, false, 1 },
{ TYPE_DC, CH0, FLD_YT, UNIT_KWH, 12, 4, 1000, false, 3 },
{ TYPE_DC, CH0, FLD_YD, UNIT_WH, 20, 2, 1, false, 0 },
{ TYPE_DC, CH0, FLD_IRR, UNIT_PCT, CALC_IRR_CH, CH0, CMD_CALC, false, 3 },

{ TYPE_DC, CH1, FLD_UDC, UNIT_V, 2, 2, 10, false, 1 },
{ TYPE_DC, CH1, FLD_IDC, UNIT_A, 6, 2, 100, false, 2 },
{ TYPE_DC, CH1, FLD_PDC, UNIT_W, 10, 2, 10, false, 1 },
{ TYPE_DC, CH1, FLD_YT, UNIT_KWH, 16, 4, 1000, false, 3 },
{ TYPE_DC, CH1, FLD_YD, UNIT_WH, 22, 2, 1, false, 0 },
{ TYPE_DC, CH1, FLD_IRR, UNIT_PCT, CALC_IRR_CH, CH1, CMD_CALC, false, 3 },

{ TYPE_DC, CH2, FLD_UDC, UNIT_V, 24, 2, 10, false, 1 },
{ TYPE_DC, CH2, FLD_IDC, UNIT_A, 26, 2, 100, false, 2 },
{ TYPE_DC, CH2, FLD_PDC, UNIT_W, 30, 2, 10, false, 1 },
{ TYPE_DC, CH2, FLD_YT, UNIT_KWH, 34, 4, 1000, false, 3 },
{ TYPE_DC, CH2, FLD_YD, UNIT_WH, 42, 2, 1, false, 0 },
{ TYPE_DC, CH2, FLD_IRR, UNIT_PCT, CALC_IRR_CH, CH2, CMD_CALC, false, 3 },

{ TYPE_DC, CH3, FLD_UDC, UNIT_V, 24, 2, 10, false, 1 },
{ TYPE_DC, CH3, FLD_IDC, UNIT_A, 28, 2, 100, false, 2 },
{ TYPE_DC, CH3, FLD_PDC, UNIT_W, 32, 2, 10, false, 1 },
{ TYPE_DC, CH3, FLD_YT, UNIT_KWH, 38, 4, 1000, false, 3 },
{ TYPE_DC, CH3, FLD_YD, UNIT_WH, 44, 2, 1, false, 0 },
{ TYPE_DC, CH3, FLD_IRR, UNIT_PCT, CALC_IRR_CH, CH3, CMD_CALC, false, 3 },

{ TYPE_AC, CH0, FLD_UAC, UNIT_V, 74, 2, 10, false, 1 }, // dummy
{ TYPE_AC, CH0, FLD_UAC_1N, UNIT_V, 68, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_UAC_2N, UNIT_V, 70, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_UAC_3N, UNIT_V, 72, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_UAC_12, UNIT_V, 74, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_UAC_23, UNIT_V, 76, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_UAC_31, UNIT_V, 78, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_F, UNIT_HZ, 80, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_PAC, UNIT_W, 82, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_Q, UNIT_VAR, 84, 2, 10, true, 1 },
{ TYPE_AC, CH0, FLD_IAC, UNIT_A, 86, 2, 100, false, 2 }, // dummy
{ TYPE_AC, CH0, FLD_IAC_1, UNIT_A, 86, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_IAC_2, UNIT_A, 88, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_IAC_3, UNIT_A, 90, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_PF, UNIT_NONE, 92, 2, 1000, false, 3 },

{ TYPE_INV, CH0, FLD_T, UNIT_C, 94, 2, 10, true, 1 },
{ TYPE_INV, CH0, FLD_EVT_LOG, UNIT_NONE, 96, 2, 1, false, 0 },

{ TYPE_AC, CH0, FLD_YD, UNIT_WH, CALC_YD_CH0, 0, CMD_CALC, false, 0 },
{ TYPE_AC, CH0, FLD_YT, UNIT_KWH, CALC_YT_CH0, 0, CMD_CALC, false, 3 },
{ TYPE_AC, CH0, FLD_PDC, UNIT_W, CALC_PDC_CH0, 0, CMD_CALC, false, 1 },
{ TYPE_AC, CH0, FLD_EFF, UNIT_PCT, CALC_EFF_CH0, 0, CMD_CALC, false, 3 }
};

HMT_4CH::HMT_4CH(HoymilesRadio* radio, uint64_t serial)
: HMT_Abstract(radio, serial) {};

bool HMT_4CH::isValidSerial(uint64_t serial)
{
// serial >= 0x136100000000 && serial <= 0x136199999999
uint16_t preSerial = (serial >> 32) & 0xffff;
return preSerial == 0x1361;
}

String HMT_4CH::typeName()
{
return F("HMT-1600/1800/2000-4T");
}

const byteAssign_t* HMT_4CH::getByteAssignment()
{
return byteAssignment;
}

uint8_t HMT_4CH::getByteAssignmentSize()
{
return sizeof(byteAssignment) / sizeof(byteAssignment[0]);
}
13 changes: 13 additions & 0 deletions lib/Hoymiles/src/inverters/HMT_4CH.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "HMT_Abstract.h"

class HMT_4CH : public HMT_Abstract {
public:
explicit HMT_4CH(HoymilesRadio* radio, uint64_t serial);
static bool isValidSerial(uint64_t serial);
String typeName();
const byteAssign_t* getByteAssignment();
uint8_t getByteAssignmentSize();
};
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMT_6CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool HMT_6CH::isValidSerial(uint64_t serial)

String HMT_6CH::typeName()
{
return F("HMT-1800, HMT-2250");
return F("HMT-1800/2250-6T");
}

const byteAssign_t* HMT_6CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_1CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool HM_1CH::isValidSerial(uint64_t serial)

String HM_1CH::typeName()
{
return "HM-300, HM-350, HM-400";
return "HM-300/350/400-1T";
}

const byteAssign_t* HM_1CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_2CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool HM_2CH::isValidSerial(uint64_t serial)

String HM_2CH::typeName()
{
return "HM-600, HM-700, HM-800";
return "HM-600/700/800-2T";
}

const byteAssign_t* HM_2CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_4CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool HM_4CH::isValidSerial(uint64_t serial)

String HM_4CH::typeName()
{
return "HM-1000, HM-1200, HM-1500";
return "HM-1000/1200/1500-4T";
}

const byteAssign_t* HM_4CH::getByteAssignment()
Expand Down
13 changes: 13 additions & 0 deletions lib/Hoymiles/src/inverters/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Class overview

| Class | Models | Serial range |
| --------------| --------------------------- | ------------ |
| HM_1CH | HM-300/350/400-1T | 1121 |
| HM_2CH | HM-600/700/800-2T | 1141 |
| HM_4CH | HM-1000/1200/1500-4T | 1161 |
| HMS_1CH | HMS-300/350/400/450/500-1T | 1124 |
| HMS_1CHv2 | HMS-500-1T v2 | 1125 |
| HMS_2CH | HMS-600/700/800/900/1000-2T | 1144 |
| HMS_4CH | HMS-1600/1800/2000-4T | 1164 |
| HMT_4CH | HMT-1600/1800/2000-4T | 1361 |
| HMT_6CH | HMT-1800/2250-6T | 1382 |
Loading

0 comments on commit e44328b

Please sign in to comment.