Skip to content

Commit 5e3a53d

Browse files
committed
Merge upstream tag 'v24.6.10' into development
2 parents 83ac154 + c144b68 commit 5e3a53d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+664
-517
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ body:
55
- type: markdown
66
attributes:
77
value: >
8-
### ✋ **This is bug tracker, not a support forum**
8+
### ⚠️ Please remember: issues are for *bugs*
9+
That is, something you believe affects every single user of OpenDTU, not just you. If you're not sure, start with one of the other options below.
10+
- type: markdown
11+
attributes:
12+
value: |
13+
#### Have a question? 👉 [Start a new discussion](https://github.com/tbnobody/OpenDTU/discussions/new) or [ask in chat](https://discord.gg/WzhxEY62mB).
914
10-
If something isn't working right, you have questions or need help, [**get in touch on the Discussions**](https://github.com/tbnobody/OpenDTU/discussions).
15+
#### Before opening an issue, please double check:
1116
12-
Please quickly search existing issues first before submitting a bug.
17+
- [Documentation](https://www.opendtu.solar).
18+
- [The FAQs](https://www.opendtu.solar/firmware/faq/).
19+
- [Existing issues and discussions](https://github.com/tbnobody/OpenDTU/search?q=&type=issues).
1320
- type: textarea
1421
id: what-happened
1522
attributes:
@@ -65,4 +72,15 @@ body:
6572
Links? References? Anything that will give us more context about the issue you are encountering!
6673
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
6774
validations:
68-
required: false
75+
required: false
76+
- type: checkboxes
77+
id: required-checks
78+
attributes:
79+
label: Please confirm the following
80+
options:
81+
- label: I believe this issue is a bug that affects all users of OpenDTU, not something specific to my installation.
82+
required: true
83+
- label: I have already searched for relevant existing issues and discussions before opening this report.
84+
required: true
85+
- label: I have updated the title field above with a concise description.
86+
required: true

include/Configuration.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct INVERTER_CONFIG_T {
5656
uint8_t ReachableThreshold;
5757
bool ZeroRuntimeDataIfUnrechable;
5858
bool ZeroYieldDayOnMidnight;
59+
bool ClearEventlogOnMidnight;
5960
bool YieldDayCorrection;
6061
CHANNEL_CONFIG_T channel[INV_MAX_CHAN_COUNT];
6162
};

include/MqttHandleInverter.h

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class MqttHandleInverterClass {
1313

1414
static String getTopic(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId);
1515

16+
void subscribeTopics();
17+
void unsubscribeTopics();
18+
1619
private:
1720
void loop();
1821
void publishField(std::shared_ptr<InverterAbstract> inv, const ChannelType_t type, const ChannelNum_t channel, const FieldId_t fieldId);
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright (C) 2024 Thomas Basler and others
4+
*/
5+
6+
#include "CpuTemperature.h"
7+
#include <Arduino.h>
8+
9+
#if defined(CONFIG_IDF_TARGET_ESP32)
10+
// there is no official API available on the original ESP32
11+
extern "C" {
12+
uint8_t temprature_sens_read();
13+
}
14+
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
15+
#include "driver/temp_sensor.h"
16+
#endif
17+
18+
CpuTemperatureClass CpuTemperature;
19+
20+
float CpuTemperatureClass::read()
21+
{
22+
std::lock_guard<std::mutex> lock(_mutex);
23+
24+
float temperature = NAN;
25+
bool success = false;
26+
27+
#if defined(CONFIG_IDF_TARGET_ESP32)
28+
uint8_t raw = temprature_sens_read();
29+
ESP_LOGV(TAG, "Raw temperature value: %d", raw);
30+
temperature = (raw - 32) / 1.8f;
31+
success = (raw != 128);
32+
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
33+
temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT();
34+
temp_sensor_set_config(tsens);
35+
temp_sensor_start();
36+
#if defined(CONFIG_IDF_TARGET_ESP32S3) && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 3))
37+
#error \
38+
"ESP32-S3 internal temperature sensor requires ESP IDF V4.4.3 or higher. See https://github.com/esphome/issues/issues/4271"
39+
#endif
40+
esp_err_t result = temp_sensor_read_celsius(&temperature);
41+
temp_sensor_stop();
42+
success = (result == ESP_OK);
43+
#endif
44+
45+
if (success && std::isfinite(temperature)) {
46+
return temperature;
47+
} else {
48+
ESP_LOGD(TAG, "Ignoring invalid temperature (success=%d, value=%.1f)", success, temperature);
49+
return NAN;
50+
}
51+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
#pragma once
3+
4+
#include <mutex>
5+
6+
class CpuTemperatureClass {
7+
public:
8+
float read();
9+
10+
private:
11+
std::mutex _mutex;
12+
};
13+
14+
extern CpuTemperatureClass CpuTemperature;

lib/Hoymiles/src/Hoymiles.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ void HoymilesClass::loop()
141141
if (inv->getZeroYieldDayOnMidnight()) {
142142
inv->Statistics()->zeroDailyData();
143143
}
144+
if (inv->getClearEventlogOnMidnight()) {
145+
inv->EventLog()->clearBuffer();
146+
}
144147
}
145148

146149
lastWeekDay = currentWeekDay;

lib/Hoymiles/src/HoymilesRadio.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class HoymilesRadio {
2222
}
2323

2424
template <typename T>
25-
std::shared_ptr<T> prepareCommand()
25+
std::shared_ptr<T> prepareCommand(InverterAbstract* inv)
2626
{
27-
return std::make_shared<T>();
27+
return std::make_shared<T>(inv);
2828
}
2929

3030
protected:

lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/*
3-
* Copyright (C) 2022-2023 Thomas Basler and others
3+
* Copyright (C) 2022-2024 Thomas Basler and others
44
*/
55

66
/*
@@ -25,8 +25,8 @@ ID Target Addr Source Addr Cmd SCmd ? Limit Type CRC16 CRC8
2525

2626
#define CRC_SIZE 6
2727

28-
ActivePowerControlCommand::ActivePowerControlCommand(const uint64_t target_address, const uint64_t router_address)
29-
: DevControlCommand(target_address, router_address)
28+
ActivePowerControlCommand::ActivePowerControlCommand(InverterAbstract* inv, const uint64_t router_address)
29+
: DevControlCommand(inv, router_address)
3030
{
3131
_payload[10] = 0x0b;
3232
_payload[11] = 0x00;
@@ -62,24 +62,24 @@ void ActivePowerControlCommand::setActivePowerLimit(const float limit, const Pow
6262
udpateCRC(CRC_SIZE);
6363
}
6464

65-
bool ActivePowerControlCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
65+
bool ActivePowerControlCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
6666
{
67-
if (!DevControlCommand::handleResponse(inverter, fragment, max_fragment_id)) {
67+
if (!DevControlCommand::handleResponse(fragment, max_fragment_id)) {
6868
return false;
6969
}
7070

7171
if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) {
72-
inverter.SystemConfigPara()->setLimitPercent(getLimit());
72+
_inv->SystemConfigPara()->setLimitPercent(getLimit());
7373
} else {
74-
const uint16_t max_power = inverter.DevInfo()->getMaxPower();
74+
const uint16_t max_power = _inv->DevInfo()->getMaxPower();
7575
if (max_power > 0) {
76-
inverter.SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
76+
_inv->SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
7777
} else {
7878
// TODO(tbnobody): Not implemented yet because we only can publish the percentage value
7979
}
8080
}
81-
inverter.SystemConfigPara()->setLastUpdateCommand(millis());
82-
inverter.SystemConfigPara()->setLastLimitCommandSuccess(CMD_OK);
81+
_inv->SystemConfigPara()->setLastUpdateCommand(millis());
82+
_inv->SystemConfigPara()->setLastLimitCommandSuccess(CMD_OK);
8383
return true;
8484
}
8585

@@ -94,7 +94,7 @@ PowerLimitControlType ActivePowerControlCommand::getType()
9494
return (PowerLimitControlType)(((uint16_t)_payload[14] << 8) | _payload[15]);
9595
}
9696

97-
void ActivePowerControlCommand::gotTimeout(InverterAbstract& inverter)
97+
void ActivePowerControlCommand::gotTimeout()
9898
{
99-
inverter.SystemConfigPara()->setLastLimitCommandSuccess(CMD_NOK);
100-
}
99+
_inv->SystemConfigPara()->setLastLimitCommandSuccess(CMD_NOK);
100+
}

lib/Hoymiles/src/commands/ActivePowerControlCommand.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ typedef enum { // ToDo: to be verified by field tests
1212

1313
class ActivePowerControlCommand : public DevControlCommand {
1414
public:
15-
explicit ActivePowerControlCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
15+
explicit ActivePowerControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
1616

1717
virtual String getCommandName() const;
1818

19-
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
20-
virtual void gotTimeout(InverterAbstract& inverter);
19+
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
20+
virtual void gotTimeout();
2121

2222
void setActivePowerLimit(const float limit, const PowerLimitControlType type = RelativNonPersistent);
2323
float getLimit() const;
2424
PowerLimitControlType getType();
25-
};
25+
};

lib/Hoymiles/src/commands/AlarmDataCommand.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/*
3-
* Copyright (C) 2022-2023 Thomas Basler and others
3+
* Copyright (C) 2022-2024 Thomas Basler and others
44
*/
55

66
/*
@@ -23,8 +23,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap AlarmId Pa
2323
#include "AlarmDataCommand.h"
2424
#include "inverters/InverterAbstract.h"
2525

26-
AlarmDataCommand::AlarmDataCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
27-
: MultiDataCommand(target_address, router_address)
26+
AlarmDataCommand::AlarmDataCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
27+
: MultiDataCommand(inv, router_address)
2828
{
2929
setTime(time);
3030
setDataType(0x11);
@@ -36,28 +36,28 @@ String AlarmDataCommand::getCommandName() const
3636
return "AlarmData";
3737
}
3838

39-
bool AlarmDataCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
39+
bool AlarmDataCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
4040
{
4141
// Check CRC of whole payload
42-
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
42+
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
4343
return false;
4444
}
4545

4646
// Move all fragments into target buffer
4747
uint8_t offs = 0;
48-
inverter.EventLog()->beginAppendFragment();
49-
inverter.EventLog()->clearBuffer();
48+
_inv->EventLog()->beginAppendFragment();
49+
_inv->EventLog()->clearBuffer();
5050
for (uint8_t i = 0; i < max_fragment_id; i++) {
51-
inverter.EventLog()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
51+
_inv->EventLog()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
5252
offs += (fragment[i].len);
5353
}
54-
inverter.EventLog()->endAppendFragment();
55-
inverter.EventLog()->setLastAlarmRequestSuccess(CMD_OK);
56-
inverter.EventLog()->setLastUpdate(millis());
54+
_inv->EventLog()->endAppendFragment();
55+
_inv->EventLog()->setLastAlarmRequestSuccess(CMD_OK);
56+
_inv->EventLog()->setLastUpdate(millis());
5757
return true;
5858
}
5959

60-
void AlarmDataCommand::gotTimeout(InverterAbstract& inverter)
60+
void AlarmDataCommand::gotTimeout()
6161
{
62-
inverter.EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
63-
}
62+
_inv->EventLog()->setLastAlarmRequestSuccess(CMD_NOK);
63+
}

lib/Hoymiles/src/commands/AlarmDataCommand.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
class AlarmDataCommand : public MultiDataCommand {
77
public:
8-
explicit AlarmDataCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
8+
explicit AlarmDataCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
99

1010
virtual String getCommandName() const;
1111

12-
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
13-
virtual void gotTimeout(InverterAbstract& inverter);
14-
};
12+
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
13+
virtual void gotTimeout();
14+
};

lib/Hoymiles/src/commands/ChannelChangeCommand.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ID Target Addr Source Addr ? ? ? CH ? CRC8
1919
*/
2020
#include "ChannelChangeCommand.h"
2121

22-
ChannelChangeCommand::ChannelChangeCommand(const uint64_t target_address, const uint64_t router_address, const uint8_t channel)
23-
: CommandAbstract(target_address, router_address)
22+
ChannelChangeCommand::ChannelChangeCommand(InverterAbstract* inv, const uint64_t router_address, const uint8_t channel)
23+
: CommandAbstract(inv, router_address)
2424
{
2525
_payload[0] = 0x56;
2626
_payload[13] = 0x14;
@@ -67,7 +67,7 @@ void ChannelChangeCommand::setCountryMode(const CountryModeId_t mode)
6767
}
6868
}
6969

70-
bool ChannelChangeCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
70+
bool ChannelChangeCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
7171
{
7272
return true;
7373
}

lib/Hoymiles/src/commands/ChannelChangeCommand.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ChannelChangeCommand : public CommandAbstract {
88
public:
9-
explicit ChannelChangeCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const uint8_t channel = 0);
9+
explicit ChannelChangeCommand(InverterAbstract* inv, const uint64_t router_address = 0, const uint8_t channel = 0);
1010

1111
virtual String getCommandName() const;
1212

@@ -15,7 +15,7 @@ class ChannelChangeCommand : public CommandAbstract {
1515

1616
void setCountryMode(const CountryModeId_t mode);
1717

18-
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
18+
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
1919

2020
virtual uint8_t getMaxResendCount();
2121
};

lib/Hoymiles/src/commands/CommandAbstract.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/*
3-
* Copyright (C) 2022-2023 Thomas Basler and others
3+
* Copyright (C) 2022-2024 Thomas Basler and others
44
*/
55

66
/*
@@ -29,13 +29,16 @@ Source Address: 80 12 23 04
2929
#include "CommandAbstract.h"
3030
#include "crc.h"
3131
#include <string.h>
32+
#include "../inverters/InverterAbstract.h"
3233

33-
CommandAbstract::CommandAbstract(const uint64_t target_address, const uint64_t router_address)
34+
CommandAbstract::CommandAbstract(InverterAbstract* inv, const uint64_t router_address)
3435
{
3536
memset(_payload, 0, RF_LEN);
3637
_payload_size = 0;
3738

38-
setTargetAddress(target_address);
39+
_inv = inv;
40+
41+
setTargetAddress(_inv->serial());
3942
setRouterAddress(router_address);
4043
setSendCount(0);
4144
setTimeout(0);
@@ -122,7 +125,7 @@ void CommandAbstract::convertSerialToPacketId(uint8_t buffer[], const uint64_t s
122125
buffer[0] = s.b[3];
123126
}
124127

125-
void CommandAbstract::gotTimeout(InverterAbstract& inverter)
128+
void CommandAbstract::gotTimeout()
126129
{
127130
}
128131

0 commit comments

Comments
 (0)