Compare commits

..
21 Commits
Author SHA1 Message Date
Yurii 131ad2fdfd refactor: after merge 2025-12-09 19:26:08 +03:00
Yurii 28099f2d07 Merge branch 'master' into new-equitherm 2025-12-09 19:19:30 +03:00
Yurii ec50d5ecbb flx: typo 2025-11-03 01:09:13 +03:00
Yurii 32e0a06c19 Merge branch 'master' into new-equitherm 2025-11-03 00:04:57 +03:00
Yurii ff89c6d478 chore: added additional description of the `T` parameter for Equitherm 2025-09-19 20:07:31 +03:00
Yurii d867c355ed style: HTML code formatting 2025-09-19 19:25:24 +03:00
Yurii e751c3aba0 fix: decimation for Equitherm chart fixed; chartjs updated 2025-09-19 02:09:12 +03:00
Yurii 30b55f1946 Merge branch 'master' into new-equitherm 2025-09-19 00:45:07 +03:00
Yurii 5544f43162 Merge branch 'master' into new-equitherm 2025-06-30 02:42:33 +03:00
Yurii 06c2ddcf96 Merge branch 'master' into new-equitherm 2025-05-21 01:20:55 +03:00
Yurii 0bb05006f4 Merge branch 'master' into new-equitherm 2025-05-19 23:45:13 +03:00
Yurii 5046bc0e8f Merge branch 'master' into new-equitherm 2025-05-19 22:49:09 +03:00
P43YM 0d3adad446 refactor: added notes for equitherm parameters 2025-03-18 09:38:09 +03:00
Yurii 587678f184 Merge branch 'master' into new-equitherm 2025-03-06 04:52:12 +03:00
Yurii 72235286c0 chore: resolve conflicts 2025-03-06 04:50:02 +03:00
Yurii ee868b22ce chore: remove unused files 2025-03-04 21:31:44 +03:00
Yurii 8046a7e13f refactor: cosmetic changes 2025-03-03 04:03:08 +03:00
Yurii 0ec1fc5f24 chore: fix typo 2025-03-03 02:26:09 +03:00
Yurii 061136b13e refactor: cosmetic changes (equitherm chart) 2025-03-03 02:05:33 +03:00
Yurii 3e61dabeab refactor: refactoring after #144 2025-03-02 22:44:53 +03:00
P43YM e5f4281d4c feat: new equitherm algorithm and chart for it (#144) 2025-02-28 23:21:55 +03:00
38 changed files with 733 additions and 2506 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v11
- uses: actions/stale@v10
with:
stale-issue-message: >
This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.
+4 -7
View File
@@ -1,5 +1,5 @@
# Blueprint for reporting indoor/outdoor temperature to OpenTherm Gateway from any home assistant sensor
# Updated: 26.01.2026
# Updated: 03.09.2024
blueprint:
name: Report temp to OpenTherm Gateway
@@ -15,6 +15,7 @@ blueprint:
multiple: false
filter:
- domain: sensor
device_class: temperature
target_entity:
name: Target entity
description: "Usually ``number.opentherm_indoor_temp`` or ``number.opentherm_outdoor_temp``"
@@ -37,12 +38,8 @@ condition:
value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action:
- if:
- condition: or
conditions:
- condition: template
value_template: "{{ (states(source_entity)|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.01 }}"
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp(states[target_entity].last_updated)) | int(0) > 300 }}"
- condition: template
value_template: "{{ (states(source_entity)|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.01 }}"
then:
- service: number.set_value
data:
@@ -1,5 +1,5 @@
# Blueprint for reporting temperature to OpenTherm Gateway from home assistant weather integration
# Updated: 26.01.2026
# Updated: 03.09.2024
blueprint:
name: Report temp to OpenTherm Gateway from Weather
@@ -37,12 +37,8 @@ condition:
value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action:
- if:
- condition: or
conditions:
- condition: template
value_template: "{{ (state_attr(source_entity, 'temperature')|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.1 }}"
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp(states[target_entity].last_updated)) | int(0) > 300 }}"
- condition: template
value_template: "{{ (state_attr(source_entity, 'temperature')|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.1 }}"
then:
- service: number.set_value
data:
+31 -70
View File
@@ -70,89 +70,50 @@ public:
}
}
inline auto sendBoilerReset() {
return this->sendRequestCode(1);
}
inline auto sendServiceReset() {
return this->sendRequestCode(10);
}
inline auto sendWaterFilling() {
return this->sendRequestCode(2);
}
bool sendRequestCode(const uint8_t requestCode) {
bool sendBoilerReset() {
unsigned int data = 1;
data <<= 8;
unsigned long response = this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest,
static_cast<unsigned int>(requestCode) << 8
data
));
if (!isValidResponse(response) || !isValidResponseId(response, OpenThermMessageID::RemoteRequest)) {
return false;
}
const uint8_t responseRequestCode = (response & 0xFFFF) >> 8;
const uint8_t responseCode = response & 0xFF;
if (responseRequestCode != requestCode || responseCode < 128) {
return false;
}
// reset
this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest,
0u << 8
));
return true;
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
}
bool getStr(OpenThermMessageID id, char* buffer, uint16_t length = 50) {
if (buffer == nullptr || length == 0) {
return false;
}
bool sendServiceReset() {
unsigned int data = 10;
data <<= 8;
unsigned long response = this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest,
data
));
unsigned long response;
uint8_t index = 0;
uint8_t maxIndex = 255;
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
}
while (index <= maxIndex && index < length) {
response = this->sendRequest(buildRequest(
OpenThermMessageType::READ_DATA,
id,
static_cast<unsigned int>(index) << 8
));
bool sendWaterFilling() {
unsigned int data = 2;
data <<= 8;
unsigned long response = this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest,
data
));
if (!isValidResponse(response) || !isValidResponseId(response, id)) {
break;
}
const uint8_t character = response & 0xFF;
if (character == 0) {
break;
}
if (index == 0) {
maxIndex = (response & 0xFFFF) >> 8;
}
buffer[index++] = static_cast<char>(character);
}
buffer[index] = '\0';
return index > 0;
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
}
static bool isCh2Active(unsigned long response) {
return response & 0x20;
return response & 0x20;
}
static bool isValidResponseId(unsigned long response, OpenThermMessageID id) {
const uint8_t responseId = (response >> 16) & 0xFF;
uint8_t responseId = (response >> 16) & 0xFF;
return static_cast<uint8_t>(id) == responseId;
return (uint8_t)id == responseId;
}
static uint8_t getResponseMessageTypeId(unsigned long response) {
@@ -163,10 +124,10 @@ public:
uint8_t msgType = getResponseMessageTypeId(response);
switch (msgType) {
case static_cast<uint8_t>(OpenThermMessageType::READ_ACK):
case static_cast<uint8_t>(OpenThermMessageType::WRITE_ACK):
case static_cast<uint8_t>(OpenThermMessageType::DATA_INVALID):
case static_cast<uint8_t>(OpenThermMessageType::UNKNOWN_DATA_ID):
case (uint8_t) OpenThermMessageType::READ_ACK:
case (uint8_t) OpenThermMessageType::WRITE_ACK:
case (uint8_t) OpenThermMessageType::DATA_INVALID:
case (uint8_t) OpenThermMessageType::UNKNOWN_DATA_ID:
return CustomOpenTherm::messageTypeToString(
static_cast<OpenThermMessageType>(msgType)
);
-113
View File
@@ -1,113 +0,0 @@
#pragma once
#include <NetworkUplink.h>
#include <NetworkWifi.h>
namespace NetworkUtils {
/**
* @brief Fallback AP: the setup network, raised when the station cannot carry the uplink
*/
class ApUplink : public NetworkUplink {
public:
ApUplink(UplinkContext* context, WifiUplink* wifi) : NetworkUplink(context), wifi(wifi) {}
void loop() override {
// the association carries the traffic again: retire the AP once it is stable and idle
if (this->wifi->isActive()) {
if (
this->isEnabled() && !this->hasClients()
&& millis() - this->wifi->getConnectedTime() >= this->retireDelay
) {
Log.sinfoln(FPSTR(L_NETWORK), F("Stop AP because STA connected"));
this->stop();
}
return;
}
if (this->isEnabled()) {
this->attempt.disarm();
return;
}
// a failed softAP() retries once the window runs out
if (this->attempt.isPending()) {
return;
}
this->start();
}
/**
* @brief The AP interface is up, whether or not anyone is on it
*
* A parked radio means the AP is not carrying anything, whatever the mode still says.
*/
bool isActive() override {
return this->isEnabled() && !this->wifi->isSuspended();
}
bool isEnabled() {
return (WiFi.getMode() & WIFI_AP) != 0;
}
bool hasClients() {
if (!this->isEnabled()) {
return false;
}
return WiFi.softAPgetStationNum() > 0;
}
void start() {
Log.sinfoln(
FPSTR(L_NETWORK),
this->wifi->hasCredentials()
? F("Disconnected for a long time, start AP")
: F("No STA credentials, start AP")
);
WiFi.mode(WIFI_AP_STA);
this->context->delayCallback(250);
if (!WiFi.softAP(this->context->apName, this->context->apPassword, this->context->apChannel)) {
this->attempt.arm(this->startTimeout);
}
}
void stop() {
WiFi.mode(WIFI_STA);
this->attempt.disarm();
}
IPAddress localIP() override {
return WiFi.softAPIP();
}
IPAddress subnetMask() override {
#ifdef ARDUINO_ARCH_ESP32
return WiFi.softAPSubnetMask();
#else
return IPAddress(255, 255, 255, 0);
#endif
}
IPAddress gatewayIP() override {
return WiFi.softAPIP();
}
IPAddress dnsIP() override {
return WiFi.softAPIP();
}
String macAddress() override {
return WiFi.softAPmacAddress();
}
protected:
const unsigned long retireDelay = 15000;
const unsigned long startTimeout = 5000;
WifiUplink* wifi;
};
}
-1
View File
@@ -1,4 +1,3 @@
#pragma once
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h>
#include "lwip/etharp.h"
-269
View File
@@ -1,269 +0,0 @@
#pragma once
#include <NetworkUplink.h>
#ifdef NETWORK_HAS_ETHERNET
#include <ETH.h>
#endif
namespace NetworkUtils {
/**
* @brief Ethernet uplink: the W5500 driver, its cable and its DHCP lease
*/
class EthernetUplink : public NetworkUplink {
public:
explicit EthernetUplink(UplinkContext* context) : NetworkUplink(context) {}
void loop() override {
#ifdef NETWORK_HAS_ETHERNET
if (this->restartFlag) {
this->restartFlag = false;
// The W5500 driver cannot be re-initialized in place: Arduino's ETH.end() leaves
// the SPI bus allocated, so a wiring change only takes effect after a restart.
if (this->started) {
Log.swarningln(FPSTR(L_NETWORK), F("Ethernet: settings changed, restart required to apply them"));
}
}
if (!this->enabled || !this->hasPins()) {
if (this->active || this->linkUp) {
this->active = false;
this->linkUp = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: disabled, handing the uplink back to WiFi"));
}
this->attempt.disarm();
return;
}
if (!this->started) {
if (this->startUnavailable) {
return;
}
Log.sinfoln(
FPSTR(L_NETWORK),
F("Ethernet: init W5500 (CS: %u, IRQ: %u, RST: %u, CLK: %u, MISO: %u, MOSI: %u)"),
this->cs,
this->irq,
this->rst,
this->clk,
this->miso,
this->mosi
);
if (!ETH.begin(ETH_PHY_W5500, 1, this->cs, this->irq, this->rst, SPI2_HOST, this->clk, this->miso, this->mosi, 12)) {
// A failed init leaves the SPI bus allocated, so retrying cannot succeed;
// wait for a restart instead of flapping.
this->startUnavailable = true;
this->attempt.disarm();
Log.serrorln(FPSTR(L_NETWORK), F("Ethernet: W5500 init failed, check the wiring and restart"));
return;
}
this->started = true;
this->running = true;
this->prevLinkCheck = 0;
this->attempt.arm(this->linkGrace);
if (!this->context->useDhcp) {
ETH.config(this->context->staticIp, this->context->staticGateway, this->context->staticSubnet, this->context->staticDns);
}
if (strlen(this->context->hostname) && UplinkContext::isHostnameValid(this->context->hostname)) {
ETH.setHostname(this->context->hostname);
}
return;
}
if (millis() - this->prevLinkCheck < this->linkCheckInterval) {
return;
}
this->prevLinkCheck = millis();
if (!ETH.linkUp()) {
if (this->linkUp) {
this->linkUp = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: cable disconnected"));
}
this->attempt.disarm();
if (this->active) {
this->active = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: link lost, falling back to WiFi"));
this->context->delayCallback(250);
}
return;
}
if (!this->linkUp) {
this->linkUp = true;
this->attempt.arm(this->leaseGrace);
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: cable connected"));
}
if (!ETH.connected() || this->active) {
return;
}
this->active = true;
this->attempt.disarm();
Log.sinfoln(
FPSTR(L_NETWORK),
F("Ethernet: using ethernet instead of WiFi, IP: %s, link: %u Mbps, duplex: %u"),
ETH.localIP().toString().c_str(),
ETH.linkSpeed(),
ETH.fullDuplex() ? 1 : 0
);
#endif
}
/**
* @brief Ethernet carries the uplink: cable plugged in and DHCP lease obtained
*/
bool isActive() override {
#ifdef NETWORK_HAS_ETHERNET
if (!this->enabled || !this->started) {
return false;
}
return ETH.linkUp() && ETH.connected();
#else
return false;
#endif
}
/**
* @brief Enable/disable the interface, taking the driver in and out of the FSM
*/
void setEnabled(bool value) {
this->enabled = value;
#ifdef NETWORK_HAS_ETHERNET
// The driver stays installed: stop() only takes the link and the netif down, while the
// SPI bus, the MAC and the netif itself stay allocated, so start() resumes without a restart
if (this->started && ETH.handle() != nullptr && value != this->running) {
esp_err_t ret = value ? esp_eth_start(ETH.handle()) : esp_eth_stop(ETH.handle());
if (ret == ESP_OK) {
this->running = value;
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Ethernet: driver %s failed"), value ? "start" : "stop");
}
}
#endif
}
/**
* @brief Configure the W5500 wiring. Use GPIO_IS_NOT_CONFIGURED to disable
*/
void setPins(uint8_t clk, uint8_t mosi, uint8_t miso, uint8_t cs, uint8_t irq, uint8_t rst) {
if (
clk != this->clk || mosi != this->mosi || miso != this->miso
|| cs != this->cs || irq != this->irq || rst != this->rst
) {
this->markSettingsChanged();
}
this->clk = clk;
this->mosi = mosi;
this->miso = miso;
this->cs = cs;
this->irq = irq;
this->rst = rst;
}
/**
* @brief A setting the driver reads changed: applying it needs a restart
*/
void markSettingsChanged() {
if (this->started) {
this->restartFlag = true;
}
}
bool hasPins() {
return this->clk != GPIO_IS_NOT_CONFIGURED
&& this->mosi != GPIO_IS_NOT_CONFIGURED
&& this->miso != GPIO_IS_NOT_CONFIGURED
&& this->cs != GPIO_IS_NOT_CONFIGURED
&& this->irq != GPIO_IS_NOT_CONFIGURED
&& this->rst != GPIO_IS_NOT_CONFIGURED;
}
IPAddress localIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.localIP();
#else
return IPAddress();
#endif
}
IPAddress subnetMask() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.subnetMask();
#else
return IPAddress();
#endif
}
IPAddress gatewayIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.gatewayIP();
#else
return IPAddress();
#endif
}
IPAddress dnsIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.dnsIP();
#else
return IPAddress();
#endif
}
String macAddress() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.macAddress();
#else
return String();
#endif
}
protected:
const unsigned long linkCheckInterval = 1000;
const unsigned long linkGrace = 5000;
const unsigned long leaseGrace = 20000;
bool enabled = false;
bool started = false;
bool running = false;
bool active = false;
bool linkUp = false;
bool restartFlag = false;
bool startUnavailable = false;
uint8_t clk = GPIO_IS_NOT_CONFIGURED;
uint8_t mosi = GPIO_IS_NOT_CONFIGURED;
uint8_t miso = GPIO_IS_NOT_CONFIGURED;
uint8_t cs = GPIO_IS_NOT_CONFIGURED;
uint8_t irq = GPIO_IS_NOT_CONFIGURED;
uint8_t rst = GPIO_IS_NOT_CONFIGURED;
unsigned long prevLinkCheck = 0;
};
}
+362 -200
View File
@@ -1,258 +1,380 @@
#pragma once
#include <NetworkAp.h>
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h>
#include "lwip/etharp.h"
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#include <esp_wifi.h>
#endif
#include <NetworkConnection.h>
#include <NetworkEthernet.h>
#include <NetworkUplink.h>
#include <NetworkWifi.h>
namespace NetworkUtils {
/**
* @brief Picks the uplink that carries the traffic and drives it
*
* The hierarchy is ethernet > WiFi > fallback AP: the first interface able to do it owns the
* pass, and every status getter reads that decision instead of re-testing the interfaces.
*/
class NetworkMgr {
public:
NetworkMgr() : wifi(&this->context), ap(&this->context, &this->wifi), ethernet(&this->context) {
NetworkConnection::setup(this->context.useDhcp);
this->wifi.resetWifi();
typedef std::function<void()> YieldCallback;
typedef std::function<void(unsigned int)> DelayCallback;
NetworkMgr() {
NetworkConnection::setup(this->useDhcp);
this->resetWifi();
}
NetworkMgr* setYieldCallback(YieldCallback callback = nullptr) {
this->context.yieldCallback = callback;
this->yieldCallback = callback;
return this;
}
NetworkMgr* setDelayCallback(DelayCallback callback = nullptr) {
this->context.delayCallback = callback;
this->delayCallback = callback;
return this;
}
NetworkMgr* setHostname(const char* value) {
this->context.hostname = value;
this->hostname = value;
return this;
}
NetworkMgr* setApCredentials(const char* ssid, const char* password = nullptr, uint8_t channel = 0) {
this->context.apName = ssid;
this->context.apPassword = password;
this->context.apChannel = channel;
this->apName = ssid;
this->apPassword = password;
this->apChannel = channel;
return this;
}
NetworkMgr* setStaCredentials(const char* ssid = nullptr, const char* password = nullptr, uint8_t channel = 0) {
this->context.staSsid = ssid;
this->context.staPassword = password;
this->context.staChannel = channel;
this->staSsid = ssid;
this->staPassword = password;
this->staChannel = channel;
return this;
}
NetworkMgr* setUseDhcp(bool value) {
if (value != this->context.useDhcp) {
this->ethernet.markSettingsChanged();
}
this->context.useDhcp = value;
NetworkConnection::setup(this->context.useDhcp);
this->useDhcp = value;
NetworkConnection::setup(this->useDhcp);
return this;
}
NetworkMgr* setStaticConfig(const char* ip, const char* gateway, const char* subnet, const char* dns) {
IPAddress valueIp, valueGateway, valueSubnet, valueDns;
valueIp.fromString(ip);
valueGateway.fromString(gateway);
valueSubnet.fromString(subnet);
valueDns.fromString(dns);
if (
valueIp != this->context.staticIp || valueGateway != this->context.staticGateway
|| valueSubnet != this->context.staticSubnet || valueDns != this->context.staticDns
) {
this->ethernet.markSettingsChanged();
}
this->context.staticIp = valueIp;
this->context.staticGateway = valueGateway;
this->context.staticSubnet = valueSubnet;
this->context.staticDns = valueDns;
this->staticIp.fromString(ip);
this->staticGateway.fromString(gateway);
this->staticSubnet.fromString(subnet);
this->staticDns.fromString(dns);
return this;
}
NetworkMgr* setStaticConfig(IPAddress& ip, IPAddress& gateway, IPAddress& subnet, IPAddress& dns) {
if (
ip != this->context.staticIp || gateway != this->context.staticGateway
|| subnet != this->context.staticSubnet || dns != this->context.staticDns
) {
this->ethernet.markSettingsChanged();
}
this->context.staticIp = ip;
this->context.staticGateway = gateway;
this->context.staticSubnet = subnet;
this->context.staticDns = dns;
this->staticIp = ip;
this->staticGateway = gateway;
this->staticSubnet = subnet;
this->staticDns = dns;
return this;
}
/**
* @brief Enable/disable the ethernet interface (W5500 over SPI)
*/
NetworkMgr* setEthernet(bool enabled) {
this->ethernet.setEnabled(enabled);
return this;
}
/**
* @brief Configure W5500 wiring. Use GPIO_IS_NOT_CONFIGURED to disable
*/
NetworkMgr* setEthernetPins(uint8_t clk, uint8_t mosi, uint8_t miso, uint8_t cs, uint8_t irq, uint8_t rst) {
this->ethernet.setPins(clk, mosi, miso, cs, irq, rst);
return this;
}
/**
* @brief Uplinks in the order they are tried: ethernet, WiFi, fallback AP
*/
enum class Uplink : uint8_t { None = 0, Ap, Wifi, Ethernet };
/**
* @brief The uplink that currently carries traffic
*
* Always the first interface in the hierarchy that can do it, so every consumer reads the
* same decision instead of re-testing ethernet and overriding the WiFi answer.
*/
Uplink getUplink() {
if (this->ethernet.isActive()) {
return Uplink::Ethernet;
}
if (this->wifi.isActive()) {
return Uplink::Wifi;
}
if (this->ap.isActive()) {
return Uplink::Ap;
}
return Uplink::None;
bool hasStaCredentials() {
return this->staSsid != nullptr;
}
bool isConnected() {
return this->getUplink() >= Uplink::Wifi;
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTED;
}
/**
* @brief WiFi signal quality in percent, 0 when WiFi is not carrying the uplink
*/
uint8_t getSignalQuality() {
return this->getUplink() == Uplink::Wifi ? rssiToSignalQuality(this->wifi.rssi()) : 0;
bool isConnecting() {
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTING;
}
/**
* @return "ethernet", "wifi", "wifi-ap" or "none"
*/
const char* getConnectionType() {
return uplinkName(this->getUplink());
}
/**
* @brief Uplink token, already in locale-key shape
*/
static const char* uplinkName(Uplink uplink) {
switch (uplink) {
case Uplink::Ethernet:
return "ethernet";
case Uplink::Wifi:
return "wifi";
case Uplink::Ap:
return "wifi-ap";
default:
return "none";
}
bool isStaEnabled() {
return (WiFi.getMode() & WIFI_STA) != 0;
}
bool isApEnabled() {
return this->ap.isEnabled();
return (WiFi.getMode() & WIFI_AP) != 0;
}
bool hasApClients() {
if (!this->isApEnabled()) {
return false;
}
return WiFi.softAPgetStationNum() > 0;
}
short int getRssi() {
return this->station()->rssi();
return WiFi.RSSI();
}
IPAddress getApIp() {
return this->ap.localIP();
return WiFi.softAPIP();
}
IPAddress getStaIp() {
return this->station()->localIP();
return WiFi.localIP();
}
IPAddress getStaSubnet() {
return this->station()->subnetMask();
return WiFi.subnetMask();
}
IPAddress getStaGateway() {
return this->station()->gatewayIP();
return WiFi.gatewayIP();
}
IPAddress getStaDns() {
return this->station()->dnsIP();
return WiFi.dnsIP();
}
String getStaMac() {
return this->station()->macAddress();
return WiFi.macAddress();
}
const char* getStaSsid() {
return this->context.staSsid;
return this->staSsid;
}
const char* getStaPassword() {
return this->staPassword;
}
uint8_t getStaChannel() {
return this->context.staChannel;
return this->staChannel;
}
bool resetWifi() {
// set policy manual for work 13 ch
{
#ifdef ARDUINO_ARCH_ESP8266
wifi_country_t country = {"JP", 1, 14, WIFI_COUNTRY_POLICY_MANUAL};
wifi_set_country(&country);
#elif defined(ARDUINO_ARCH_ESP32)
const wifi_country_t country = {"JP", 1, 14, CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER, WIFI_COUNTRY_POLICY_MANUAL};
esp_wifi_set_country(&country);
#endif
}
WiFi.persistent(false);
#if !defined(ESP_ARDUINO_VERSION_MAJOR) || ESP_ARDUINO_VERSION_MAJOR < 3
WiFi.setAutoConnect(false);
#endif
WiFi.setAutoReconnect(false);
#ifdef ARDUINO_ARCH_ESP8266
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#elif defined(ARDUINO_ARCH_ESP32)
WiFi.setSleep(USE_BLE ? WIFI_PS_MIN_MODEM : WIFI_PS_NONE);
#endif
WiFi.softAPdisconnect();
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_softap_dhcps_status() == DHCP_STARTED) {
wifi_softap_dhcps_stop();
}*/
#endif
WiFi.disconnect(false, true);
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}*/
wifi_station_dhcpc_set_maxtry(5);
#endif
#if defined(ARDUINO_ARCH_ESP32) && ESP_ARDUINO_VERSION_MAJOR < 3
// Nothing. Because memory leaks when turn off WiFi on ESP32 SDK < 3.0.0
return true;
#else
return WiFi.mode(WIFI_OFF);
#endif
}
void reconnect() {
this->wifi.reconnect();
this->reconnectFlag = true;
}
bool connect(bool force = false, unsigned int timeout = 1000u) {
if (this->isConnected() && !force) {
return true;
}
if (force && !this->isApEnabled()) {
this->resetWifi();
NetworkConnection::reset();
} else {
/*#ifdef ARDUINO_ARCH_ESP8266
if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}
#endif*/
this->disconnect();
}
if (!this->hasStaCredentials()) {
return false;
}
this->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP32
if (this->setWifiHostname(this->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->hostname);
}
#endif
if (!WiFi.mode((WiFiMode_t)(WiFi.getMode() | WIFI_STA))) {
return false;
}
this->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP8266
if (this->setWifiHostname(this->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->hostname);
}
this->delayCallback(250);
#endif
#ifdef ARDUINO_ARCH_ESP32
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
#endif
if (!this->useDhcp) {
WiFi.begin(this->staSsid, this->staPassword, this->staChannel, nullptr, false);
WiFi.config(this->staticIp, this->staticGateway, this->staticSubnet, this->staticDns);
WiFi.reconnect();
} else {
WiFi.begin(this->staSsid, this->staPassword, this->staChannel, nullptr, true);
}
unsigned long beginConnectionTime = millis();
while (millis() - beginConnectionTime < timeout) {
this->delayCallback(100);
NetworkConnection::Status status = NetworkConnection::getStatus();
if (status != NetworkConnection::Status::CONNECTING && status != NetworkConnection::Status::NONE) {
return status == NetworkConnection::Status::CONNECTED;
}
}
return false;
}
void disconnect() {
#ifdef ARDUINO_ARCH_ESP32
WiFi.disconnectAsync(false, true);
const unsigned long start = millis();
while (WiFi.isConnected() && (millis() - start) < 5000) {
this->delayCallback(100);
}
#else
WiFi.disconnect(false, true);
#endif
}
void loop() {
// The top of the hierarchy polls every pass so it can take the uplink whenever it can
this->ethernet.loop();
if (this->reconnectFlag) {
this->delayCallback(5000);
this->trackUplink();
this->updateWifiRadio();
Log.sinfoln(FPSTR(L_NETWORK), F("Reconnecting..."));
this->reconnectFlag = false;
this->disconnect();
NetworkConnection::reset();
this->delayCallback(1000);
if (this->getUplink() == Uplink::Ethernet) {
return;
} else if (this->isConnected() && !this->hasStaCredentials()) {
Log.sinfoln(FPSTR(L_NETWORK), F("Reset"));
this->resetWifi();
NetworkConnection::reset();
this->delayCallback(1000);
} else if (this->isConnected()) {
if (!this->connected) {
this->connectedTime = millis();
this->connected = true;
Log.sinfoln(
FPSTR(L_NETWORK),
F("Connected, downtime: %lu s., IP: %s, RSSI: %hhd"),
(millis() - this->disconnectedTime) / 1000,
WiFi.localIP().toString().c_str(),
WiFi.RSSI()
);
}
if (this->isApEnabled() && millis() - this->connectedTime > this->reconnectInterval && !this->hasApClients()) {
Log.sinfoln(FPSTR(L_NETWORK), F("Stop AP because STA connected"));
WiFi.mode(WIFI_STA);
return;
}
#ifdef ARDUINO_ARCH_ESP8266
if (millis() - this->prevArpGratuitous > 60000) {
this->stationKeepAliveNow();
this->prevArpGratuitous = millis();
}
#endif
} else {
if (this->connected) {
this->disconnectedTime = millis();
this->connected = false;
Log.sinfoln(
FPSTR(L_NETWORK),
F("Disconnected, reason: %d, uptime: %lu s."),
NetworkConnection::getDisconnectReason(),
(millis() - this->connectedTime) / 1000
);
}
if (!this->hasStaCredentials() && !this->isApEnabled()) {
Log.sinfoln(FPSTR(L_NETWORK), F("No STA credentials, start AP"));
WiFi.mode(WIFI_AP_STA);
this->delayCallback(250);
WiFi.softAP(this->apName, this->apPassword, this->apChannel);
} else if (!this->isApEnabled() && millis() - this->disconnectedTime > this->failedConnectTimeout) {
Log.sinfoln(FPSTR(L_NETWORK), F("Disconnected for a long time, start AP"));
WiFi.mode(WIFI_AP_STA);
this->delayCallback(250);
WiFi.softAP(this->apName, this->apPassword, this->apChannel);
} else if (this->isConnecting() && millis() - this->prevReconnectingTime > this->resetConnectionTimeout) {
Log.swarningln(FPSTR(L_NETWORK), F("Connection timeout, reset wifi..."));
this->resetWifi();
NetworkConnection::reset();
this->delayCallback(250);
} else if (!this->isConnecting() && this->hasStaCredentials() && (!this->prevReconnectingTime || millis() - this->prevReconnectingTime > this->reconnectInterval)) {
Log.sinfoln(FPSTR(L_NETWORK), F("Try connect..."));
NetworkConnection::reset();
if (!this->connect(true, this->connectionTimeout)) {
Log.straceln(FPSTR(L_NETWORK), F("Connection failed. Status: %d, reason: %d, raw reason: %d"), NetworkConnection::getStatus(), NetworkConnection::getDisconnectReason(), NetworkConnection::rawDisconnectReason);
}
this->prevReconnectingTime = millis();
}
}
// a pending ethernet attempt holds the hierarchy: nothing below it starts until it resolves
if (this->ethernet.isPending() && !this->wifi.isActive() && !this->ap.isActive()) {
return;
}
this->wifi.loop();
// the ladder only reaches the AP once the station is out of the running
if (!this->wifi.isActive() && this->wifi.isPending()) {
return;
}
this->ap.loop();
}
static uint8_t rssiToSignalQuality(short int rssi) {
@@ -260,55 +382,95 @@ namespace NetworkUtils {
}
protected:
UplinkContext context;
WifiUplink wifi;
ApUplink ap;
EthernetUplink ethernet;
const unsigned int reconnectInterval = 15000;
const unsigned int failedConnectTimeout = 185000;
const unsigned int connectionTimeout = 10000;
const unsigned int resetConnectionTimeout = 90000;
Uplink uplink = Uplink::None;
YieldCallback yieldCallback = []() {
::yield();
};
DelayCallback delayCallback = [](unsigned int time) {
::delay(time);
};
/**
* @brief The interface holding the station address: the wired one while it carries the
* uplink, the station otherwise
*/
NetworkUplink* station() {
if (this->getUplink() == Uplink::Ethernet) {
return &this->ethernet;
const char* hostname = "esp";
const char* apName = "ESP";
const char* apPassword = nullptr;
uint8_t apChannel = 1;
const char* staSsid = nullptr;
const char* staPassword = nullptr;
uint8_t staChannel = 0;
bool useDhcp = true;
IPAddress staticIp;
IPAddress staticGateway;
IPAddress staticSubnet;
IPAddress staticDns;
bool connected = false;
bool reconnectFlag = false;
unsigned long prevArpGratuitous = 0;
unsigned long prevReconnectingTime = 0;
unsigned long connectedTime = 0;
unsigned long disconnectedTime = 0;
bool setWifiHostname(const char* hostname) {
if (!this->isHostnameValid(hostname)) {
return false;
}
return &this->wifi;
}
/**
* @brief Notice an uplink change so the hierarchy is walked from the top again
*/
void trackUplink() {
const Uplink current = this->getUplink();
if (current == this->uplink) {
return;
if (strcmp(WiFi.getHostname(), hostname) == 0) {
return true;
}
Log.sinfoln(FPSTR(L_NETWORK), F("Uplink: %s -> %s"), uplinkName(this->uplink), uplinkName(current));
this->uplink = current;
return WiFi.setHostname(hostname);
}
#ifdef ARDUINO_ARCH_ESP8266
/**
* @brief Keep the WiFi radio in step with the uplink
* @brief
* https://github.com/arendst/Tasmota/blob/e6515883f0ee5451931b6280ff847b117de5a231/tasmota/tasmota_support/support_wifi.ino#L1196
*/
static void stationKeepAliveNow(void) {
for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
if (
(interface->flags & NETIF_FLAG_LINK_UP)
&& (interface->flags & NETIF_FLAG_UP)
&& interface->num == STATION_IF
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
) {
etharp_gratuitous(interface);
break;
}
}
}
#endif
/**
* @brief check RFC compliance
*
* WiFi is only in service while it carries the traffic. The AP is for first configuration:
* once a cable carries the uplink the radio goes off, and if that uplink never comes up the
* ladder falls back to the AP again on its own.
* @param value
* @return true
* @return false
*/
void updateWifiRadio() {
if (this->ethernet.isActive()) {
this->wifi.suspend();
return;
static bool isHostnameValid(const char* value) {
size_t len = strlen(value);
if (len > 24) {
return false;
} else if (value[len - 1] == '-') {
return false;
}
this->wifi.resume();
for (size_t i = 0; i < len; i++) {
if (!isalnum(value[i]) && value[i] != '-') {
return false;
}
}
return true;
}
};
}
}
-143
View File
@@ -1,143 +0,0 @@
#pragma once
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h>
#include "lwip/etharp.h"
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#include <esp_wifi.h>
#endif
// W5500 support needs both the ESP32 core (for ETH.h) and the per-env USE_ETHERNET flag.
// USE_ETHERNET defaults to false in defines.h, so this must be a value test, not #ifdef.
#if USE_ETHERNET && defined(ARDUINO_ARCH_ESP32)
#define NETWORK_HAS_ETHERNET
#endif
namespace NetworkUtils {
typedef std::function<void()> YieldCallback;
typedef std::function<void(unsigned int)> DelayCallback;
/**
* @brief Settings and callbacks every uplink reads
*/
struct UplinkContext {
const char* hostname = "esp";
const char* staSsid = nullptr;
const char* staPassword = nullptr;
uint8_t staChannel = 0;
const char* apName = "ESP";
const char* apPassword = nullptr;
uint8_t apChannel = 1;
bool useDhcp = true;
IPAddress staticIp;
IPAddress staticGateway;
IPAddress staticSubnet;
IPAddress staticDns;
YieldCallback yieldCallback = []() {
::yield();
};
DelayCallback delayCallback = [](unsigned int time) {
::delay(time);
};
/**
* @brief check RFC compliance
*
* @param value
* @return true
* @return false
*/
static bool isHostnameValid(const char* value) {
size_t len = strlen(value);
if (len > 24) {
return false;
} else if (value[len - 1] == '-') {
return false;
}
for (size_t i = 0; i < len; i++) {
if (!isalnum(value[i]) && value[i] != '-') {
return false;
}
}
return true;
}
};
/**
* @brief How long an uplink may still take the pass
*
* Armed when the uplink starts trying, disarmed when it resolves either way. A window that has
* run out means the uplink gave up, which lets the class below it take over.
*/
class UplinkAttempt {
public:
void arm(unsigned long window) {
this->start = millis() ? millis() : 1;
this->window = window;
}
void disarm() {
this->start = 0;
this->window = 0;
}
bool isArmed() const {
return this->window > 0;
}
bool isPending() const {
return this->window > 0 && (millis() - this->start) < this->window;
}
protected:
unsigned long start = 0;
unsigned long window = 0;
};
/**
* @brief One interface that is able to carry the uplink
*/
class NetworkUplink {
public:
explicit NetworkUplink(UplinkContext* context) : context(context) {}
virtual ~NetworkUplink() {}
/**
* @brief Run one pass of this interface's state machine
*/
virtual void loop() = 0;
/**
* @brief The interface is able to carry traffic right now
*/
virtual bool isActive() = 0;
/**
* @brief The interface may still become active, so nothing below it should start
*/
virtual bool isPending() {
return !this->isActive() && this->attempt.isPending();
}
virtual IPAddress localIP() = 0;
virtual IPAddress subnetMask() = 0;
virtual IPAddress gatewayIP() = 0;
virtual IPAddress dnsIP() = 0;
virtual String macAddress() = 0;
virtual short int rssi() {
return 0;
}
protected:
UplinkContext* context;
UplinkAttempt attempt;
};
}
-431
View File
@@ -1,431 +0,0 @@
#pragma once
#include <NetworkConnection.h>
#include <NetworkUplink.h>
namespace NetworkUtils {
/**
* @brief WiFi uplink: the station association, its radio, and the fallback AP
*/
class WifiUplink : public NetworkUplink {
public:
explicit WifiUplink(UplinkContext* context) : NetworkUplink(context) {}
void loop() override {
if (this->reconnectFlag) {
this->context->delayCallback(5000);
Log.sinfoln(FPSTR(L_NETWORK), F("Reconnecting..."));
this->reconnectFlag = false;
this->disconnect();
NetworkConnection::reset();
this->context->delayCallback(1000);
return;
}
if (this->isAssociated() && !this->hasCredentials()) {
Log.sinfoln(FPSTR(L_NETWORK), F("Reset"));
this->resetWifi();
NetworkConnection::reset();
this->context->delayCallback(1000);
return;
}
if (this->isAssociated()) {
this->attempt.disarm();
if (!this->connected) {
this->connectedTime = millis();
this->connected = true;
Log.sinfoln(
FPSTR(L_NETWORK),
F("Connected, downtime: %lu s., IP: %s, RSSI: %hhd"),
(millis() - this->disconnectedTime) / 1000,
WiFi.localIP().toString().c_str(),
WiFi.RSSI()
);
}
#ifdef ARDUINO_ARCH_ESP8266
if (millis() - this->prevArpGratuitous > 60000) {
this->stationKeepAliveNow();
this->prevArpGratuitous = millis();
}
#endif
return;
}
// the association is down: track the downtime and keep asking for the network
if (this->connected) {
this->disconnectedTime = millis();
this->connected = false;
this->attempt.arm(this->failedConnectTimeout);
Log.sinfoln(
FPSTR(L_NETWORK),
F("Disconnected, reason: %d, uptime: %lu s."),
NetworkConnection::getDisconnectReason(),
(millis() - this->connectedTime) / 1000
);
}
if (!this->hasCredentials()) {
this->attempt.disarm();
return;
}
if (!this->attempt.isArmed()) {
this->attempt.arm(this->failedConnectTimeout);
}
if (this->isConnecting() && millis() - this->prevReconnectingTime > this->resetConnectionTimeout) {
Log.swarningln(FPSTR(L_NETWORK), F("Connection timeout, reset wifi..."));
this->resetWifi();
NetworkConnection::reset();
this->context->delayCallback(250);
return;
}
if (!this->isConnecting() && (!this->prevReconnectingTime || millis() - this->prevReconnectingTime > this->reconnectInterval)) {
Log.sinfoln(FPSTR(L_NETWORK), F("Try connect..."));
NetworkConnection::reset();
if (!this->connect(true, this->connectionTimeout)) {
Log.straceln(FPSTR(L_NETWORK), F("Connection failed. Status: %d, reason: %d, raw reason: %d"), NetworkConnection::getStatus(), NetworkConnection::getDisconnectReason(), NetworkConnection::rawDisconnectReason);
}
this->prevReconnectingTime = millis();
}
}
/**
* @brief WiFi carries the uplink: radio running and associated
*/
bool isActive() override {
return !this->suspended && this->isAssociated();
}
bool isAssociated() {
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTED;
}
bool isConnecting() {
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTING;
}
bool isStaEnabled() {
return (WiFi.getMode() & WIFI_STA) != 0;
}
bool isApEnabled() {
return (WiFi.getMode() & WIFI_AP) != 0;
}
/**
* @brief When the association first came up, for the fallback AP's retirement delay
*/
unsigned long getConnectedTime() {
return this->connectedTime;
}
/**
* @brief Stop the radio while another uplink carries the traffic
*
* esp_wifi_stop() parks the radio without tearing the driver and its netifs down.
* WiFi.mode(WIFI_OFF) does the same job but also deinitialises, which panicked when it
* was called from this task with lwIP live — keep the driver allocated.
*/
void suspend() {
#ifdef ARDUINO_ARCH_ESP32
if (this->suspended) {
return;
}
if (WiFi.getMode() == WIFI_MODE_NULL) {
return;
}
// a scan holds the radio: parking it mid-scan leaves the driver half torn down
if (WiFi.scanComplete() == WIFI_SCAN_RUNNING) {
return;
}
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: uplink active, switching the WiFi radio off"));
esp_wifi_stop();
this->suspended = true;
#endif
}
/**
* @brief Bring the radio back when no other uplink carries the traffic
*/
void resume() {
#ifdef ARDUINO_ARCH_ESP32
if (!this->suspended) {
return;
}
this->suspended = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: uplink lost, switching the WiFi radio back on"));
esp_wifi_start();
this->connected = false;
this->disconnectedTime = millis();
this->prevReconnectingTime = 0;
this->attempt.arm(this->failedConnectTimeout);
NetworkConnection::reset();
if (this->hasCredentials()) {
WiFi.begin(this->context->staSsid, this->context->staPassword);
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: reconnecting to WiFi \"%s\""), this->context->staSsid);
}
#endif
}
bool isSuspended() {
return this->suspended;
}
bool resetWifi() {
// set policy manual for work 13 ch
{
#ifdef ARDUINO_ARCH_ESP8266
wifi_country_t country = {"JP", 1, 14, WIFI_COUNTRY_POLICY_MANUAL};
wifi_set_country(&country);
#elif defined(ARDUINO_ARCH_ESP32)
const wifi_country_t country = {"JP", 1, 14, CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER, WIFI_COUNTRY_POLICY_MANUAL};
esp_wifi_set_country(&country);
#endif
}
WiFi.persistent(false);
#if !defined(ESP_ARDUINO_VERSION_MAJOR) || ESP_ARDUINO_VERSION_MAJOR < 3
WiFi.setAutoConnect(false);
#endif
WiFi.setAutoReconnect(false);
#ifdef ARDUINO_ARCH_ESP8266
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#elif defined(ARDUINO_ARCH_ESP32)
WiFi.setSleep(USE_BLE ? WIFI_PS_MIN_MODEM : WIFI_PS_NONE);
#endif
WiFi.softAPdisconnect();
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_softap_dhcps_status() == DHCP_STARTED) {
wifi_softap_dhcps_stop();
}*/
#endif
WiFi.disconnect(false, true);
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}*/
wifi_station_dhcpc_set_maxtry(5);
#endif
#if defined(ARDUINO_ARCH_ESP32) && ESP_ARDUINO_VERSION_MAJOR < 3
// Nothing. Because memory leaks when turn off WiFi on ESP32 SDK < 3.0.0
return true;
#else
return WiFi.mode(WIFI_OFF);
#endif
}
/**
* @brief Ask for a fresh connect
*
* The attempt window is armed here so the ladder keeps the fallback AP out of the way while
* the station works on this reconnect; it expires like any other failed attempt.
*/
void reconnect() {
this->attempt.arm(this->failedConnectTimeout);
this->reconnectFlag = true;
}
bool connect(bool force = false, unsigned int timeout = 1000u) {
if (this->isAssociated() && !force) {
return true;
}
if (force && !this->isApEnabled()) {
this->resetWifi();
NetworkConnection::reset();
} else {
/*#ifdef ARDUINO_ARCH_ESP8266
if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}
#endif*/
this->disconnect();
}
if (!this->hasCredentials()) {
return false;
}
this->context->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP32
if (this->setHostname(this->context->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->context->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->context->hostname);
}
#endif
if (!WiFi.mode((WiFiMode_t)(WiFi.getMode() | WIFI_STA))) {
return false;
}
this->context->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP8266
if (this->setHostname(this->context->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->context->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->context->hostname);
}
this->context->delayCallback(250);
#endif
#ifdef ARDUINO_ARCH_ESP32
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
#endif
if (!this->context->useDhcp) {
WiFi.begin(this->context->staSsid, this->context->staPassword, this->context->staChannel, nullptr, false);
WiFi.config(this->context->staticIp, this->context->staticGateway, this->context->staticSubnet, this->context->staticDns);
WiFi.reconnect();
} else {
#ifdef ARDUINO_ARCH_ESP32
// the interface keeps a static address from an earlier association, so the addressing has
// to be reset before the station reconnects or the switch back to DHCP never takes effect
const IPAddress noIp(0, 0, 0, 0);
WiFi.config(noIp, noIp, noIp);
#endif
WiFi.begin(this->context->staSsid, this->context->staPassword, this->context->staChannel, nullptr, true);
}
unsigned long beginConnectionTime = millis();
while (millis() - beginConnectionTime < timeout) {
this->context->delayCallback(100);
NetworkConnection::Status status = NetworkConnection::getStatus();
if (status != NetworkConnection::Status::CONNECTING && status != NetworkConnection::Status::NONE) {
return status == NetworkConnection::Status::CONNECTED;
}
}
return false;
}
void disconnect() {
#ifdef ARDUINO_ARCH_ESP32
WiFi.disconnectAsync(false, true);
const unsigned long start = millis();
while (WiFi.isConnected() && (millis() - start) < 5000) {
this->context->delayCallback(100);
}
#else
WiFi.disconnect(false, true);
#endif
}
bool setHostname(const char* hostname) {
if (!UplinkContext::isHostnameValid(hostname)) {
return false;
}
if (strcmp(WiFi.getHostname(), hostname) == 0) {
return true;
}
return WiFi.setHostname(hostname);
}
bool hasCredentials() {
return this->context->staSsid != nullptr;
}
IPAddress localIP() override {
return WiFi.localIP();
}
IPAddress subnetMask() override {
return WiFi.subnetMask();
}
IPAddress gatewayIP() override {
return WiFi.gatewayIP();
}
IPAddress dnsIP() override {
return WiFi.dnsIP();
}
String macAddress() override {
return WiFi.macAddress();
}
short int rssi() override {
return WiFi.RSSI();
}
protected:
const unsigned int reconnectInterval = 15000;
const unsigned int failedConnectTimeout = 185000;
const unsigned int connectionTimeout = 10000;
const unsigned int resetConnectionTimeout = 90000;
bool connected = false;
bool reconnectFlag = false;
bool suspended = false;
unsigned long prevArpGratuitous = 0;
unsigned long prevReconnectingTime = 0;
unsigned long connectedTime = 0;
unsigned long disconnectedTime = 0;
#ifdef ARDUINO_ARCH_ESP8266
/**
* @brief
* https://github.com/arendst/Tasmota/blob/e6515883f0ee5451931b6280ff847b117de5a231/tasmota/tasmota_support/support_wifi.ino#L1196
*/
static void stationKeepAliveNow(void) {
for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
if (
(interface->flags & NETIF_FLAG_LINK_UP)
&& (interface->flags & NETIF_FLAG_UP)
&& interface->num == STATION_IF
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
) {
etharp_gratuitous(interface);
break;
}
}
}
#endif
};
}
+3 -3
View File
@@ -4,12 +4,12 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"cssnano": "^9.3.2",
"cssnano-preset-advanced": "^10.0.0",
"cssnano": "^7.0.2",
"cssnano-preset-advanced": "^7.0.2",
"gulp": "^5.0.0",
"gulp-concat": "^2.6.1",
"gulp-gzip": "^1.4.2",
"gulp-html-minifier-terser": "^8.0.0",
"gulp-html-minifier-terser": "^7.1.0",
"gulp-jsonminify": "^1.1.0",
"gulp-postcss": "^10.0.0",
"gulp-terser": "^2.1.0",
+9 -14
View File
@@ -14,7 +14,7 @@ extra_configs = secrets.default.ini
core_dir = .pio
[env]
version = 1.6.0
version = 1.5.6
framework = arduino
lib_deps =
bblanchon/ArduinoJson@^7.4.2
@@ -25,10 +25,8 @@ lib_deps =
gyverlibs/FileData@^1.0.3
gyverlibs/GyverPID@^3.3.2
gyverlibs/GyverBlinker@^1.1.1
pstolarz/OneWireNg@^0.14.1
milesburton/DallasTemperature@^4.0.6
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
laxilef/TinyLogger@^1.1.1
lib_ignore = OneWire
build_type = ${secrets.build_type}
build_flags =
-mtext-section-literals
@@ -75,7 +73,7 @@ platform_packages = ${env.platform_packages}
lib_deps =
${env.lib_deps}
nrwiersma/ESP8266Scheduler@^1.2
lib_ignore = ${env.lib_ignore}
lib_ignore =
extra_scripts =
post:tools/build.py
build_type = ${env.build_type}
@@ -94,14 +92,14 @@ check_flags = ${env.check_flags}
;platform_packages =
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip
platform_packages = ${env.platform_packages}
board_build.partitions = esp32_partitions.csv
lib_deps =
${env.lib_deps}
laxilef/ESP32Scheduler@^1.0.1
nimble_lib = h2zero/NimBLE-Arduino@2.3.7
lib_ignore = ${env.lib_ignore}
nimble_lib = h2zero/NimBLE-Arduino@2.3.3
lib_ignore =
extra_scripts =
post:tools/esp32.py
post:tools/build.py
@@ -236,7 +234,7 @@ build_flags =
${esp32_defaults.build_flags}
-D ARDUINO_USB_MODE=0
-D ARDUINO_USB_CDC_ON_BOOT=1
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D CONFIG_BT_NIMBLE_EXT_ADV=1
-D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=35
-D DEFAULT_OT_OUT_GPIO=36
@@ -262,7 +260,7 @@ build_unflags =
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D CONFIG_BT_NIMBLE_EXT_ADV=1
-D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=8
-D DEFAULT_OT_OUT_GPIO=10
@@ -324,8 +322,6 @@ check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:esp32_c6]
; W5500 ethernet (USE_ETHERNET) is hardware-validated on this target only; every other env
; inherits the `false` default from src/defines.h and compiles the driver out.
platform = ${esp32_defaults.platform}
framework = arduino, espidf
platform_packages = ${esp32_defaults.platform_packages}
@@ -346,7 +342,6 @@ build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D USE_BLE=1
-D USE_ETHERNET=1
-D DEFAULT_OT_IN_GPIO=15
-D DEFAULT_OT_OUT_GPIO=23
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
@@ -371,7 +366,7 @@ build_unflags =
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D CONFIG_BT_NIMBLE_EXT_ADV=1
-D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=3
-D DEFAULT_OT_OUT_GPIO=1
-5
View File
@@ -9,11 +9,6 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
#
# Ethernet (W5500 over SPI)
CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_W5500=y
#
# BT config
CONFIG_BT_ENABLED=y
+3 -34
View File
@@ -25,12 +25,6 @@ public:
}
bool publishDynamicSensor(Sensors::Settings& sSensor, Sensors::ValueType vType = Sensors::ValueType::PRIMARY, UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) {
#if !USE_BLE
if (sSensor.type == Sensors::Type::BLUETOOTH) {
return false;
}
#endif
JsonDocument doc;
// set device class & unit of measurement
@@ -449,28 +443,6 @@ public:
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")).c_str(), doc);
}
bool publishSwitchHeatingHysteresis(bool enabledByDefault = true) {
JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_hysteresis"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis"));
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Use heating hysteresis");
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
doc[FPSTR(HA_STATE_ON)] = true;
doc[FPSTR(HA_STATE_OFF)] = false;
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.enabled }}");
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
doc[FPSTR(HA_PAYLOAD_ON)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : true}}}");
doc[FPSTR(HA_PAYLOAD_OFF)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : false}}}");
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
doc.shrinkToFit();
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis")).c_str(), doc);
}
bool publishInputHeatingHysteresis(UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) {
JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
@@ -490,9 +462,9 @@ public:
doc[FPSTR(HA_NAME)] = F("Heating hysteresis");
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.value|float(0)|round(2) }}");
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis|float(0)|round(2) }}");
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {\"value\" : {{ value }}}}}");
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {{ value }}}}");
doc[FPSTR(HA_MIN)] = 0;
doc[FPSTR(HA_MAX)] = 15;
doc[FPSTR(HA_STEP)] = 0.01f;
@@ -1184,10 +1156,7 @@ public:
bool publishNetworkRssi(bool enabledByDefault = true) {
JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_TOPIC)] = this->stateTopic.c_str();
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.master.network.connectionType == 'wifi', 'online', 'offline') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(FPSTR(S_RSSI));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), FPSTR(S_RSSI));
+25 -33
View File
@@ -43,6 +43,8 @@ protected:
bool telnetStarted = false;
bool emergencyDetected = false;
unsigned long emergencyFlipTime = 0;
bool freezeDetected = false;
unsigned long freezeDetectedTime = 0;
#if defined(ARDUINO_ARCH_ESP32)
const char* getTaskName() override {
@@ -102,8 +104,7 @@ protected:
vars.mqtt.connected = tMqtt->isConnected();
vars.network.connected = network->isConnected();
vars.network.rssi = network->getRssi();
vars.network.connectionType = network->getUplink();
vars.network.rssi = network->isConnected() ? WiFi.RSSI() : 0;
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
if (Log.getLevel() != settings.system.logLevel) {
@@ -134,6 +135,8 @@ protected:
tMqtt->disable();
}
Sensors::setConnectionStatusByType(Sensors::Type::MANUAL, !settings.mqtt.enabled || vars.mqtt.connected, false);
} else {
if (this->ntpStarted) {
this->ntpStarted = false;
@@ -242,7 +245,7 @@ protected:
void heating() {
// freeze protection
{
if (!settings.heating.enabled) {
float lowTemp = 255.0f;
uint8_t availableSensors = 0;
@@ -273,40 +276,29 @@ protected:
availableSensors++;
}
if (availableSensors) {
if (vars.master.heating.freezing) {
if (lowTemp - (float) settings.heating.freezeProtection.highTemp + 0.0001f >= 0.0f) {
vars.master.heating.freezing = false;
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
if (!this->freezeDetected) {
this->freezeDetected = true;
this->freezeDetectedTime = millis();
Log.sinfoln(
FPSTR(L_MAIN),
F("No freezing detected. Current low temp: %.2f, threshold (high): %hhu"),
lowTemp, settings.heating.freezeProtection.highTemp
);
}
} else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) {
this->freezeDetected = false;
settings.heating.enabled = true;
fsSettings.update();
} else {
if ((float) settings.heating.freezeProtection.lowTemp - lowTemp + 0.0001f >= 0.0f) {
vars.master.heating.freezing = true;
if (!settings.heating.enabled) {
settings.heating.enabled = true;
fsSettings.update();
}
Log.sinfoln(
FPSTR(L_MAIN),
F("Freezing detected! Current low temp: %.2f, threshold (low): %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp
);
}
Log.sinfoln(
FPSTR(L_MAIN),
F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp
);
}
} else if (vars.master.heating.freezing) {
vars.master.heating.freezing = false;
Log.sinfoln(FPSTR(L_MAIN), F("No sensors available, freeze protection unavailable!"));
} else if (this->freezeDetected) {
this->freezeDetected = false;
}
} else if (this->freezeDetected) {
this->freezeDetected = false;
}
}
@@ -327,7 +319,7 @@ protected:
emergencyFlags |= 0b00000010;
}
if (settings.opentherm.options.nativeOTC) {
if (settings.opentherm.options.nativeHeatingControl) {
emergencyFlags |= 0b00000100;
}
}
-1
View File
@@ -486,7 +486,6 @@ protected:
void publishHaEntities() {
// heating
this->haHelper->publishSwitchHeatingTurbo(false);
this->haHelper->publishSwitchHeatingHysteresis();
this->haHelper->publishInputHeatingHysteresis(settings.system.unitSystem);
this->haHelper->publishInputHeatingTurboFactor(false);
this->haHelper->publishInputHeatingMinTemp(settings.system.unitSystem);
+63 -142
View File
@@ -170,7 +170,8 @@ protected:
// Heating settings
vars.master.heating.enabled = this->isReady()
&& settings.heating.enabled
&& (vars.master.heating.freezing || (vars.cascadeControl.input && !vars.master.heating.blocking))
&& vars.cascadeControl.input
&& !vars.master.heating.blocking
&& !vars.master.heating.overheat;
// DHW settings
@@ -185,9 +186,7 @@ protected:
|| (settings.opentherm.options.dhwToCh2 && settings.opentherm.options.dhwSupport && settings.dhw.enabled);
if (settings.opentherm.options.heatingToCh2) {
vars.master.ch2.targetTemp = !settings.opentherm.options.nativeOTC
? vars.master.heating.setpointTemp
: vars.master.heating.targetTemp;
vars.master.ch2.targetTemp = vars.master.heating.setpointTemp;
} else if (settings.opentherm.options.dhwToCh2) {
vars.master.ch2.targetTemp = vars.master.dhw.targetTemp;
@@ -219,7 +218,7 @@ protected:
vars.master.heating.enabled,
vars.master.dhw.enabled,
settings.opentherm.options.coolingSupport,
settings.opentherm.options.nativeOTC,
settings.opentherm.options.nativeHeatingControl,
vars.master.ch2.enabled,
summerWinterMode,
dhwBlocking,
@@ -306,7 +305,6 @@ protected:
Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_BURNER_HOURS, false);
Sensors::setConnectionStatusByType(Sensors::Type::OT_HEATING_PUMP_HOURS, false);
Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_PUMP_HOURS, false);
Sensors::setConnectionStatusByType(Sensors::Type::OT_COOLING_HOURS, false);
this->initialized = false;
this->disconnectedTime = millis();
@@ -679,21 +677,6 @@ protected:
}
}
// Update cooling hours
if (Sensors::getAmountByType(Sensors::Type::OT_COOLING_HOURS, true)) {
if (this->updateCoolingHours()) {
Log.snoticeln(FPSTR(L_OT), F("Received cooling hours: %hu"), vars.slave.stats.coolingHours);
Sensors::setValueByType(
Sensors::Type::OT_COOLING_HOURS, vars.slave.stats.coolingHours,
Sensors::ValueType::PRIMARY, true, true
);
} else {
Log.swarningln(FPSTR(L_OT), F("Failed receive cooling hours"));
}
}
// Auto fault reset
if (settings.opentherm.options.autoFaultReset && vars.slave.fault.active && !vars.actions.resetFault) {
vars.actions.resetFault = true;
@@ -809,7 +792,7 @@ protected:
bool result = this->updateDhwTemp();
if (result) {
const float convertedDhwTemp = convertTemp(
float convertedDhwTemp = convertTemp(
vars.slave.dhw.currentTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -833,7 +816,7 @@ protected:
// Update DHW temp 2
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2, true)) {
if (this->updateDhwTemp2()) {
const float convertedDhwTemp2 = convertTemp(
float convertedDhwTemp2 = convertTemp(
vars.slave.dhw.currentTemp2,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -857,7 +840,7 @@ protected:
// Update DHW flow rate
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE, true)) {
if (this->updateDhwFlowRate()) {
const float convertedDhwFlowRate = convertVolume(
float convertedDhwFlowRate = convertVolume(
vars.slave.dhw.flowRate,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -881,7 +864,7 @@ protected:
// Update heating temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP, true)) {
if (this->updateHeatingTemp()) {
const float convertedHeatingTemp = convertTemp(
float convertedHeatingTemp = convertTemp(
vars.slave.heating.currentTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -905,7 +888,7 @@ protected:
// Update heating return temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP, true)) {
if (this->updateHeatingReturnTemp()) {
const float convertedHeatingReturnTemp = convertTemp(
float convertedHeatingReturnTemp = convertTemp(
vars.slave.heating.returnTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -928,9 +911,9 @@ protected:
// Update CH2 temp
if (Sensors::getAmountByType(Sensors::Type::OT_CH2_TEMP, true)) {
if (vars.master.ch2.enabled && !settings.opentherm.options.nativeOTC) {
if (vars.master.ch2.enabled && !settings.opentherm.options.nativeHeatingControl) {
if (this->updateCh2Temp()) {
const float convertedCh2Temp = convertTemp(
float convertedCh2Temp = convertTemp(
vars.slave.ch2.currentTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -955,7 +938,7 @@ protected:
// Update exhaust temp
if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP, true)) {
if (this->updateExhaustTemp()) {
const float convertedExhaustTemp = convertTemp(
float convertedExhaustTemp = convertTemp(
vars.slave.exhaust.temp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -979,7 +962,7 @@ protected:
// Update heat exchanger temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP, true)) {
if (this->updateHeatExchangerTemp()) {
const float convertedHeatExchTemp = convertTemp(
float convertedHeatExchTemp = convertTemp(
vars.slave.heatExchangerTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -1003,7 +986,7 @@ protected:
// Update outdoor temp
if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP, true)) {
if (this->updateOutdoorTemp()) {
const float convertedOutdoorTemp = convertTemp(
float convertedOutdoorTemp = convertTemp(
vars.slave.heating.outdoorTemp,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -1027,7 +1010,7 @@ protected:
// Update solar storage temp
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_STORAGE_TEMP, true)) {
if (this->updateSolarStorageTemp()) {
const float convertedSolarStorageTemp = convertTemp(
float convertedSolarStorageTemp = convertTemp(
vars.slave.solar.storage,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -1051,7 +1034,7 @@ protected:
// Update solar collector temp
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_COLLECTOR_TEMP, true)) {
if (this->updateSolarCollectorTemp()) {
const float convertedSolarCollectorTemp = convertTemp(
float convertedSolarCollectorTemp = convertTemp(
vars.slave.solar.collector,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -1097,7 +1080,7 @@ protected:
// Update pressure
if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE, true)) {
if (this->updatePressure()) {
const float convertedPressure = convertPressure(
float convertedPressure = convertPressure(
vars.slave.pressure,
settings.opentherm.unitSystem,
settings.system.unitSystem
@@ -1203,12 +1186,9 @@ protected:
// Update DHW temp
if (vars.master.dhw.enabled) {
// Target dhw temp
const float& targetTemp = vars.master.dhw.targetTemp;
// Converted target dhw temp
const float convertedTemp = convertTemp(
targetTemp,
float convertedTemp = convertTemp(
vars.master.dhw.targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
@@ -1220,7 +1200,7 @@ protected:
Log.sinfoln(
FPSTR(L_OT_DHW), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.dhw.targetTemp
vars.master.dhw.targetTemp, convertedTemp, vars.slave.dhw.targetTemp
);
} else {
@@ -1229,19 +1209,16 @@ protected:
}
}
// Send indoor temp if AlwaysSendIndoorTemp option is enabled.
if (settings.opentherm.options.nativeOTC || settings.opentherm.options.alwaysSendIndoorTemp) {
// Current indoor temp
const float& indoorTemp = vars.master.heating.indoorTemp;
// Native heating control
if (settings.opentherm.options.nativeHeatingControl) {
// Converted current indoor temp
const float convertedTemp = convertTemp(indoorTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
float convertedTemp = convertTemp(vars.master.heating.indoorTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
// Set current indoor temp
if (this->setRoomTemp(convertedTemp)) {
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set current indoor temp: %.2f (converted: %.2f, response: %.2f)"),
indoorTemp, convertedTemp, vars.slave.heating.indoorTemp
vars.master.heating.indoorTemp, convertedTemp, vars.slave.heating.indoorTemp
);
} else {
@@ -1253,26 +1230,17 @@ protected:
if (this->setRoomTempCh2(convertedTemp)) {
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set current CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"),
indoorTemp, convertedTemp, vars.slave.ch2.indoorTemp
vars.master.heating.indoorTemp, convertedTemp, vars.slave.ch2.indoorTemp
);
} else {
Log.swarningln(FPSTR(L_OT_HEATING), F("Failed set current CH2 indoor temp"));
}
}
}
// NativeOTC
if (settings.opentherm.options.nativeOTC) {
// Target indoor temp
const float& targetTemp = vars.master.heating.targetTemp;
// Converted target indoor temp
const float convertedTemp = convertTemp(
targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
convertedTemp = convertTemp(vars.master.heating.targetTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
// Set target indoor temp
if (this->needSetHeatingTemp(convertedTemp)) {
@@ -1281,7 +1249,7 @@ protected:
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target indoor temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.heating.targetTemp
vars.master.heating.targetTemp, convertedTemp, vars.slave.heating.targetTemp
);
} else {
@@ -1296,7 +1264,7 @@ protected:
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.ch2.targetTemp
vars.master.heating.targetTemp, convertedTemp, vars.slave.ch2.targetTemp
);
} else {
@@ -1305,22 +1273,10 @@ protected:
}
}
// Set heating temp
{
// Target heating temp
float targetTemp = 0.0f;
if (vars.master.heating.enabled) {
targetTemp = !settings.opentherm.options.nativeOTC
? vars.master.heating.setpointTemp
: vars.master.heating.targetTemp;
}
// Normal heating control
if (!settings.opentherm.options.nativeHeatingControl && vars.master.heating.enabled) {
// Converted target heating temp
const float convertedTemp = convertTemp(
targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
float convertedTemp = convertTemp(vars.master.heating.setpointTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
if (this->needSetHeatingTemp(convertedTemp)) {
// Set max heating temp
@@ -1328,13 +1284,13 @@ protected:
if (this->setMaxHeatingTemp(convertedTemp)) {
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set max heating temp: %.2f (converted: %.2f)"),
targetTemp, convertedTemp
vars.master.heating.setpointTemp, convertedTemp
);
} else {
Log.swarningln(
FPSTR(L_OT_HEATING), F("Failed set max heating temp: %.2f (converted: %.2f)"),
targetTemp, convertedTemp
vars.master.heating.setpointTemp, convertedTemp
);
}
}
@@ -1345,7 +1301,7 @@ protected:
Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.heating.targetTemp
vars.master.heating.setpointTemp, convertedTemp, vars.slave.heating.targetTemp
);
} else {
@@ -1355,30 +1311,27 @@ protected:
}
// Set CH2 temp
if (settings.opentherm.options.heatingToCh2 || settings.opentherm.options.dhwToCh2) {
// Target CH2 heating temp
const float targetTemp = vars.master.ch2.enabled
? vars.master.ch2.targetTemp
: 0.0f;
if (!settings.opentherm.options.nativeHeatingControl && vars.master.ch2.enabled) {
if (settings.opentherm.options.heatingToCh2 || settings.opentherm.options.dhwToCh2) {
// Converted target CH2 temp
float convertedTemp = convertTemp(
vars.master.ch2.targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
// Converted target CH2 temp
const float convertedTemp = convertTemp(
targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
if (this->needSetCh2Temp(convertedTemp)) {
if (this->setCh2Temp(convertedTemp)) {
this->ch2SetTempTime = millis();
if (this->needSetCh2Temp(convertedTemp)) {
if (this->setCh2Temp(convertedTemp)) {
this->ch2SetTempTime = millis();
Log.sinfoln(
FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
vars.master.ch2.targetTemp, convertedTemp, vars.slave.ch2.targetTemp
);
Log.sinfoln(
FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.ch2.targetTemp
);
} else {
Log.swarningln(FPSTR(L_OT_CH2), F("Failed set temp"));
} else {
Log.swarningln(FPSTR(L_OT_CH2), F("Failed set temp"));
}
}
}
}
@@ -1386,7 +1339,7 @@ protected:
// Heating overheat control
if (settings.heating.overheatProtection.highTemp > 0 && settings.heating.overheatProtection.lowTemp > 0) {
const float highTemp = convertTemp(
float highTemp = convertTemp(
max({
vars.slave.heating.currentTemp,
vars.slave.heating.returnTemp,
@@ -1423,7 +1376,7 @@ protected:
// DHW overheat control
if (settings.dhw.overheatProtection.highTemp > 0 && settings.dhw.overheatProtection.lowTemp > 0) {
const float highTemp = convertTemp(
float highTemp = convertTemp(
max({
vars.slave.heating.currentTemp,
vars.slave.heating.returnTemp,
@@ -1517,19 +1470,6 @@ protected:
} else {
Log.swarningln(FPSTR(L_OT), F("Failed set master config"));
}
/*char buf[100];
if (this->instance->getStr(OpenThermMessageID::Brand, buf, sizeof(buf) - 1)) {
Log.snoticeln(FPSTR(L_OT), F("Slave brand: %s"), buf);
}
if (this->instance->getStr(OpenThermMessageID::BrandVersion, buf, sizeof(buf) - 1)) {
Log.snoticeln(FPSTR(L_OT), F("Slave brand version: %s"), buf);
}
if (this->instance->getStr(OpenThermMessageID::BrandSerialNumber, buf, sizeof(buf) - 1)) {
Log.snoticeln(FPSTR(L_OT), F("Slave brand s/n: %s"), buf);
}*/
}
bool isReady() {
@@ -1707,7 +1647,7 @@ protected:
}
bool setRoomTemp(const float temperature) {
bool setRoomTemp(float temperature) {
const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermMessageType::WRITE_DATA,
@@ -1727,7 +1667,7 @@ protected:
return CustomOpenTherm::getUInt(response) == request;
}
bool setRoomTempCh2(const float temperature) {
bool setRoomTempCh2(float temperature) {
const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermMessageType::WRITE_DATA,
@@ -2229,25 +2169,6 @@ protected:
return true;
}
bool updateCoolingHours() {
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermRequestType::READ_DATA,
OpenThermMessageID::CoolingOperationHours,
0
));
if (!CustomOpenTherm::isValidResponse(response)) {
return false;
} else if (!CustomOpenTherm::isValidResponseId(response, OpenThermMessageID::CoolingOperationHours)) {
return false;
}
vars.slave.stats.coolingHours = CustomOpenTherm::getUInt(response);
return true;
}
bool updateModulationLevel() {
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermRequestType::READ_DATA,
@@ -2262,7 +2183,7 @@ protected:
return false;
}
const float value = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (value < 0) {
return false;
}
@@ -2286,7 +2207,7 @@ protected:
return false;
}
const float value = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (value <= 0) {
return false;
}
@@ -2310,7 +2231,7 @@ protected:
return false;
}
const float value = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (value <= 0) {
return false;
}
@@ -2364,7 +2285,7 @@ protected:
return false;
}
const float value = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (value <= 0) {
return false;
}
@@ -2428,7 +2349,7 @@ protected:
return false;
}
const float value = (float) CustomOpenTherm::getInt(response);
float value = (float) CustomOpenTherm::getInt(response);
if (!isValidTemp(value, settings.opentherm.unitSystem, -40, 500)) {
return false;
}
@@ -2452,7 +2373,7 @@ protected:
return false;
}
const float value = (float) CustomOpenTherm::getInt(response);
float value = (float) CustomOpenTherm::getInt(response);
if (value <= 0) {
return false;
}
@@ -2553,7 +2474,7 @@ protected:
return false;
}
const float value = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (value < 0) {
return false;
}
+56 -201
View File
@@ -29,7 +29,6 @@ public:
this->webServer = new WebServer(80);
this->bufferedWebServer = new BufferedWebServer(this->webServer, 32u);
this->dnsServer = new DNSServer();
this->mDnsRetryTime = millis() - this->mDnsRetryInterval;
}
~PortalTask() {
@@ -57,11 +56,6 @@ protected:
bool dnsServerEnabled = false;
unsigned long webServerChangeState = 0;
bool mDnsState = false;
#if USE_ETHERNET
NetworkMgr::Uplink mdnsConnectionType = NetworkMgr::Uplink::None;
#endif
unsigned long mDnsRetryTime = 0;
const unsigned long mDnsRetryInterval = 5000;
#if defined(ARDUINO_ARCH_ESP32)
const char* getTaskName() override {
@@ -247,17 +241,7 @@ protected:
doc.shrinkToFit();
char filename[64];
getFilename(filename, sizeof(filename), "backup");
char contentDispositionHeaderValue[128];
snprintf_P(
contentDispositionHeaderValue,
sizeof(contentDispositionHeaderValue),
PSTR("attachment; filename=\"%s\""),
filename
);
this->webServer->sendHeader(F("Content-Disposition"), contentDispositionHeaderValue);
this->webServer->sendHeader(F("Content-Disposition"), F("attachment; filename=\"backup.json\""));
this->bufferedWebServer->send(200, F("application/json"), doc);
});
@@ -302,14 +286,12 @@ protected:
networkSettings.staticConfig.gateway,
networkSettings.staticConfig.subnet,
networkSettings.staticConfig.dns
)
->setEthernet(networkSettings.ethernet.enabled);
);
changed = true;
}
if (!doc[FPSTR(S_SETTINGS)].isNull() && jsonToSettings(doc[FPSTR(S_SETTINGS)], settings)) {
fsSettings.update();
applyEthernetSettings();
changed = true;
}
@@ -323,14 +305,14 @@ protected:
if (sensorId < 0 || sensorId > 255 || !Sensors::isValidSensorId(sensorId)) {
continue;
}
if (jsonToSensorSettings(sensorId, sensor.value(), Sensors::settings[sensorId])) {
fsSensorsSettings.update();
changed = true;
}
}
}
doc.clear();
doc.shrinkToFit();
@@ -349,7 +331,6 @@ protected:
JsonDocument doc;
networkSettingsToJson(networkSettings, doc);
this->ethernetToJson(doc);
doc.shrinkToFit();
this->bufferedWebServer->send(200, F("application/json"), doc);
@@ -359,7 +340,7 @@ protected:
if (this->isAuthRequired() && !this->isValidCredentials()) {
return this->webServer->send(401);
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
@@ -385,20 +366,12 @@ protected:
}
bool changed = jsonToNetworkSettings(doc, networkSettings);
// ethernet is only usable with a complete W5500 pin set
if (!this->isEthernetConfigured() && networkSettings.ethernet.enabled) {
networkSettings.ethernet.enabled = false;
changed = true;
}
doc.clear();
doc.shrinkToFit();
networkSettingsToJson(networkSettings, doc);
this->ethernetToJson(doc);
doc.shrinkToFit();
this->bufferedWebServer->send(changed ? 201 : 200, F("application/json"), doc);
if (changed) {
@@ -416,10 +389,7 @@ protected:
networkSettings.staticConfig.subnet,
networkSettings.staticConfig.dns
)
->setEthernet(networkSettings.ethernet.enabled)
->reconnect();
this->applyEthernetSettings();
}
});
@@ -428,12 +398,6 @@ protected:
return this->webServer->send(401);
}
// scanning needs WiFi, which is not the uplink while ethernet carries the traffic
if (network->getUplink() == NetworkMgr::Uplink::Ethernet) {
this->webServer->send(409);
return;
}
auto apCount = WiFi.scanComplete();
if (apCount <= 0) {
if (apCount != WIFI_SCAN_RUNNING) {
@@ -443,11 +407,11 @@ protected:
WiFi.scanNetworks(true, true, true);
#endif
}
this->webServer->send(404);
return;
}
JsonDocument doc;
for (short int i = 0; i < apCount; i++) {
const String& ssid = WiFi.SSID(i);
@@ -480,7 +444,7 @@ protected:
JsonDocument doc;
settingsToJson(settings, doc);
doc.shrinkToFit();
this->bufferedWebServer->send(200, F("application/json"), doc);
});
@@ -488,7 +452,7 @@ protected:
if (this->isAuthRequired() && !this->isValidCredentials()) {
return this->webServer->send(401);
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
@@ -527,7 +491,6 @@ protected:
doc.shrinkToFit();
fsSettings.update();
applyEthernetSettings();
tMqtt->resetPublishedSettingsTime();
}
});
@@ -543,7 +506,7 @@ protected:
if (this->webServer->hasArg(F("detailed"))) {
detailed = this->webServer->arg(F("detailed")).toInt() > 0;
}
JsonDocument doc;
for (uint8_t sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) {
if (detailed) {
@@ -557,7 +520,7 @@ protected:
doc[sensorId] = Sensors::settings[sensorId].name;
}
}
doc.shrinkToFit();
this->bufferedWebServer->send(200, F("application/json"), doc);
});
@@ -567,7 +530,7 @@ protected:
if (this->isAuthRequired() && !this->isValidCredentials()) {
return this->webServer->send(401);
}
if (!this->webServer->hasArg(F("id"))) {
return this->webServer->send(400);
}
@@ -588,12 +551,12 @@ protected:
doc.shrinkToFit();
this->bufferedWebServer->send(200, F("application/json"), doc);
});
this->webServer->on(F("/api/sensor"), HTTP_POST, [this]() {
if (this->isAuthRequired() && !this->isValidCredentials()) {
return this->webServer->send(401);
}
if (vars.states.restarting) {
return this->webServer->send(503);
}
@@ -650,7 +613,7 @@ protected:
auto& sSettings = Sensors::settings[sensorId];
sensorSettingsToJson(sensorId, sSettings, doc);
doc.shrinkToFit();
this->bufferedWebServer->send(changed ? 201 : 200, F("application/json"), doc);
}
@@ -701,13 +664,13 @@ protected:
varsToJson(vars, doc);
doc.shrinkToFit();
this->bufferedWebServer->send(changed ? 201 : 200, F("application/json"), doc);
if (changed) {
doc.clear();
doc.shrinkToFit();
tMqtt->resetPublishedVarsTime();
}
});
@@ -717,16 +680,6 @@ protected:
JsonDocument doc;
// capabilities: only the flags this build actually has; the UI shows features on an explicit true
auto docFeatures = doc[FPSTR(S_FEATURES)].to<JsonObject>();
#if USE_ETHERNET
docFeatures[FPSTR(S_ETHERNET)] = true;
#endif
#if USE_BLE
docFeatures[FPSTR(S_BLE)] = true;
#endif
auto docSystem = doc[FPSTR(S_SYSTEM)].to<JsonObject>();
docSystem[FPSTR(S_RESET_REASON)] = getResetReason();
docSystem[FPSTR(S_UPTIME)] = millis() / 1000;
@@ -735,15 +688,9 @@ protected:
docNetwork[FPSTR(S_HOSTNAME)] = networkSettings.hostname;
docNetwork[FPSTR(S_MAC)] = network->getStaMac();
docNetwork[FPSTR(S_CONNECTED)] = isConnected;
docNetwork[FPSTR(S_CONNECTION_TYPE)] = network->getConnectionType();
// SSID, signal and channel describe the WiFi uplink only: with ethernet up the radio is
// parked and those readings are stale, so report them as not applicable rather than 0 dBm
const bool wifiUplink = network->getUplink() == NetworkMgr::Uplink::Wifi;
const char* staSsid = network->getStaSsid();
docNetwork[FPSTR(S_SSID)] = (wifiUplink && staSsid) ? staSsid : "";
docNetwork[FPSTR(S_SIGNAL_QUALITY)] = network->getSignalQuality();
docNetwork[FPSTR(S_CHANNEL)] = wifiUplink ? network->getStaChannel() : 0;
docNetwork[FPSTR(S_SSID)] = network->getStaSsid();
docNetwork[FPSTR(S_SIGNAL_QUALITY)] = isConnected ? NetworkMgr::rssiToSignalQuality(network->getRssi()) : 0;
docNetwork[FPSTR(S_CHANNEL)] = isConnected ? network->getStaChannel() : 0;
docNetwork[FPSTR(S_IP)] = isConnected ? network->getStaIp().toString() : "";
docNetwork[FPSTR(S_SUBNET)] = isConnected ? network->getStaSubnet().toString() : "";
docNetwork[FPSTR(S_GATEWAY)] = isConnected ? network->getStaGateway().toString() : "";
@@ -770,7 +717,7 @@ protected:
docHeap[FPSTR(S_MIN_FREE)] = getFreeHeap(true);
docHeap[FPSTR(S_MAX_FREE_BLOCK)] = getMaxFreeBlockHeap();
docHeap[FPSTR(S_MIN_MAX_FREE_BLOCK)] = getMaxFreeBlockHeap(true);
auto docChip = doc[FPSTR(S_CHIP)].to<JsonObject>();
#ifdef ARDUINO_ARCH_ESP8266
docChip[FPSTR(S_MODEL)] = esp_is_8285() ? F("ESP8285") : F("ESP8266");
@@ -809,9 +756,6 @@ protected:
this->webServer->on(F("/api/debug"), HTTP_GET, [this]() {
JsonDocument doc;
auto docNetwork = doc[FPSTR(S_NETWORK)].to<JsonObject>();
docNetwork[FPSTR(S_CONNECTION_TYPE)] = network->getConnectionType();
auto docBuild = doc[FPSTR(S_BUILD)].to<JsonObject>();
docBuild[FPSTR(S_VERSION)] = BUILD_VERSION;
docBuild[FPSTR(S_DATE)] = __DATE__ " " __TIME__;
@@ -833,7 +777,7 @@ protected:
docHeap[FPSTR(S_MIN_FREE)] = getFreeHeap(true);
docHeap[FPSTR(S_MAX_FREE_BLOCK)] = getMaxFreeBlockHeap();
docHeap[FPSTR(S_MIN_MAX_FREE_BLOCK)] = getMaxFreeBlockHeap(true);
auto docChip = doc[FPSTR(S_CHIP)].to<JsonObject>();
#ifdef ARDUINO_ARCH_ESP8266
docChip[FPSTR(S_MODEL)] = esp_is_8285() ? F("ESP8285") : F("ESP8266");
@@ -892,21 +836,10 @@ protected:
docCrash[FPSTR(S_EPC)] = epcStr;
}
}
doc.shrinkToFit();
char filename[64];
getFilename(filename, sizeof(filename), "debug");
char contentDispositionHeaderValue[128];
snprintf_P(
contentDispositionHeaderValue,
sizeof(contentDispositionHeaderValue),
PSTR("attachment; filename=\"%s\""),
filename
);
this->webServer->sendHeader(F("Content-Disposition"), contentDispositionHeaderValue);
this->webServer->sendHeader(F("Content-Disposition"), F("attachment; filename=\"debug.json\""));
this->bufferedWebServer->send(200, F("application/json"), doc, true);
});
@@ -938,31 +871,54 @@ protected:
#ifdef ARDUINO_ARCH_ESP32
this->delay(250);
#endif
this->startWebServer();
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Started: AP up or network connected"));
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Started: AP up or STA connected"));
// Enabling mDNS
if (!this->mDnsState && settings.portal.mdns) {
if (MDNS.begin(networkSettings.hostname)) {
MDNS.addService("http", "tcp", 80);
this->mDnsState = true;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS enabled and service added"));
}
}
#ifdef ARDUINO_ARCH_ESP8266
::optimistic_yield(1000);
#endif
} else if (this->stateWebServer() && !network->isApEnabled() && !network->isConnected()) {
} else if (this->stateWebServer() && !network->isApEnabled() && !network->isStaEnabled()) {
this->stopWebServer();
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Stopped: no network"));
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Stopped: AP and STA down"));
// Disabling mDNS
if (this->mDnsState) {
MDNS.end();
this->mDnsState = false;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS disabled"));
}
#ifdef ARDUINO_ARCH_ESP8266
::optimistic_yield(1000);
#endif
}
// mDNS
this->loopMdns();
// Disabling mDNS if disabled in settings
if (this->mDnsState && !settings.portal.mdns) {
MDNS.end();
this->mDnsState = false;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS disabled"));
}
// dns server
if (!this->stateDnsServer() && !network->isConnected() && network->isApEnabled() && this->stateWebServer()) {
this->startDnsServer();
Log.straceln(FPSTR(L_PORTAL_DNSSERVER), F("Started: AP up"));
#ifdef ARDUINO_ARCH_ESP8266
::optimistic_yield(1000);
#endif
@@ -1005,99 +961,6 @@ protected:
return !network->isApEnabled() && settings.portal.auth && strlen(settings.portal.password);
}
/**
* @brief Keep mDNS in sync with the active uplink
* @details The responder binds its records to the interface that is up when it starts, so when
* switching between interfaces, mDNS must be restarted
*/
void loopMdns() {
#if USE_ETHERNET
const NetworkMgr::Uplink connectionType = network->getUplink();
if (connectionType != this->mdnsConnectionType) {
this->mdnsConnectionType = connectionType;
if (this->mDnsState) {
MDNS.end();
this->mDnsState = false;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS restarting: connection is now %s"), NetworkMgr::uplinkName(connectionType));
}
}
#endif
if (!settings.portal.mdns || !this->stateWebServer()) {
if (this->mDnsState) {
MDNS.end();
this->mDnsState = false;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS disabled"));
}
return;
}
if (this->mDnsState || millis() - this->mDnsRetryTime < this->mDnsRetryInterval) {
return;
}
this->mDnsRetryTime = millis();
if (MDNS.begin(networkSettings.hostname)) {
MDNS.addService("http", "tcp", 80);
this->mDnsState = true;
Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("mDNS enabled and service added"));
}
}
/**
* @brief Add the computed W5500 state to a network settings document
* @details The key is absent entirely on builds without ethernet, rather than an empty object:
* presence of the section is what tells a client the target can do it. The stored fields
* (enabled flag, pinout) come from networkSettingsToJson, this adds only what is derived.
*/
void ethernetToJson(JsonDocument& dst) {
#if USE_ETHERNET
dst[FPSTR(S_ETHERNET)][FPSTR(S_CONFIGURED)] = this->isEthernetConfigured();
#endif
}
/**
* @brief Ethernet can only be used when all six W5500 pins are configured
*/
bool isEthernetConfigured() {
#if USE_ETHERNET
return networkSettings.ethernet.w5500.clk != GPIO_IS_NOT_CONFIGURED
&& networkSettings.ethernet.w5500.mosi != GPIO_IS_NOT_CONFIGURED
&& networkSettings.ethernet.w5500.miso != GPIO_IS_NOT_CONFIGURED
&& networkSettings.ethernet.w5500.cs != GPIO_IS_NOT_CONFIGURED
&& networkSettings.ethernet.w5500.irq != GPIO_IS_NOT_CONFIGURED
&& networkSettings.ethernet.w5500.rst != GPIO_IS_NOT_CONFIGURED;
#else
// nothing to configure: the W5500 driver is not compiled into this target
return false;
#endif
}
/**
* @brief Push the W5500 wiring from the settings into the network manager
*/
void applyEthernetSettings() {
#if USE_ETHERNET
network
->setEthernet(networkSettings.ethernet.enabled)
->setEthernetPins(
networkSettings.ethernet.w5500.clk,
networkSettings.ethernet.w5500.mosi,
networkSettings.ethernet.w5500.miso,
networkSettings.ethernet.w5500.cs,
networkSettings.ethernet.w5500.irq,
networkSettings.ethernet.w5500.rst
);
#endif
}
bool isValidCredentials() {
return this->webServer->authenticate(settings.portal.login, settings.portal.password);
}
@@ -1183,12 +1046,4 @@ protected:
this->dnsServer->stop();
this->dnsServerEnabled = false;
}
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
const time_t now = time(nullptr);
const tm* localNow = localtime(&now);
char localNowValue[20];
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), localNow);
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
}
};
};
+8 -13
View File
@@ -37,7 +37,7 @@ protected:
this->indoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::INDOOR_TEMP);
//this->outdoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::OUTDOOR_TEMP);
if (settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeOTC) {
if (settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl) {
vars.master.heating.indoorTempControl = true;
vars.master.heating.minTemp = THERMOSTAT_INDOOR_MIN_TEMP;
vars.master.heating.maxTemp = THERMOSTAT_INDOOR_MAX_TEMP;
@@ -90,15 +90,15 @@ protected:
void hysteresis() {
bool useHyst = false;
if (settings.heating.hysteresis.enabled && this->indoorSensorsConnected) {
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeOTC;
if (settings.heating.hysteresis > 0.01f && this->indoorSensorsConnected) {
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl;
}
if (useHyst) {
if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis.value) {
if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis) {
vars.master.heating.blocking = true;
} else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis.value)) {
} else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis)) {
vars.master.heating.blocking = false;
}
@@ -108,13 +108,13 @@ protected:
}
inline float getHeatingMinSetpointTemp() {
return settings.opentherm.options.nativeOTC
return settings.opentherm.options.nativeHeatingControl
? vars.master.heating.minTemp
: settings.heating.minTemp;
}
inline float getHeatingMaxSetpointTemp() {
return settings.opentherm.options.nativeOTC
return settings.opentherm.options.nativeHeatingControl
? vars.master.heating.maxTemp
: settings.heating.maxTemp;
}
@@ -135,7 +135,7 @@ protected:
if (vars.emergency.state) {
return settings.emergency.target;
} else if (settings.opentherm.options.nativeOTC) {
} else if (settings.opentherm.options.nativeHeatingControl) {
return settings.heating.target;
} else if (!settings.equitherm.enabled && !settings.pid.enabled) {
@@ -240,11 +240,6 @@ protected:
) * settings.heating.turboFactor;
}
// If freezing, set temperature to no lower than low temp provided by freeze protection
if (vars.master.heating.freezing && fabsf(settings.heating.freezeProtection.lowTemp - newTemp) < 0.0001f) {
newTemp = settings.heating.freezeProtection.lowTemp;
}
return newTemp;
}
};
+5 -6
View File
@@ -34,7 +34,6 @@ public:
OT_DHW_BURNER_HOURS = 24,
OT_HEATING_PUMP_HOURS = 25,
OT_DHW_PUMP_HOURS = 26,
OT_COOLING_HOURS = 27,
NTC_10K_TEMP = 50,
DALLAS_TEMP = 51,
@@ -150,7 +149,7 @@ public:
static int16_t getIdByName(const char* name) {
if (settings == nullptr) {
return -1;
return 0;
}
for (uint8_t id = 0; id <= getMaxSensorId(); id++) {
@@ -164,7 +163,7 @@ public:
static int16_t getIdByObjectId(const char* objectId) {
if (settings == nullptr) {
return -1;
return 0;
}
String refObjectId;
@@ -330,12 +329,12 @@ public:
static float getMeanValueByPurpose(Purpose purpose, const ValueType valueType, bool onlyConnected = true) {
if (settings == nullptr || results == nullptr) {
return 0.0f;
return 0;
}
uint8_t valueId = (uint8_t) valueType;
if (!isValidValueId(valueId)) {
return 0.0f;
return 0;
}
float value = 0.0f;
@@ -364,7 +363,7 @@ public:
static bool existsConnectedSensorsByPurpose(Purpose purpose) {
if (settings == nullptr || results == nullptr) {
return false;
return 0;
}
for (uint8_t id = 0; id <= getMaxSensorId(); id++) {
+6 -11
View File
@@ -66,8 +66,7 @@ public:
}
protected:
const unsigned int wiredDisconnectTimeout = 180000u;
const unsigned int wirelessDisconnectTimeout = 600000u;
const unsigned int disconnectedTimeout = 120000;
const unsigned short dallasSearchInterval = 60000;
const unsigned short dallasPollingInterval = 10000;
const unsigned short globalPollingInterval = 15000;
@@ -1005,16 +1004,12 @@ protected:
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
Sensors::setConnectionStatusById(sensorId, false, false);
} else if (rSensor.connected) {
if (sSensor.type == Sensors::Type::MANUAL || sSensor.type == Sensors::Type::BLUETOOTH) {
if ((millis() - rSensor.activityTime) > this->wirelessDisconnectTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false);
}
} else if (sSensor.type != Sensors::Type::MANUAL && rSensor.connected && (millis() - rSensor.activityTime) > this->disconnectedTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false);
} else if ((millis() - rSensor.activityTime) > this->wiredDisconnectTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false);
}
}
}/* else if (!rSensor.connected) {
rSensor.connected = true;
}*/
}
}
+5 -32
View File
@@ -1,5 +1,3 @@
// NetworkSettings struct is append-only. The file is persisted across updates,
// and removing/modifying existing keys will lead to file corruption.
struct NetworkSettings {
char hostname[25] = DEFAULT_HOSTNAME;
bool useDhcp = true;
@@ -22,22 +20,6 @@ struct NetworkSettings {
char password[65] = DEFAULT_STA_PASSWORD;
uint8_t channel = 0;
} sta;
struct {
bool enabled = DEFAULT_ETHERNET_ENABLED;
// nothing reads this yet: the W5500 is the only implementation the firmware can drive
EthernetImplementation implementation = EthernetImplementation::W5500;
struct {
uint8_t clk = DEFAULT_ETH_CLK_GPIO;
uint8_t mosi = DEFAULT_ETH_MOSI_GPIO;
uint8_t miso = DEFAULT_ETH_MISO_GPIO;
uint8_t cs = DEFAULT_ETH_CS_GPIO;
uint8_t irq = DEFAULT_ETH_IRQ_GPIO;
uint8_t rst = DEFAULT_ETH_RST_GPIO;
} w5500;
} ethernet;
} networkSettings;
struct Settings {
@@ -96,8 +78,7 @@ struct Settings {
bool autoFaultReset = false;
bool autoDiagReset = false;
bool setDateAndTime = false;
bool alwaysSendIndoorTemp = true;
bool nativeOTC = false;
bool nativeHeatingControl = false;
bool immergasFix = false;
} options;
} opentherm;
@@ -122,25 +103,20 @@ struct Settings {
bool enabled = true;
bool turbo = false;
float target = DEFAULT_HEATING_TARGET_TEMP;
float hysteresis = 0.5f;
float turboFactor = 7.5f;
uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP;
uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP;
uint8_t maxModulation = 100;
struct {
bool enabled = true;
float value = 0.5f;
HysteresisAction action = HysteresisAction::DISABLE_HEATING;
} hysteresis;
struct {
uint8_t highTemp = 95;
uint8_t lowTemp = 90;
} overheatProtection;
struct {
uint8_t highTemp = 15;
uint8_t lowTemp = 10;
unsigned short thresholdTime = 600;
} freezeProtection;
} heating;
@@ -150,7 +126,7 @@ struct Settings {
uint8_t minTemp = DEFAULT_DHW_MIN_TEMP;
uint8_t maxTemp = DEFAULT_DHW_MAX_TEMP;
uint8_t maxModulation = 100;
struct {
uint8_t highTemp = 95;
uint8_t lowTemp = 90;
@@ -290,7 +266,6 @@ struct Variables {
struct {
bool connected = false;
int8_t rssi = 0;
NetworkUtils::NetworkMgr::Uplink connectionType = NetworkUtils::NetworkMgr::Uplink::None;
} network;
struct {
@@ -323,7 +298,6 @@ struct Variables {
bool enabled = false;
bool indoorTempControl = false;
bool overheat = false;
bool freezing = false;
float setpointTemp = 0.0f;
float targetTemp = 0.0f;
float currentTemp = 0.0f;
@@ -409,7 +383,6 @@ struct Variables {
uint16_t dhwBurnerStarts = 0;
uint16_t heatingPumpStarts = 0;
uint16_t dhwPumpStarts = 0;
uint16_t coolingHours = 0;
uint16_t burnerHours = 0;
uint16_t dhwBurnerHours = 0;
uint16_t heatingPumpHours = 0;
@@ -459,4 +432,4 @@ struct Variables {
bool restarting = false;
bool upgrading = false;
} states;
} vars;
} vars;
+2 -45
View File
@@ -54,11 +54,6 @@
#define USE_BLE false
#endif
// ethernet (W5500 over SPI) is only validated on the esp32_c6 target: off everywhere else
#ifndef USE_ETHERNET
#define USE_ETHERNET false
#endif
#ifndef DEFAULT_HOSTNAME
#define DEFAULT_HOSTNAME ""
#endif
@@ -87,34 +82,6 @@
#define DEFAULT_STATUS_LED_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETHERNET_ENABLED
#define DEFAULT_ETHERNET_ENABLED false
#endif
#ifndef DEFAULT_ETH_CLK_GPIO
#define DEFAULT_ETH_CLK_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETH_MOSI_GPIO
#define DEFAULT_ETH_MOSI_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETH_MISO_GPIO
#define DEFAULT_ETH_MISO_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETH_CS_GPIO
#define DEFAULT_ETH_CS_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETH_IRQ_GPIO
#define DEFAULT_ETH_IRQ_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_ETH_RST_GPIO
#define DEFAULT_ETH_RST_GPIO GPIO_IS_NOT_CONFIGURED
#endif
#ifndef DEFAULT_PORTAL_LOGIN
#define DEFAULT_PORTAL_LOGIN ""
#endif
@@ -180,7 +147,7 @@
#endif
#ifndef PROGMEM
#define PROGMEM
#define PROGMEM
#endif
#ifdef ARDUINO_ARCH_ESP32
@@ -196,14 +163,4 @@ enum class UnitSystem : uint8_t {
IMPERIAL = 1
};
enum class HysteresisAction : uint8_t {
DISABLE_HEATING = 0,
SET_ZERO_TARGET = 1
};
enum class EthernetImplementation : uint8_t {
NONE = 0,
W5500 = 1
};
char buffer[255];
char buffer[255];
+1 -16
View File
@@ -74,7 +74,7 @@ void setup() {
return tm{sec, min, hour};
});
Serial.begin(115200);
#if ARDUINO_USB_MODE
Serial.setTxBufferSize(512);
@@ -84,9 +84,6 @@ void setup() {
//
// Network settings
// The network file has to survive updates, this ensures it doesn't get wiped when the structure is modified
fsNetworkSettings.addWithoutWipe(true);
switch (fsNetworkSettings.read()) {
case FD_FS_ERR:
Log.swarningln(FPSTR(L_NETWORK_SETTINGS), F("Filesystem error, load default"));
@@ -157,18 +154,6 @@ void setup() {
break;
}
// ethernet (W5500) is configured from the network settings, after they are loaded
network
->setEthernet(networkSettings.ethernet.enabled)
->setEthernetPins(
networkSettings.ethernet.w5500.clk,
networkSettings.ethernet.w5500.mosi,
networkSettings.ethernet.w5500.miso,
networkSettings.ethernet.w5500.cs,
networkSettings.ethernet.w5500.irq,
networkSettings.ethernet.w5500.rst
);
// generate mqtt prefix if it is empty
if (!strlen(settings.mqtt.prefix)) {
strcpy(settings.mqtt.prefix, getChipId("otgateway_").c_str());
+1 -17
View File
@@ -34,7 +34,6 @@ const char L_CASCADE_OUTPUT[] PROGMEM = "CASCADE.OUTPUT";
const char L_EXTPUMP[] PROGMEM = "EXTPUMP";
const char S_ACTION[] PROGMEM = "action";
const char S_ACTIONS[] PROGMEM = "actions";
const char S_ACTIVE[] PROGMEM = "active";
const char S_ADDRESS[] PROGMEM = "address";
@@ -48,7 +47,6 @@ const char S_AUTO_FAULT_RESET[] PROGMEM = "autoFaultReset";
const char S_BACKTRACE[] PROGMEM = "backtrace";
const char S_BATTERY[] PROGMEM = "battery";
const char S_BAUDRATE[] PROGMEM = "baudrate";
const char S_BLE[] PROGMEM = "ble";
const char S_BLOCKING[] PROGMEM = "blocking";
const char S_BSSID[] PROGMEM = "bssid";
const char S_BUILD[] PROGMEM = "build";
@@ -56,18 +54,14 @@ const char S_CASCADE_CONTROL[] PROGMEM = "cascadeControl";
const char S_CHANNEL[] PROGMEM = "channel";
const char S_CH2_ALWAYS_ENABLED[] PROGMEM = "ch2AlwaysEnabled";
const char S_CHIP[] PROGMEM = "chip";
const char S_CLK[] PROGMEM = "clk";
const char S_CODE[] PROGMEM = "code";
const char S_CONNECTED[] PROGMEM = "connected";
const char S_CONFIGURED[] PROGMEM = "configured";
const char S_CONNECTION_TYPE[] PROGMEM = "connectionType";
const char S_CONTINUES[] PROGMEM = "continues";
const char S_COOLING[] PROGMEM = "cooling";
const char S_COOLING_SUPPORT[] PROGMEM = "coolingSupport";
const char S_CORE[] PROGMEM = "core";
const char S_CORES[] PROGMEM = "cores";
const char S_CRASH[] PROGMEM = "crash";
const char S_CS[] PROGMEM = "cs";
const char S_CURRENT_TEMP[] PROGMEM = "currentTemp";
const char S_DATA[] PROGMEM = "data";
const char S_DATE[] PROGMEM = "date";
@@ -87,14 +81,11 @@ const char S_ENABLED[] PROGMEM = "enabled";
const char S_ENV[] PROGMEM = "env";
const char S_EPC[] PROGMEM = "epc";
const char S_EQUITHERM[] PROGMEM = "equitherm";
const char S_ETHERNET[] PROGMEM = "ethernet";
const char S_EXPONENT[] PROGMEM = "exponent";
const char S_EXTERNAL_PUMP[] PROGMEM = "externalPump";
const char S_FACTOR[] PROGMEM = "factor";
const char S_FAULT[] PROGMEM = "fault";
const char S_FEATURES[] PROGMEM = "features";
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
const char S_FREEZING[] PROGMEM = "freezing";
const char S_FILTERING[] PROGMEM = "filtering";
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
const char S_FLAGS[] PROGMEM = "flags";
@@ -118,7 +109,6 @@ const char S_HYSTERESIS[] PROGMEM = "hysteresis";
const char S_ID[] PROGMEM = "id";
const char S_IGNORE_DIAG_STATE[] PROGMEM = "ignoreDiagState";
const char S_IMMERGAS_FIX[] PROGMEM = "immergasFix";
const char S_ALWAYS_SEND_INDOOR_TEMP[] PROGMEM = "alwaysSendIndoorTemp";
const char S_INDOOR_TEMP[] PROGMEM = "indoorTemp";
const char S_INDOOR_TEMP_CONTROL[] PROGMEM = "indoorTempControl";
const char S_IN_GPIO[] PROGMEM = "inGpio";
@@ -126,7 +116,6 @@ const char S_INPUT[] PROGMEM = "input";
const char S_INTERVAL[] PROGMEM = "interval";
const char S_INVERT_STATE[] PROGMEM = "invertState";
const char S_IP[] PROGMEM = "ip";
const char S_IRQ[] PROGMEM = "irq";
const char S_I_FACTOR[] PROGMEM = "i_factor";
const char S_I_MULTIPLIER[] PROGMEM = "i_multiplier";
const char S_LOGIN[] PROGMEM = "login";
@@ -147,13 +136,11 @@ const char S_MIN_FREE[] PROGMEM = "minFree";
const char S_MIN_MAX_FREE_BLOCK[] PROGMEM = "minMaxFreeBlock";
const char S_MIN_POWER[] PROGMEM = "minPower";
const char S_MIN_TEMP[] PROGMEM = "minTemp";
const char S_MISO[] PROGMEM = "miso";
const char S_MODEL[] PROGMEM = "model";
const char S_MOSI[] PROGMEM = "mosi";
const char S_MODULATION[] PROGMEM = "modulation";
const char S_MQTT[] PROGMEM = "mqtt";
const char S_NAME[] PROGMEM = "name";
const char S_NATIVE_OTC[] PROGMEM = "nativeOTC";
const char S_NATIVE_HEATING_CONTROL[] PROGMEM = "nativeHeatingControl";
const char S_NETWORK[] PROGMEM = "network";
const char S_NTP[] PROGMEM = "ntp";
const char S_OFFSET[] PROGMEM = "offset";
@@ -170,7 +157,6 @@ const char S_OVERHEAT_PROTECTION[] PROGMEM = "overheatProtectio
const char S_PASSWORD[] PROGMEM = "password";
const char S_PID[] PROGMEM = "pid";
const char S_PORT[] PROGMEM = "port";
const char S_PINS[] PROGMEM = "pins";
const char S_PORTAL[] PROGMEM = "portal";
const char S_POST_CIRCULATION_TIME[] PROGMEM = "postCirculationTime";
const char S_POWER[] PROGMEM = "power";
@@ -188,7 +174,6 @@ const char S_RESTART[] PROGMEM = "restart";
const char S_RETURN_TEMP[] PROGMEM = "returnTemp";
const char S_REV[] PROGMEM = "rev";
const char S_RSSI[] PROGMEM = "rssi";
const char S_RST[] PROGMEM = "rst";
const char S_RX_LED_GPIO[] PROGMEM = "rxLedGpio";
const char S_SDK[] PROGMEM = "sdk";
const char S_SENSORS[] PROGMEM = "sensors";
@@ -202,7 +187,6 @@ const char S_SIZE[] PROGMEM = "size";
const char S_SLAVE[] PROGMEM = "slave";
const char S_SLOPE[] PROGMEM = "slope";
const char S_SSID[] PROGMEM = "ssid";
const char S_STARTED[] PROGMEM = "started";
const char S_STA[] PROGMEM = "sta";
const char S_STATE[] PROGMEM = "state";
const char S_STATIC_CONFIG[] PROGMEM = "staticConfig";
+38 -156
View File
@@ -296,24 +296,8 @@ void networkSettingsToJson(const NetworkSettings& src, JsonVariant dst) {
dst[FPSTR(S_STA)][FPSTR(S_SSID)] = src.sta.ssid;
dst[FPSTR(S_STA)][FPSTR(S_PASSWORD)] = src.sta.password;
dst[FPSTR(S_STA)][FPSTR(S_CHANNEL)] = src.sta.channel;
#if USE_ETHERNET
auto ethernet = dst[FPSTR(S_ETHERNET)].to<JsonObject>();
ethernet[FPSTR(S_ENABLED)] = src.ethernet.enabled;
auto pins = ethernet[FPSTR(S_PINS)].to<JsonObject>();
pins[FPSTR(S_CLK)] = src.ethernet.w5500.clk;
pins[FPSTR(S_MOSI)] = src.ethernet.w5500.mosi;
pins[FPSTR(S_MISO)] = src.ethernet.w5500.miso;
pins[FPSTR(S_CS)] = src.ethernet.w5500.cs;
pins[FPSTR(S_IRQ)] = src.ethernet.w5500.irq;
pins[FPSTR(S_RST)] = src.ethernet.w5500.rst;
#endif
}
bool jsonToEthernetPins(const JsonVariantConst src, NetworkSettings& dst, bool& changed);
bool jsonToNetworkSettings(const JsonVariantConst src, NetworkSettings& dst) {
bool changed = false;
@@ -429,19 +413,6 @@ bool jsonToNetworkSettings(const JsonVariantConst src, NetworkSettings& dst) {
}
}
// ethernet
if (src[FPSTR(S_ETHERNET)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_ETHERNET)][FPSTR(S_ENABLED)].as<bool>();
if (value != dst.ethernet.enabled) {
dst.ethernet.enabled = value;
changed = true;
}
}
jsonToEthernetPins(src[FPSTR(S_ETHERNET)][FPSTR(S_PINS)], dst, changed);
return changed;
}
@@ -497,10 +468,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
otOptions[FPSTR(S_AUTO_FAULT_RESET)] = src.opentherm.options.autoFaultReset;
otOptions[FPSTR(S_AUTO_DIAG_RESET)] = src.opentherm.options.autoDiagReset;
otOptions[FPSTR(S_SET_DATE_AND_TIME)] = src.opentherm.options.setDateAndTime;
otOptions[FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)] = src.opentherm.options.alwaysSendIndoorTemp;
otOptions[FPSTR(S_NATIVE_OTC)] = src.opentherm.options.nativeOTC;
otOptions[FPSTR(S_NATIVE_HEATING_CONTROL)] = src.opentherm.options.nativeHeatingControl;
otOptions[FPSTR(S_IMMERGAS_FIX)] = src.opentherm.options.immergasFix;
auto mqtt = dst[FPSTR(S_MQTT)].to<JsonObject>();
mqtt[FPSTR(S_ENABLED)] = src.mqtt.enabled;
@@ -521,9 +490,7 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
heating[FPSTR(S_ENABLED)] = src.heating.enabled;
heating[FPSTR(S_TURBO)] = src.heating.turbo;
heating[FPSTR(S_TARGET)] = roundf(src.heating.target, 2);
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)] = src.heating.hysteresis.enabled;
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)] = roundf(src.heating.hysteresis.value, 3);
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)] = static_cast<uint8_t>(src.heating.hysteresis.action);
heating[FPSTR(S_HYSTERESIS)] = roundf(src.heating.hysteresis, 3);
heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3);
heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp;
heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp;
@@ -534,8 +501,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp;
auto freezeProtection = heating[FPSTR(S_FREEZE_PROTECTION)].to<JsonObject>();
freezeProtection[FPSTR(S_HIGH_TEMP)] = src.heating.freezeProtection.highTemp;
freezeProtection[FPSTR(S_LOW_TEMP)] = src.heating.freezeProtection.lowTemp;
freezeProtection[FPSTR(S_THRESHOLD_TIME)] = src.heating.freezeProtection.thresholdTime;
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
@@ -602,55 +569,6 @@ inline void safeSettingsToJson(const Settings& src, JsonVariant dst) {
settingsToJson(src, dst, true);
}
/**
* @brief Parse a single GPIO value: an empty string means "not configured"
*
* @return true if the key existed in the source document
*/
bool jsonToGpioValue(const JsonVariantConst src, const __FlashStringHelper* key, uint8_t& dst, bool& changed) {
if (src[key].isNull()) {
return false;
}
if (src[key].is<JsonString>() && src[key].as<JsonString>().size() == 0) {
if (dst != GPIO_IS_NOT_CONFIGURED) {
dst = GPIO_IS_NOT_CONFIGURED;
changed = true;
}
return true;
}
unsigned char value = src[key].as<unsigned char>();
if (GPIO_IS_VALID(value) && value != dst) {
dst = value;
changed = true;
}
return true;
}
/**
* @brief Parse the W5500 pinout from an object holding clk/mosi/miso/cs/irq/rst
*
* @return true if the source object exists
*/
bool jsonToEthernetPins(const JsonVariantConst src, NetworkSettings& dst, bool& changed) {
if (src.isNull()) {
return false;
}
jsonToGpioValue(src, FPSTR(S_CLK), dst.ethernet.w5500.clk, changed);
jsonToGpioValue(src, FPSTR(S_MOSI), dst.ethernet.w5500.mosi, changed);
jsonToGpioValue(src, FPSTR(S_MISO), dst.ethernet.w5500.miso, changed);
jsonToGpioValue(src, FPSTR(S_CS), dst.ethernet.w5500.cs, changed);
jsonToGpioValue(src, FPSTR(S_IRQ), dst.ethernet.w5500.irq, changed);
jsonToGpioValue(src, FPSTR(S_RST), dst.ethernet.w5500.rst, changed);
return true;
}
bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false) {
bool changed = false;
@@ -775,6 +693,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
// portal
if (src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].is<bool>()) {
bool value = src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].as<bool>();
@@ -1082,20 +1001,11 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)].is<bool>()) {
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)].as<bool>();
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_HEATING_CONTROL)].is<bool>()) {
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_HEATING_CONTROL)].as<bool>();
if (value != dst.opentherm.options.alwaysSendIndoorTemp) {
dst.opentherm.options.alwaysSendIndoorTemp = value;
changed = true;
}
}
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_OTC)].is<bool>()) {
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_OTC)].as<bool>();
if (value != dst.opentherm.options.nativeOTC) {
dst.opentherm.options.nativeOTC = value;
if (value != dst.opentherm.options.nativeHeatingControl) {
dst.opentherm.options.nativeHeatingControl = value;
if (value) {
dst.equitherm.enabled = false;
@@ -1115,6 +1025,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
// mqtt
if (src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].as<bool>();
@@ -1205,7 +1116,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].as<bool>();
if (!dst.opentherm.options.nativeOTC) {
if (!dst.opentherm.options.nativeHeatingControl) {
if (value != dst.equitherm.enabled) {
dst.equitherm.enabled = value;
changed = true;
@@ -1258,7 +1169,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (src[FPSTR(S_PID)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_PID)][FPSTR(S_ENABLED)].as<bool>();
if (!dst.opentherm.options.nativeOTC) {
if (!dst.opentherm.options.nativeHeatingControl) {
if (value != dst.pid.enabled) {
dst.pid.enabled = value;
changed = true;
@@ -1403,41 +1314,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
if (src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].as<bool>();
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].isNull()) {
float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].as<float>();
if (value != dst.heating.hysteresis.enabled) {
dst.heating.hysteresis.enabled = value;
if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis) > 0.0001f) {
dst.heating.hysteresis = roundf(value, 2);
changed = true;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].isNull()) {
float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].as<float>();
if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis.value) > 0.0001f) {
dst.heating.hysteresis.value = roundf(value, 2);
changed = true;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].isNull()) {
uint8_t value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].as<uint8_t>();
switch (value) {
case static_cast<uint8_t>(HysteresisAction::DISABLE_HEATING):
case static_cast<uint8_t>(HysteresisAction::SET_ZERO_TARGET):
if (static_cast<uint8_t>(dst.heating.hysteresis.action) != value) {
dst.heating.hysteresis.action = static_cast<HysteresisAction>(value);
changed = true;
}
break;
default:
break;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].isNull()) {
float value = src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].as<float>();
@@ -1503,15 +1388,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
changed = true;
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].as<uint8_t>();
if (isValidTemp(value, dst.system.unitSystem, 1, 50) && value != dst.heating.freezeProtection.highTemp) {
dst.heating.freezeProtection.highTemp = value;
changed = true;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].as<uint8_t>();
@@ -1521,9 +1397,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
if (dst.heating.freezeProtection.highTemp < dst.heating.freezeProtection.lowTemp) {
dst.heating.freezeProtection.highTemp = dst.heating.freezeProtection.lowTemp;
changed = true;
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].as<unsigned short>();
if (value >= 30 && value <= 1800) {
if (value != dst.heating.freezeProtection.thresholdTime) {
dst.heating.freezeProtection.thresholdTime = value;
changed = true;
}
}
}
@@ -1794,7 +1676,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
// force check emergency target
{
float value = !src[FPSTR(S_EMERGENCY)][FPSTR(S_TARGET)].isNull() ? src[FPSTR(S_EMERGENCY)][FPSTR(S_TARGET)].as<float>() : dst.emergency.target;
bool noRegulators = !dst.opentherm.options.nativeOTC;
bool noRegulators = !dst.opentherm.options.nativeHeatingControl;
bool valid = isValidTemp(
value,
dst.system.unitSystem,
@@ -1819,7 +1701,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
// force check heating target
{
bool indoorTempControl = dst.equitherm.enabled || dst.pid.enabled || dst.opentherm.options.nativeOTC;
bool indoorTempControl = dst.equitherm.enabled || dst.pid.enabled || dst.opentherm.options.nativeHeatingControl;
float minTemp = indoorTempControl ? THERMOSTAT_INDOOR_MIN_TEMP : dst.heating.minTemp;
float maxTemp = indoorTempControl ? THERMOSTAT_INDOOR_MAX_TEMP : dst.heating.maxTemp;
@@ -2012,7 +1894,6 @@ bool jsonToSensorSettings(const uint8_t sensorId, const JsonVariantConst src, Se
case static_cast<uint8_t>(Sensors::Type::OT_DHW_BURNER_HOURS):
case static_cast<uint8_t>(Sensors::Type::OT_HEATING_PUMP_HOURS):
case static_cast<uint8_t>(Sensors::Type::OT_DHW_PUMP_HOURS):
case static_cast<uint8_t>(Sensors::Type::OT_COOLING_HOURS):
case static_cast<uint8_t>(Sensors::Type::NTC_10K_TEMP):
case static_cast<uint8_t>(Sensors::Type::DALLAS_TEMP):
@@ -2189,18 +2070,21 @@ bool jsonToSensorResult(const uint8_t sensorId, const JsonVariantConst src) {
return false;
}
auto& dst = Sensors::results[sensorId];
bool changed = false;
// value
if (!src[FPSTR(S_VALUE)].isNull()) {
return Sensors::setValueById(
sensorId,
src[FPSTR(S_VALUE)].as<float>(),
Sensors::ValueType::PRIMARY,
true,
true
);
float value = src[FPSTR(S_VALUE)].as<float>();
uint8_t vType = static_cast<uint8_t>(Sensors::ValueType::PRIMARY);
if (fabsf(value - dst.values[vType]) > 0.0001f) {
dst.values[vType] = roundf(value, 2);
changed = true;
}
}
return false;
return changed;
}
void varsToJson(const Variables& src, JsonVariant dst) {
@@ -2209,7 +2093,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
slave[FPSTR(S_FLAGS)] = src.slave.flags;
slave[FPSTR(S_TYPE)] = src.slave.type;
slave[FPSTR(S_APP_VERSION)] = src.slave.appVersion;
slave[FPSTR(S_PROTOCOL_VERSION)] = src.slave.protocolVersion;
slave[FPSTR(S_PROTOCOL_VERSION)] = src.slave.appVersion;
slave[FPSTR(S_CONNECTED)] = src.slave.connected;
slave[FPSTR(S_FLAME)] = src.slave.flame;
@@ -2250,7 +2134,6 @@ void varsToJson(const Variables& src, JsonVariant dst) {
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat;
mHeating[FPSTR(S_FREEZING)] = src.master.heating.freezing;
mHeating[FPSTR(S_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2);
mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);
@@ -2271,7 +2154,6 @@ void varsToJson(const Variables& src, JsonVariant dst) {
master[FPSTR(S_NETWORK)][FPSTR(S_CONNECTED)] = src.network.connected;
master[FPSTR(S_NETWORK)][FPSTR(S_RSSI)] = src.network.rssi;
master[FPSTR(S_NETWORK)][FPSTR(S_CONNECTION_TYPE)] = NetworkUtils::NetworkMgr::uplinkName(src.network.connectionType);
master[FPSTR(S_MQTT)][FPSTR(S_CONNECTED)] = src.mqtt.connected;
master[FPSTR(S_EMERGENCY)][FPSTR(S_STATE)] = src.emergency.state;
master[FPSTR(S_EXTERNAL_PUMP)][FPSTR(S_STATE)] = src.externalPump.state;
+15 -68
View File
@@ -151,7 +151,6 @@
"section": {
"static": "静态设置",
"ethernet": "以太网",
"availableNetworks": "可用网络",
"staSettings": "WiFi 设置",
"apSettings": "AP 设置"
@@ -159,20 +158,7 @@
"scan": {
"pos": "#",
"info": "Info",
"unavailable": "请启用 WiFi 以扫描网络"
},
"ethernet": {
"enable": "启用以太网",
"notConfigured": "填写全部六个 GPIO 引脚后才能启用以太网。",
"clk": "SPI 时钟 GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "中断 GPIO",
"rst": "复位 GPIO",
"note": "W5500 SPI 接线"
"info": "Info"
},
"wifi": {
@@ -190,14 +176,7 @@
"ip": "IP",
"subnet": "子网掩码",
"gateway": "网关",
"dns": "DNS 服务器",
"connection": "连接",
"connectionType": {
"ethernet": "以太网",
"wifi": "WiFi",
"wifi-ap": "WiFi 接入点",
"none": "无"
}
"dns": "DNS 服务器"
},
"sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
"otCoolingHours": "OpenTherm, number of cooling hours",
"ntcTemp": "NTC 传感器",
"dallasTemp": "DALLAS 传感器",
@@ -341,15 +319,9 @@
},
"freezeProtection": {
"title": "防冻保护",
"desc": "如果热载体或室内温度低于 <b>低温</b>,加热将被强制开启。",
"highTemp": {
"title": "高温阈值",
"note": "防冻保护激活后系统恢复正常模式的阈值"
},
"lowTemp": {
"title": "低温阈值",
"note": "强制开启加热的阈值"
}
"desc": "当热媒或室内温度在<b>等待时间</b> 内降至<b>低温阈值</b>以下时,系统将强制启动加热功能。",
"lowTemp": "低温阈值",
"thresholdTime": "等待时间<small>(秒)</small>"
},
"portal": {
@@ -384,16 +356,7 @@
},
"heating": {
"hyst": {
"title": "滞回",
"desc": "滞回有助于维持设定的室内温度(在使用«Equitherm»和/或«PID»时)。强制禁用加热当<code>current indoor > target + value</code>,启用加热当<code>current indoor < (target - value)</code>。",
"value": "值 <small>(以度为单位)</small>",
"action": {
"title": "行动",
"disableHeating": "禁用加热",
"set0target": "设置空目标"
}
},
"hyst": "滞后值<small>(单位:度)</small>",
"turboFactor": "Turbo 模式系数"
},
@@ -408,26 +371,11 @@
},
"equitherm": {
"slope": {
"title": "斜率",
"note": "热损失补偿。主要调谐参数。"
},
"exponent": {
"title": "指数",
"note": "散热器效率。典型值:<code>1.1</code> - 地板采暖,<code>1.2</code> - 铸铁,<code>1.3</code> - 面板散热器,<code>1.4</code> - 对流器。"
},
"shift": {
"title": "偏移",
"note": "补偿额外热损失(例如,在管道中)或额外热源。"
},
"targetDiffFactor": {
"title": "T 因子",
"note": "如果启用 PID,则不使用。将目标和当前室内温度之间的差值添加到设定点:<code>setpoint = setpoint + ((target - indoor) * T)</code>。"
},
"chart": {
"targetTemp": "目标室内温度",
"setpointTemp": "热载体温度",
"outdoorTemp": "室外温度"
"n": "N 系数",
"k": "K 系数",
"t": {
"title": "T 系数",
"note": "启用PID时此参数无效"
}
},
@@ -485,13 +433,12 @@
"autoFaultReset": "自动报警复位 <small>(不推荐!)</small>",
"autoDiagReset": "自动诊断复位 <small>(不推荐!)</small>",
"setDateAndTime": "同步设置锅炉日期与时间",
"immergasFix": "针对Immergas锅炉的兼容性修复",
"alwaysSendIndoorTemp": "向锅炉发送当前室内温度"
"immergasFix": "针对Immergas锅炉的兼容性修复"
},
"nativeOTC": {
"title": "原生热载体温度计算模式",
"note": "仅在锅炉处于 OTC 模式时<u>才</u>工作:需要并接受目标室内温度,并基于内置曲线模式自行调节热载体温度。与 PID 和 Equitherm 不兼容。"
"nativeHeating": {
"title": "原生锅炉供暖控制",
"note": "<u>注意:</u> 仅适用于锅炉需接收目标室温并自主调节载热介质温度的场景,与固件中的PID及Equithermq气候补偿功能不兼容。"
}
},
+10 -49
View File
@@ -119,7 +119,6 @@
"mHeatEnabled": "Heating enabled",
"mHeatBlocking": "Heating blocked",
"mHeatOverheat": "Heating overheat",
"mHeatFreezing": "Heating freezing",
"sHeatActive": "Heating active",
"mHeatSetpointTemp": "Heating setpoint temp",
"mHeatTargetTemp": "Heating target temp",
@@ -152,7 +151,6 @@
"section": {
"static": "Static settings",
"ethernet": "Ethernet",
"availableNetworks": "Available networks",
"staSettings": "WiFi settings",
"apSettings": "AP settings"
@@ -160,20 +158,7 @@
"scan": {
"pos": "#",
"info": "Info",
"unavailable": "Please enable WiFi to scan for networks"
},
"ethernet": {
"enable": "Enable ethernet",
"notConfigured": "Fill in all six GPIO pins to enable ethernet.",
"clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "W5500 SPI wiring"
"info": "Info"
},
"wifi": {
@@ -191,14 +176,7 @@
"ip": "IP",
"subnet": "Subnet",
"gateway": "Gateway",
"dns": "DNS",
"connection": "Connection",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "None"
}
"dns": "DNS"
},
"sta": {
@@ -265,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
"otCoolingHours": "OpenTherm, number of cooling hours",
"ntcTemp": "NTC sensor",
"dallasTemp": "DALLAS sensor",
@@ -342,15 +319,9 @@
},
"freezeProtection": {
"title": "Freeze protection",
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b>.",
"highTemp": {
"title": "High temperature threshold",
"note": "Threshold when the system returns to normal mode after freeze protection activation"
},
"lowTemp": {
"title": "Low temperature threshold",
"note": "Threshold when heating is forced to turn on"
}
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b> during <b>Waiting time</b>.",
"lowTemp": "Low temperature threshold",
"thresholdTime": "Waiting time <small>(sec)</small>"
},
"portal": {
@@ -385,16 +356,7 @@
},
"heating": {
"hyst": {
"title": "Hysteresis",
"desc": "Hysteresis is useful for maintaining a set indoor temp (when using «Equitherm» and/or «PID»). Forces disable heating when <code>current indoor > target + value</code> and enable heating when <code>current indoor < (target - value)</code>.",
"value": "Value <small>(in degrees)</small>",
"action": {
"title": "Action",
"disableHeating": "Disable heating",
"set0target": "Set null target"
}
},
"hyst": "Hysteresis <small>(in degrees)</small>",
"turboFactor": "Turbo mode coeff."
},
@@ -486,13 +448,12 @@
"autoFaultReset": "Auto fault reset <small>(not recommended!)</small>",
"autoDiagReset": "Auto diag reset <small>(not recommended!)</small>",
"setDateAndTime": "Set date & time on boiler",
"immergasFix": "Fix for Immergas boilers",
"alwaysSendIndoorTemp": "Send current indoor temp to boiler"
"immergasFix": "Fix for Immergas boilers"
},
"nativeOTC": {
"title": "Native OTC mode",
"note": "Works <u>ONLY</u> if the boiler is in OTC mode: requires and accepts the target indoor temperature and self-regulates the heat carrier temperature based on the built-in curves mode. Incompatible with PID and Equitherm."
"nativeHeating": {
"title": "Native heating control (boiler)",
"note": "Works <u>ONLY</u> if the boiler requires the desired room temperature and regulates the temperature of the coolant itself. Not compatible with PID and Equitherm regulators in firmware."
}
},
+16 -54
View File
@@ -151,7 +151,6 @@
"section": {
"static": "Impostazioni statico",
"ethernet": "Ethernet",
"availableNetworks": "Reti disponibili",
"staSettings": "Impostazioni WiFi",
"apSettings": "Impostazioni AP"
@@ -159,20 +158,7 @@
"scan": {
"pos": "#",
"info": "Info",
"unavailable": "Abilita il WiFi per cercare le reti"
},
"ethernet": {
"enable": "Abilita ethernet",
"notConfigured": "Compilare tutti e sei i pin GPIO per abilitare ethernet.",
"clk": "GPIO clock SPI",
"mosi": "GPIO MOSI SPI",
"miso": "GPIO MISO SPI",
"cs": "GPIO CS SPI",
"irq": "GPIO interrupt",
"rst": "GPIO reset",
"note": "Cablaggio SPI del W5500"
"info": "Info"
},
"wifi": {
@@ -190,14 +176,7 @@
"ip": "IP",
"subnet": "Subnet",
"gateway": "Gateway",
"dns": "DNS",
"connection": "Connessione",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Nessuno"
}
"dns": "DNS"
},
"sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, numero di ore di funzionamento del bruciatore (ACS)",
"otHeatingPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (riscaldamento)",
"otDhwPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (ACS)",
"otCoolingHours": "OpenTherm, numero di ore di funzionamento della cooling",
"ntcTemp": "Sensore NTC",
"dallasTemp": "Sensore DALLAS",
@@ -341,15 +319,9 @@
},
"freezeProtection": {
"title": "Protezione antigelo",
"desc": "Il riscaldamento verrà forzatamente attivato se la temperatura del vettore termico o la temperatura interna scende al di sotto della <b>Soglia di temperatura bassa</b>.",
"highTemp": {
"title": "Soglia di temperatura alta",
"note": "Soglia quando il sistema ritorna alla modalità normale dopo l'attivazione della protezione antigelo"
},
"lowTemp": {
"title": "Soglia di temperatura bassa",
"note": "Soglia quando il riscaldamento viene forzatamente attivato"
}
"desc": "Il riscaldamento verrà attivato forzatamente se la temperatura del vettore di calore o interna scende al di sotto della <b>temperatura minima</b> durante il <b>tempo di attesa</b>.",
"lowTemp": "Soglia di temperatura minima",
"thresholdTime": "Tempo di attesa <small>(sec)</small>"
},
"portal": {
@@ -384,16 +356,7 @@
},
"heating": {
"hyst": {
"title": "Isteresi",
"desc": "L'isteresi è utile per mantenere una temperatura interna impostata (quando si utilizza «Equitherm» e/o «PID»). Forza la disabilitazione del riscaldamento quando <code>current indoor > target + value</code> e abilita il riscaldamento quando <code>current indoor < (target - value)</code>.",
"value": "Valore <small>(in gradi)</small>",
"action": {
"title": "Azione",
"disableHeating": "Disabilita riscaldamento",
"set0target": "Imposta target nullo"
}
},
"hyst": "Isteresi <small>(in gradi)</small>",
"turboFactor": "Turbo mode coeff."
},
@@ -410,23 +373,23 @@
"equitherm": {
"slope": {
"title": "Pendenza",
"note": "Compensazione della perdita di calore. Parametro di regolazione principale."
"note": "Compensazione delle perdite di calore. Principale parametro di regolazione."
},
"exponent": {
"title": "Esponente",
"note": "Efficienza del radiatore. Valori tipici: <code>1.1</code> - Riscaldamento a pavimento, <code>1.2</code> - Ghisa, <code>1.3</code> - Radiatori a pannello, <code>1.4</code> - Convettori."
"note": "Efficienza del radiatore. Valori tipici: <code>1.1</code> - Riscaldamento a pavimento, <code>1.2</code> - Radiatori in ghisa, <code>1.3</code> - Radiatori a pannelli, <code>1.4</code> - Convetttori."
},
"shift": {
"title": "Spostamento",
"note": "Compensa perdite di calore aggiuntive (ad es., nelle tubature) o fonti di calore extra."
"title": "Spostare",
"note": "Compensa le perdite di calore aggiuntive (ad esempio, nelle tubature) o fonti di calore extra."
},
"targetDiffFactor": {
"title": "Fattore T",
"note": "Non utilizzato se PID è abilitato. Aggiunge al setpoint la differenza tra la temperatura target e quella interna attuale: <code>setpoint = setpoint + ((target - indoor) * T)</code>."
"note": "Non usato se PID è attivato. Aggiunge al setpoint la differenza tra la temperatura interna target e quella attuale: <code>setpoint = setpoint + ((target - indoor) * T)</code>."
},
"chart": {
"targetTemp": "Temperatura interna target",
"setpointTemp": "Temperatura del vettore termico",
"setpointTemp": "Temperatura del portatore di calore",
"outdoorTemp": "Temperatura esterna"
}
},
@@ -485,13 +448,12 @@
"autoFaultReset": "Ripristino automatico degli errori <small>(sconsigliato!)</small>",
"autoDiagReset": "Ripristino diagnostico automatica <small>(sconsigliato!)</small>",
"setDateAndTime": "Imposta data e ora sulla caldaia",
"immergasFix": "Fix per caldiaie Immergas",
"alwaysSendIndoorTemp": "Invia la temp attuale interna alla caldaia"
"immergasFix": "Fix per caldiaie Immergas"
},
"nativeOTC": {
"title": "Modalità nativa di calcolo della temperatura del vettore termico",
"note": "Funziona <u>SOLO</u> se la caldaia è in modalità OTC: richiede e accetta la temperatura interna target e regola autonomamente la temperatura del vettore termico basata sulla modalità curve integrata. Incompatibile con PID e Equitherm."
"nativeHeating": {
"title": "Controllo del riscaldamento nativo (caldaia)",
"note": "Lavora <u>SOLO</u> se la caldaia richiede la temperatura ambiente desiderata e regola autonomamente la temperatura del fluido. Non compatiblile con regolazioni PID e Equitherm del sistema."
}
},
+16 -72
View File
@@ -136,27 +136,13 @@
"name": "Netwerkinstellingen",
"section": {
"static": "Statische instellingen",
"ethernet": "Ethernet",
"availableNetworks": "Beschikbare netwerken",
"staSettings": "WiFi-instellingen",
"apSettings": "AP-instellingen"
},
"scan": {
"pos": "#",
"info": "Info",
"unavailable": "Schakel WiFi in om naar netwerken te zoeken"
},
"ethernet": {
"enable": "Ethernet inschakelen",
"notConfigured": "Vul alle zes GPIO-pinnen in om ethernet in te schakelen.",
"clk": "SPI-klok GPIO",
"mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO",
"irq": "Interrupt GPIO",
"rst": "Reset GPIO",
"note": "W5500 SPI-bedrading"
"info": "Info"
},
"wifi": {
"ssid": "SSID",
@@ -172,14 +158,7 @@
"ip": "IP",
"subnet": "Subnet",
"gateway": "Gateway",
"dns": "DNS",
"connection": "Verbinding",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Geen"
}
"dns": "DNS"
},
"sta": {
"channel.note": "zet op 0 voor automatische selectie"
@@ -243,8 +222,6 @@
"otDhwBurnerHours": "OpenTherm, aantal branderuren (warm water)",
"otHeatingPumpHours": "OpenTherm, aantal pompuren (verwarming)",
"otDhwPumpHours": "OpenTherm, aantal pompuren (warm water)",
"otCoolingHours": "OpenTherm, aantal cooling",
"ntcTemp": "NTC-sensor",
"dallasTemp": "DALLAS-sensor",
"bluetooth": "BLE-sensor",
@@ -315,18 +292,11 @@
}
},
"freezeProtection": {
"title": "Vorbeveiliging",
"desc": "Verwarming zal geforceerd worden ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur daalt onder de <b>Lage temperatuurdrempel</b>.",
"highTemp": {
"title": "Hoge temperatuurdrempel",
"note": "Drempel waarna het systeem terugkeert naar de normale modus na activering van de vorbeveiliging"
},
"lowTemp": {
"title": "Lage temperatuurdrempel",
"note": "Drempel wanneer de verwarming geforceerd wordt ingeschakeld"
}
"title": "Vorstbeveiliging",
"desc": "De verwarming wordt geforceerd ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur onder de <b>Lage temperatuur</b> daalt gedurende de <b>Wachttijd</b>.",
"lowTemp": "Drempelwaarde lage temperatuur",
"thresholdTime": "Wachttijd <small>(sec)</small>"
},
"portal": {
"login": "Gebruikersnaam",
"password": "Wachtwoord",
@@ -357,16 +327,7 @@
}
},
"heating": {
"hyst": {
"title": "Hysterese",
"desc": "Hysterese is nuttig voor het handhaven van een ingestelde binnentemperatuur (bij gebruik van «Equitherm» en/of «PID»). Forceert uitschakelen van verwarming wanneer <code>current indoor > target + value</code> en inschakelen van verwarming wanneer <code>current indoor < (target - value)</code>.",
"value": "Waarde <small>(in graden)</small>",
"action": {
"title": "Actie",
"disableHeating": "Verwarming uitschakelen",
"set0target": "Stel null target in"
}
},
"hyst": "Hysterese <small>(in graden)</small>",
"turboFactor": "Turbomodus coëff."
},
"emergency": {
@@ -378,26 +339,11 @@
"treshold": "Drempeltijd <small>(sec)</small>"
},
"equitherm": {
"slope": {
"title": "Helling",
"note": "Compensatie voor warmteverlies. Hoofdafstelparameter."
},
"exponent": {
"title": "Exponent",
"note": "Radiator efficiëntie. Typische waarden: <code>1.1</code> - Vloerverwarming, <code>1.2</code> - Gietijzer, <code>1.3</code> - Paneelradiatoren, <code>1.4</code> - Convectors."
},
"shift": {
"title": "Verschuiving",
"note": "Compenseert voor extra warmteverliezen (bijv. in leidingen) of extra warmtebronnen."
},
"targetDiffFactor": {
"title": "T factor",
"note": "Niet gebruikt als PID is ingeschakeld. Voegt aan de setpoint de verschil tussen de target en huidige binnentemperatuur toe: <code>setpoint = setpoint + ((target - indoor) * T)</code>."
},
"chart": {
"targetTemp": "Doel binnentemperatuur",
"setpointTemp": "Warmtedrager temperatuur",
"outdoorTemp": "Buitentemperatuur"
"n": "N-factor",
"k": "K-factor",
"t": {
"title": "T-factor",
"note": "Niet gebruikt als PID is ingeschakeld"
}
},
"pid": {
@@ -452,13 +398,11 @@
"autoFaultReset": "Automatische storingsreset <small>(niet aanbevolen!)</small>",
"autoDiagReset": "Automatische diagnosereset <small>(niet aanbevolen!)</small>",
"setDateAndTime": "Stel datum & tijd in op ketel",
"immergasFix": "Fix voor Immergas-ketels",
"alwaysSendIndoorTemp": "Stuur huidige binnentemp naar ketel"
"immergasFix": "Fix voor Immergas-ketels"
},
"nativeOTC": {
"title": "Native warmtedrager temperatuur berekeningsmodus",
"note": "Werkt <u>ALLEEN</u> als de ketel in OTC-modus is: vereist en accepteert de doel binnentemperatuur en regelt zelf de warmtedrager temperatuur op basis van de ingebouwde curves modus. Incompatibel met PID en Equitherm."
"nativeHeating": {
"title": "Natuurlijke verwarmingsregeling (ketel)",
"note": "Werkt <u>ALLEEN</u> als de ketel de gewenste kamertemperatuur vereist en zelf de temperatuur van de warmtedrager regelt. Niet compatibel met PID- en Equitherm-regelaars in de firmware."
}
},
"mqtt": {
+10 -48
View File
@@ -151,7 +151,6 @@
"section": {
"static": "Статические параметры",
"ethernet": "Ethernet",
"availableNetworks": "Доступные сети",
"staSettings": "Настройки подключения",
"apSettings": "Настройки точки доступа"
@@ -159,20 +158,7 @@
"scan": {
"pos": "#",
"info": "Инфо",
"unavailable": "Включите WiFi, чтобы искать сети"
},
"ethernet": {
"enable": "Включить ethernet",
"notConfigured": "Заполните все шесть выводов GPIO, чтобы включить ethernet.",
"clk": "GPIO тактирования SPI",
"mosi": "GPIO MOSI SPI",
"miso": "GPIO MISO SPI",
"cs": "GPIO CS SPI",
"irq": "GPIO прерывания",
"rst": "GPIO сброса",
"note": "Подключение W5500 по SPI"
"info": "Инфо"
},
"wifi": {
@@ -190,14 +176,7 @@
"ip": "IP адрес",
"subnet": "Адрес подсети",
"gateway": "Адрес шлюза",
"dns": "DNS адрес",
"connection": "Подключение",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Нет"
}
"dns": "DNS адрес"
},
"sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, кол-во часов работы горелки (ГВС)",
"otHeatingPumpHours": "OpenTherm, кол-во часов работы насоса (отопление)",
"otDhwPumpHours": "OpenTherm, кол-во часов работы насоса (ГВС)",
"otCoolingHours": "OpenTherm, кол-во часов работы охлаждения",
"ntcTemp": "NTC датчик",
"dallasTemp": "DALLAS датчик",
@@ -341,15 +319,9 @@
},
"freezeProtection": {
"title": "Защита от замерзания",
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b>.",
"highTemp": {
"title": "Верхний порог температуры",
"note": "Порог, при котором система вернется в нормальное состояние после активации защиты от замерзания"
},
"lowTemp": {
"title": "Нижний порог температуры",
"note": "Порог, при котором отопление будет принудительно включено"
}
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b> в течение <b>времени ожидания</b>.",
"lowTemp": "Нижний порог температуры",
"thresholdTime": "Время ожидания <small>(сек)</small>"
},
"portal": {
@@ -384,16 +356,7 @@
},
"heating": {
"hyst": {
"title": "Гистерезис",
"desc": "Гистерезис полезен для поддержания заданной внутр. темп. (при использовании «ПЗА» и/или «ПИД»). Принудительно откл. отопление, когда <code>current indoor > target + value</code>, и вкл. отопление, когда <code>current indoor < (target - value)</code>.",
"value": "Значение <small>(в градусах)</small>",
"action": {
"title": "Действие",
"disableHeating": "Отключить отопление",
"set0target": "Установить 0 в качестве целевой темп."
}
},
"hyst": "Гистерезис <small>(в градусах)</small>",
"turboFactor": "Коэфф. турбо режима"
},
@@ -485,13 +448,12 @@
"autoFaultReset": "Автоматический сброс ошибок <small>(не рекомендуется!)</small>",
"autoDiagReset": "Автоматический сброс диагностики <small>(не рекомендуется!)</small>",
"setDateAndTime": "Устанавливать время и дату на котле",
"immergasFix": "Фикс для котлов Immergas",
"alwaysSendIndoorTemp": "Передавать текущую темп. в помещении котлу"
"immergasFix": "Фикс для котлов Immergas"
},
"nativeOTC": {
"title": "Нативный режим OTC (расчёт температуры теплоносителя)",
"note": "Работает <u>ТОЛЬКО</u> если котел в режиме OTC: требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
"nativeHeating": {
"title": "Передать управление отоплением котлу",
"note": "Работает <u>ТОЛЬКО</u> если котел требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
}
},
+1 -10
View File
@@ -195,10 +195,6 @@
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
<td><i class="mHeatOverheat"></i></td>
</tr>
<tr>
<th scope="row" data-i18n>dashboard.states.mHeatFreezing</th>
<td><i class="mHeatFreezing"></i></td>
</tr>
<tr>
<th scope="row" data-i18n>dashboard.states.sHeatActive</th>
<td><i class="sHeatActive"></i></td>
@@ -324,7 +320,7 @@
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
lang.build();
let actionTimer = null;
let actionLongPress = false;
@@ -637,11 +633,6 @@
result.master.heating.overheat ? "success" : "error",
result.master.heating.overheat ? "red" : "green"
);
setStatus(
'.mHeatFreezing',
result.master.heating.freezing ? "success" : "error",
result.master.heating.freezing ? "red" : "green"
);
setValue('.mHeatSetpointTemp', result.master.heating.setpointTemp);
setValue('.mHeatTargetTemp', result.master.heating.targetTemp);
setValue('.mHeatCurrTemp', result.master.heating.currentTemp);
+3 -16
View File
@@ -50,19 +50,15 @@
<th scope="row" data-i18n>network.params.mac</th>
<td><b id="network-mac"></b></td>
</tr>
<tr>
<th scope="row" data-i18n>network.params.connection</th>
<td><b id="network-connection"></b></td>
</tr>
<tr>
<th scope="row" data-i18n>network.wifi.connected</th>
<td><i id="network-connected"></i></td>
</tr>
<tr id="network-ssid-row">
<tr>
<th scope="row" data-i18n>network.wifi.ssid</th>
<td><b id="network-ssid"></b></td>
</tr>
<tr id="network-signal-row">
<tr>
<th scope="row" data-i18n>network.wifi.signal</th>
<td><b id="network-signal"></b> %</td>
</tr>
@@ -173,7 +169,7 @@
<script>
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
lang.build();
setTimeout(async function onLoadPage() {
try {
@@ -196,7 +192,6 @@
setValue('#network-hostname', result.network.hostname);
setValue('#network-mac', result.network.mac);
setValue('#network-connection', i18n(`network.params.connectionType.${result.network.connectionType}`));
setStatus(
'#network-connected',
result.network.connected ? "success" : "error",
@@ -204,14 +199,6 @@
);
setValue('#network-ssid', result.network.ssid);
setValue('#network-signal', result.network.signalQuality);
// SSID and signal strength only describe the uplink when WiFi carries it; with
// ethernet up the radio is parked and both values are meaningless
const wifiUplink = result.network.connectionType === "wifi";
document.getElementById("network-ssid-row")?.classList.toggle("hidden", !wifiUplink);
document.getElementById("network-signal-row")?.classList.toggle("hidden", !wifiUplink);
setValue('#network-ip', result.network.ip);
setValue('#network-subnet', result.network.subnet);
setValue('#network-gateway', result.network.gateway);
+7 -116
View File
@@ -79,7 +79,6 @@
</div>
</article>
<article>
<div>
<hgroup>
@@ -101,7 +100,6 @@
</table>
</div>
<p id="scan-unavailable" class="hidden" data-i18n>network.scan.unavailable</p>
<button type="submit" data-i18n>button.refresh</button>
</form>
@@ -164,62 +162,6 @@
</form>
</div>
</article>
<article id="ethernet-section" class="hidden">
<div>
<hgroup>
<h3 data-i18n>network.section.ethernet</h3>
<p></p>
</hgroup>
<div id="ethernet-settings-busy" aria-busy="true"></div>
<form action="/api/network/settings" id="ethernet-settings" class="hidden">
<label>
<input type="checkbox" name="ethernet[enabled]" value="true">
<span data-i18n>network.ethernet.enable</span>
</label>
<small id="ethernet-not-configured" class="hidden" data-i18n>network.ethernet.notConfigured</small>
<div class="grid">
<label>
<span data-i18n>network.ethernet.clk</span>
<input type="number" inputmode="numeric" name="ethernet[pins][clk]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.mosi</span>
<input type="number" inputmode="numeric" name="ethernet[pins][mosi]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.miso</span>
<input type="number" inputmode="numeric" name="ethernet[pins][miso]" min="0" max="254" step="1">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>network.ethernet.cs</span>
<input type="number" inputmode="numeric" name="ethernet[pins][cs]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.irq</span>
<input type="number" inputmode="numeric" name="ethernet[pins][irq]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.rst</span>
<input type="number" inputmode="numeric" name="ethernet[pins][rst]" min="0" max="254" step="1">
</label>
</div>
<small data-i18n>network.ethernet.note</small>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</article>
</main>
<footer class="container">
@@ -237,7 +179,7 @@
<script>
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
lang.build();
const fillData = (data) => {
setInputValue("[name='hostname']", data.hostname);
@@ -248,29 +190,6 @@
setInputValue("[name='staticConfig[dns]']", data.staticConfig.dns);
setBusy('#network-settings-busy', '#network-settings', false);
const ethernet = data.ethernet || {};
const ethernetConfigured = !!ethernet.configured;
const ethernetPins = ethernet.pins || {};
const pinValue = (value) => (value ?? 255) < 255 ? value : '';
setInputValue("[name='ethernet[pins][clk]']", pinValue(ethernetPins.clk));
setInputValue("[name='ethernet[pins][mosi]']", pinValue(ethernetPins.mosi));
setInputValue("[name='ethernet[pins][miso]']", pinValue(ethernetPins.miso));
setInputValue("[name='ethernet[pins][cs]']", pinValue(ethernetPins.cs));
setInputValue("[name='ethernet[pins][irq]']", pinValue(ethernetPins.irq));
setInputValue("[name='ethernet[pins][rst]']", pinValue(ethernetPins.rst));
setCheckboxValue("[name='ethernet[enabled]']", ethernetConfigured ? !!ethernet.enabled : false);
const ethernetCheckbox = document.querySelector("[name='ethernet[enabled]']");
if (ethernetCheckbox) {
ethernetCheckbox.disabled = !ethernetConfigured;
}
document.getElementById('ethernet-not-configured')?.classList.toggle('hidden', ethernetConfigured);
setBusy('#ethernet-settings-busy', '#ethernet-settings', false);
setInputValue("[name='sta[ssid]']", data.sta.ssid);
setInputValue("[name='sta[password]']", data.sta.password);
setInputValue("[name='sta[channel]']", data.sta.channel);
@@ -282,49 +201,21 @@
setBusy('#ap-settings-busy', '#ap-settings', false);
};
const applyCapabilities = (info) => {
// pages and firmware ship together: the section stays hidden unless the build says it can do ethernet
const supported = info?.features?.ethernet === true;
document.getElementById('ethernet-section')?.classList.toggle('hidden', !supported);
return supported;
};
try {
const [response, infoResponse] = await Promise.all([
fetch("/api/network/settings", {
cache: "no-cache",
credentials: "include"
}),
fetch("/api/info", {
cache: "no-cache",
credentials: "include"
})
]);
const response = await fetch("/api/network/settings", {
cache: "no-cache",
credentials: "include"
});
if (!response.ok) {
throw new Error('Response not valid');
}
const info = infoResponse.ok ? await infoResponse.json() : null;
const ethernetSupported = applyCapabilities(info);
const result = await response.json();
fillData(result);
setupForm('#network-settings', fillData, ['hostname']);
// scanning needs the radio, which stays parked while ethernet carries the uplink
const radioParked = info?.network?.connectionType === 'ethernet';
setupNetworkScanForm('#network-scan', '#networks', !radioParked);
document.querySelector('#network-scan button[type="submit"]').disabled = radioParked;
document.querySelector('#scan-unavailable').classList.toggle('hidden', !radioParked);
if (ethernetSupported) {
setupForm('#ethernet-settings', fillData);
}
setupNetworkScanForm('#network-scan', '#networks');
setupForm('#sta-settings', fillData, ['sta.ssid', 'sta.password']);
setupForm('#ap-settings', fillData, ['ap.ssid', 'ap.password']);
+6 -37
View File
@@ -38,8 +38,6 @@
<p></p>
</hgroup>
<small id="ble-not-supported" class="hidden" data-i18n>settings.note.bleDevice</small>
<details id="template" class="sensor hidden" data-id="" data-preloaded="0">
<summary><b>#<span class="pos"></span>: <span class="name"></span></b></summary>
@@ -115,11 +113,10 @@
<option value="24" data-i18n>sensors.types.otDhwBurnerHours</option>
<option value="25" data-i18n>sensors.types.otHeatingPumpHours</option>
<option value="26" data-i18n>sensors.types.otDhwPumpHours</option>
<option value="27" data-i18n>sensors.types.otCoolingHours</option>
<option value="50" data-i18n>sensors.types.ntcTemp</option>
<option value="51" data-i18n>sensors.types.dallasTemp</option>
<option value="52" data-requires="ble" disabled data-i18n>sensors.types.bluetooth</option>
<option value="52" data-i18n>sensors.types.bluetooth</option>
<option value="253" data-i18n>sensors.types.heatSetpointTemp</option>
<option value="254" data-i18n>sensors.types.manual</option>
<option value="255" data-i18n>sensors.types.notConfigured</option>
@@ -203,43 +200,21 @@
<script>
document.addEventListener("DOMContentLoaded", async () => {
const lang = new Lang(document.getElementById("lang"));
await lang.build();
lang.build();
const container = document.querySelector("article");
const templateNode = container.querySelector("#template");
let bleSupported = false;
const applyCapabilities = (info, root) => {
// pages and firmware ship together: BLE stays disabled unless the build says it has the stack
bleSupported = info?.features?.ble === true;
root.querySelectorAll('[data-requires="ble"]').forEach((option) => {
option.disabled = !bleSupported;
});
document.getElementById("ble-not-supported")?.classList.toggle("hidden", bleSupported);
};
try {
const [response, infoResponse] = await Promise.all([
fetch("/api/sensors", {
cache: "no-cache",
credentials: "include"
}),
fetch("/api/info", {
cache: "no-cache",
credentials: "include"
})
]);
const response = await fetch("/api/sensors", {
cache: "no-cache",
credentials: "include"
});
if (!response.ok) {
throw new Error("Response not valid");
}
const info = infoResponse.ok ? await infoResponse.json() : null;
applyCapabilities(info, templateNode);
const result = await response.json();
for (const sensorId in result) {
const sensorNode = templateNode.cloneNode(true);
@@ -311,12 +286,6 @@
// ble
case 52:
if (!bleSupported) {
parentGpio.classList.add("hidden");
parentAddress.classList.add("hidden");
break;
}
parentGpio.classList.add("hidden");
parentAddress.classList.remove("hidden");
address.setAttribute("pattern", "([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}");
+20 -60
View File
@@ -194,47 +194,20 @@
<div class="grid">
<label>
<span data-i18n>settings.heating.turboFactor</span>
<input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required>
<span data-i18n>settings.heating.hyst</span>
<input type="number" inputmode="decimal" name="heating[hysteresis]" min="0" max="5" step="0.05" required>
</label>
<label>
<span data-i18n>settings.maxModulation</span>
<input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required>
<span data-i18n>settings.heating.turboFactor</span>
<input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required>
</label>
</div>
<hr />
<details>
<summary><b data-i18n>settings.heating.hyst.title</b></summary>
<div>
<fieldset>
<label>
<input type="checkbox" name="heating[hysteresis][enabled]" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.heating.hyst.value</span>
<input type="number" inputmode="decimal" name="heating[hysteresis][value]" min="0" max="5" step="0.05" required>
</label>
<label>
<span data-i18n>settings.heating.hyst.action.title</span>
<select name="heating[hysteresis][action]">
<option value="0" data-i18n>settings.heating.hyst.action.disableHeating</option>
<option value="1" data-i18n>settings.heating.hyst.action.set0target</option>
</select>
</label>
</div>
</div>
<small data-i18n>settings.heating.hyst.desc</small>
</details>
<label>
<span data-i18n>settings.maxModulation</span>
<input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required>
</label>
<hr />
@@ -265,15 +238,13 @@
<div class="grid">
<label>
<span data-i18n>settings.freezeProtection.highTemp.title</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][highTemp]" min="0" max="0" step="1" required>
<small data-i18n>settings.freezeProtection.highTemp.note</small>
<span data-i18n>settings.freezeProtection.lowTemp</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
</label>
<label>
<span data-i18n>settings.freezeProtection.lowTemp.title</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
<small data-i18n>settings.freezeProtection.lowTemp.note</small>
<span data-i18n>settings.freezeProtection.thresholdTime</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][thresholdTime]" min="30" max="1800" step="1" required>
</label>
</div>
@@ -694,17 +665,12 @@
<span data-i18n>settings.ot.options.immergasFix</span>
</label>
<label>
<input type="checkbox" name="opentherm[options][alwaysSendIndoorTemp]" value="true">
<span data-i18n>settings.ot.options.alwaysSendIndoorTemp</span>
</label>
<hr />
<label>
<input type="checkbox" name="opentherm[options][nativeOTC]" value="true">
<span data-i18n>settings.ot.nativeOTC.title</span><br />
<small data-i18n>settings.ot.nativeOTC.note</small>
<input type="checkbox" name="opentherm[options][nativeHeatingControl]" value="true">
<span data-i18n>settings.ot.nativeHeating.title</span><br />
<small data-i18n>settings.ot.nativeHeating.note</small>
</label>
</fieldset>
</div>
@@ -927,7 +893,7 @@
<script>
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
lang.build();
let etChart = null;
let etChartConfig = {
@@ -1124,9 +1090,8 @@
setCheckboxValue("[name='opentherm[options][autoFaultReset]']", data.opentherm.options.autoFaultReset);
setCheckboxValue("[name='opentherm[options][autoDiagReset]']", data.opentherm.options.autoDiagReset);
setCheckboxValue("[name='opentherm[options][setDateAndTime]']", data.opentherm.options.setDateAndTime);
setCheckboxValue("[name='opentherm[options][nativeOTC]']", data.opentherm.options.nativeOTC);
setCheckboxValue("[name='opentherm[options][nativeHeatingControl]']", data.opentherm.options.nativeHeatingControl);
setCheckboxValue("[name='opentherm[options][immergasFix]']", data.opentherm.options.immergasFix);
setCheckboxValue("[name='opentherm[options][alwaysSendIndoorTemp]']", data.opentherm.options.alwaysSendIndoorTemp);
setBusy('#ot-settings-busy', '#ot-settings', false);
// MQTT
@@ -1173,9 +1138,7 @@
"min": data.system.unitSystem == 0 ? 1 : 33,
"max": data.system.unitSystem == 0 ? 100 : 212
});
setCheckboxValue("[name='heating[hysteresis][enabled]']", data.heating.hysteresis.enabled);
setInputValue("[name='heating[hysteresis][value]']", data.heating.hysteresis.value);
setSelectValue("[name='heating[hysteresis][action]']", data.heating.hysteresis.action);
setInputValue("[name='heating[hysteresis]']", data.heating.hysteresis);
setInputValue("[name='heating[turboFactor]']", data.heating.turboFactor);
setInputValue("[name='heating[maxModulation]']", data.heating.maxModulation);
setInputValue("[name='heating[overheatProtection][highTemp]']", data.heating.overheatProtection.highTemp, {
@@ -1186,14 +1149,11 @@
"min": 0,
"max": data.system.unitSystem == 0 ? 99 : 211
});
setInputValue("[name='heating[freezeProtection][highTemp]']", data.heating.freezeProtection.highTemp, {
"min": data.system.unitSystem == 0 ? 1 : 34,
"max": data.system.unitSystem == 0 ? 50 : 122
});
setInputValue("[name='heating[freezeProtection][lowTemp]']", data.heating.freezeProtection.lowTemp, {
"min": data.system.unitSystem == 0 ? 1 : 34,
"max": data.system.unitSystem == 0 ? 30 : 86
});
setInputValue("[name='heating[freezeProtection][thresholdTime]']", data.heating.freezeProtection.thresholdTime);
setBusy('#heating-settings-busy', '#heating-settings', false);
// DHW
@@ -1217,7 +1177,7 @@
setBusy('#dhw-settings-busy', '#dhw-settings', false);
// Emergency mode
if (data.opentherm.options.nativeOTC) {
if (data.opentherm.options.nativeHeatingControl) {
setInputValue("[name='emergency[target]']", data.emergency.target, {
"min": data.system.unitSystem == 0 ? 5 : 41,
"max": data.system.unitSystem == 0 ? 40 : 104
+1 -1
View File
@@ -105,7 +105,7 @@
<script>
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
lang.build();
setupRestoreBackupForm('#restore');
setupUpgradeForm('#upgrade');
+2 -4
View File
@@ -92,7 +92,7 @@ const setupForm = (formSelector, onResultCallback = null, noCastItems = []) => {
});
}
const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
const setupNetworkScanForm = (formSelector, tableSelector) => {
const form = document.querySelector(formSelector);
if (!form) {
console.error("form not found");
@@ -253,9 +253,7 @@ const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
};
form.addEventListener('submit', onSubmitFn);
if (autorun) {
onSubmitFn();
}
onSubmitFn();
}
const setupRestoreBackupForm = (formSelector) => {