Skip to content

Commit

Permalink
Feature: allow to reduce DTU poll interval to 100ms
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Dec 7, 2024
1 parent a37b012 commit 2e094ad
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +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 2
#define CONFIG_VERSION_ONBATTERY 3

#define WIFI_MAX_SSID_STRLEN 32
#define WIFI_MAX_PASSWORD_STRLEN 64
Expand Down
2 changes: 1 addition & 1 deletion include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
#define MQTT_CLEAN_SESSION true

#define DTU_SERIAL 0x99978563412U
#define DTU_POLL_INTERVAL 5U
#define DTU_POLL_INTERVAL 5000U
#define DTU_NRF_PA_LEVEL 0U
#define DTU_CMT_PA_LEVEL 0
#define DTU_CMT_FREQUENCY 865000000U
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void HoymilesClass::loop()
return;
}

if (millis() - _lastPoll > (_pollInterval * 1000)) {
if (millis() - _lastPoll > _pollInterval) {
static uint8_t inverterPos = 0;

std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos);
Expand Down
4 changes: 4 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,10 @@ void ConfigurationClass::migrateOnBattery()
config.PowerLimiter.ConductionLosses = doc["powerlimiter"]["solar_passthrough_losses"].as<uint8_t>();
}

if (config.Cfg.VersionOnBattery < 3) {
config.Dtu.PollInterval *= 1000; // new unit is milliseconds
}

f.close();

config.Cfg.VersionOnBattery = CONFIG_VERSION_ONBATTERY;
Expand Down
2 changes: 1 addition & 1 deletion src/MqttHandleHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void MqttHandleHassClass::publishInverterField(std::shared_ptr<InverterAbstract>
root["uniq_id"] = serial + "_ch" + chanNum + "_" + fieldName;

if (Configuration.get().Mqtt.Hass.Expire) {
root["exp_aft"] = Hoymiles.getNumInverters() * max<uint32_t>(Hoymiles.PollInterval(), Configuration.get().Mqtt.PublishInterval) * inv->getReachableThreshold();
root["exp_aft"] = Hoymiles.getNumInverters() * max<uint32_t>(Hoymiles.PollInterval()/1000U, Configuration.get().Mqtt.PublishInterval) * inv->getReachableThreshold();
}

publish(configTopic, root);
Expand Down
13 changes: 11 additions & 2 deletions webapp/src/views/DtuAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

<InputElement
:label="$t('dtuadmin.PollInterval')"
v-model="dtuConfigList.pollinterval"
v-model="pollIntervalSeconds"
type="number"
min="1"
min="0.1"
max="86400"
step="0.1"
:postfix="$t('dtuadmin.Seconds')"
/>

Expand Down Expand Up @@ -158,6 +159,14 @@ export default defineComponent({
this.getDtuConfig();
},
computed: {
pollIntervalSeconds: {
get(): number {
return this.dtuConfigList.pollinterval / 1000;
},
set(value: number) {
this.dtuConfigList.pollinterval = value * 1000;
},
},
cmtFrequencyText() {
return this.$t('dtuadmin.MHz', {
mhz: this.$n(this.dtuConfigList.cmt_frequency / 1000000, 'decimalTwoDigits'),
Expand Down

0 comments on commit 2e094ad

Please sign in to comment.