Skip to content

Commit

Permalink
Prepare Release 2025.01.09
Browse files Browse the repository at this point in the history
Merges branch development into master.
  • Loading branch information
schlimmchen authored Jan 9, 2025
2 parents 81b1e6e + 0ad1626 commit b9ab868
Show file tree
Hide file tree
Showing 106 changed files with 2,967 additions and 2,089 deletions.
Binary file removed .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:
get_default_envs:
name: Gather Environments
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:

build:
name: Build Environments
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: get_default_envs
strategy:
matrix:
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
release:
name: Create Release
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [get_default_envs, build]
if: startsWith(github.ref, 'refs/tags/2')
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

# prevent push event from triggering if it's part of a local PR, see
# https://github.com/orgs/community/discussions/57827#discussioncomment-6579237
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/repo-maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
stale:
name: 'Stale'
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/stale@v9
with:
Expand All @@ -32,7 +32,7 @@ jobs:
lock-threads:
name: 'Lock Old Threads'
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: dessant/lock-threads@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yarnlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

# prevent push event from triggering if it's part of a local PR, see
# https://github.com/orgs/community/discussions/57827#discussioncomment-6579237
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yarnprettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

# prevent push event from triggering if it's part of a local PR, see
# https://github.com/orgs/community/discussions/57827#discussioncomment-6579237
Expand Down
6 changes: 3 additions & 3 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
OpenDTU - ESP32 firmware to control HoyMiles Inverter
OpenDTU-OnBattery - ESP32 firmware to control Hoymiles inverters and peripherals

Copyright (C) 2022 Thomas Basler and others

OpenDTU is provided under:
OpenDTU-OnBattery is provided under:

SPDX-License-Identifier: GPL-2.0-or-later

Being under the terms of the GNU General Public License version 2
or any later version, according with:

LICENSE
LICENSE
66 changes: 43 additions & 23 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#define CONFIG_FILENAME "/config.json"
#define CONFIG_VERSION 0x00011d00 // 0.1.29 // make sure to clean all after change
#define CONFIG_VERSION_ONBATTERY 4

#define WIFI_MAX_SSID_STRLEN 32
#define WIFI_MAX_PASSWORD_STRLEN 64
Expand Down Expand Up @@ -137,17 +138,18 @@ struct POWERLIMITER_INVERTER_CONFIG_T {
bool IsGoverned;
bool IsBehindPowerMeter;
bool IsSolarPowered;
bool UseOverscalingToCompensateShading;
bool UseOverscaling;
uint16_t LowerPowerLimit;
uint16_t UpperPowerLimit;
uint8_t ScalingThreshold;
};
using PowerLimiterInverterConfig = struct POWERLIMITER_INVERTER_CONFIG_T;

struct POWERLIMITER_CONFIG_T {
bool Enabled;
bool VerboseLogging;
bool SolarPassThroughEnabled;
uint8_t SolarPassThroughLosses;
uint8_t ConductionLosses;
bool BatteryAlwaysUseAtNight;
int16_t TargetPowerConsumption;
uint16_t TargetPowerConsumptionHysteresis;
Expand Down Expand Up @@ -195,9 +197,39 @@ struct BATTERY_CONFIG_T {
};
using BatteryConfig = struct BATTERY_CONFIG_T;

enum GridChargerHardwareInterface { MCP2515 = 0, TWAI = 1 };

struct GRID_CHARGER_CONFIG_T {
bool Enabled;
bool VerboseLogging;
GridChargerHardwareInterface HardwareInterface;
uint32_t CAN_Controller_Frequency;
bool Auto_Power_Enabled;
bool Auto_Power_BatterySoC_Limits_Enabled;
bool Emergency_Charge_Enabled;
float Auto_Power_Voltage_Limit;
float Auto_Power_Enable_Voltage_Limit;
float Auto_Power_Lower_Power_Limit;
float Auto_Power_Upper_Power_Limit;
uint8_t Auto_Power_Stop_BatterySoC_Threshold;
float Auto_Power_Target_Power_Consumption;
};
using GridChargerConfig = struct GRID_CHARGER_CONFIG_T;

enum SolarChargerProviderType { VEDIRECT = 0 };

struct SOLAR_CHARGER_CONFIG_T {
bool Enabled;
bool VerboseLogging;
SolarChargerProviderType Provider;
bool PublishUpdatesOnly;
};
using SolarChargerConfig = struct SOLAR_CHARGER_CONFIG_T;

struct CONFIG_T {
struct {
uint32_t Version;
uint32_t VersionOnBattery;
uint32_t SaveCount;
} Cfg;

Expand Down Expand Up @@ -305,11 +337,7 @@ struct CONFIG_T {
uint8_t Brightness;
} Led_Single[PINMAPPING_LED_COUNT];

struct {
bool Enabled;
bool VerboseLogging;
bool UpdatesOnly;
} Vedirect;
SolarChargerConfig SolarCharger;

struct PowerMeterConfig {
bool Enabled;
Expand All @@ -325,21 +353,7 @@ struct CONFIG_T {

BatteryConfig Battery;

struct {
bool Enabled;
bool VerboseLogging;
uint32_t CAN_Controller_Frequency;
bool Auto_Power_Enabled;
bool Auto_Power_BatterySoC_Limits_Enabled;
bool Emergency_Charge_Enabled;
float Auto_Power_Voltage_Limit;
float Auto_Power_Enable_Voltage_Limit;
float Auto_Power_Lower_Power_Limit;
float Auto_Power_Upper_Power_Limit;
uint8_t Auto_Power_Stop_BatterySoC_Threshold;
float Auto_Power_Target_Power_Consumption;
} Huawei;

GridChargerConfig Huawei;

INVERTER_CONFIG_T Inverter[INV_MAX_COUNT];
char Dev_PinMapping[DEV_MAX_MAPPING_NAME_STRLEN + 1];
Expand All @@ -351,6 +365,7 @@ class ConfigurationClass {
bool read();
bool write();
void migrate();
void migrateOnBattery();
CONFIG_T const& get();

class WriteGuard {
Expand All @@ -370,23 +385,28 @@ class ConfigurationClass {
void deleteInverterById(const uint8_t id);

static void serializeHttpRequestConfig(HttpRequestConfig const& source, JsonObject& target);
static void serializeSolarChargerConfig(SolarChargerConfig const& source, JsonObject& target);
static void serializePowerMeterMqttConfig(PowerMeterMqttConfig const& source, JsonObject& target);
static void serializePowerMeterSerialSdmConfig(PowerMeterSerialSdmConfig const& source, JsonObject& target);
static void serializePowerMeterHttpJsonConfig(PowerMeterHttpJsonConfig const& source, JsonObject& target);
static void serializePowerMeterHttpSmlConfig(PowerMeterHttpSmlConfig const& source, JsonObject& target);
static void serializeBatteryConfig(BatteryConfig const& source, JsonObject& target);
static void serializePowerLimiterConfig(PowerLimiterConfig const& source, JsonObject& target);
static void serializeGridChargerConfig(GridChargerConfig const& source, JsonObject& target);

static void deserializeHttpRequestConfig(JsonObject const& source, HttpRequestConfig& target);
static void deserializeHttpRequestConfig(JsonObject const& source_http_config, HttpRequestConfig& target);
static void deserializeSolarChargerConfig(JsonObject const& source, SolarChargerConfig& target);
static void deserializePowerMeterMqttConfig(JsonObject const& source, PowerMeterMqttConfig& target);
static void deserializePowerMeterSerialSdmConfig(JsonObject const& source, PowerMeterSerialSdmConfig& target);
static void deserializePowerMeterHttpJsonConfig(JsonObject const& source, PowerMeterHttpJsonConfig& target);
static void deserializePowerMeterHttpSmlConfig(JsonObject const& source, PowerMeterHttpSmlConfig& target);
static void deserializeBatteryConfig(JsonObject const& source, BatteryConfig& target);
static void deserializePowerLimiterConfig(JsonObject const& source, PowerLimiterConfig& target);
static void deserializeGridChargerConfig(JsonObject const& source, GridChargerConfig& target);

private:
void loop();
static double roundedFloat(float val);

Task _loopTask;
};
Expand Down
14 changes: 12 additions & 2 deletions include/DataPoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <string>
#include <unordered_map>
#include <variant>
#include <limits>
#include <algorithm>

using tCellVoltages = std::map<uint8_t, uint16_t>;

Expand Down Expand Up @@ -58,8 +60,6 @@ class DataPointContainer {
public:
DataPointContainer() = default;

//template<Label L> using Traits = LabelTraits<L>;

template<Label L>
void add(typename Traits<L>::type val) {
_dataPoints.emplace(
Expand Down Expand Up @@ -114,6 +114,16 @@ class DataPointContainer {
}
}

uint32_t getLastUpdate() const
{
uint32_t now = millis();
uint32_t diff = std::numeric_limits<uint32_t>::max()/2;
for (auto iter = _dataPoints.cbegin(); iter != _dataPoints.cend(); ++iter) {
diff = std::min(diff, now - iter->second.getTimestamp());
}
return now - diff;
}

private:
tMap _dataPoints;
};
Loading

0 comments on commit b9ab868

Please sign in to comment.