mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-12 17:34:46 +05:00
Compare commits
4
Commits
master
..
95d508553d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d508553d | ||
|
|
d474be26dc | ||
|
|
d54a9cf2d7 | ||
|
|
98e5fe42e8 |
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -27,9 +27,6 @@ let paths = {
|
||||
'src_data/scripts/i18n.min.js',
|
||||
'src_data/scripts/lang.js',
|
||||
'src_data/scripts/utils.js'
|
||||
],
|
||||
'chart.js': [
|
||||
'src_data/scripts/chart.js'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(EQUITHERM_INTEGER)
|
||||
// расчёты с целыми числами
|
||||
typedef int datatype;
|
||||
#else
|
||||
// расчёты с float числами
|
||||
typedef float datatype;
|
||||
#endif
|
||||
|
||||
class Equitherm {
|
||||
public:
|
||||
datatype targetTemp = 0;
|
||||
datatype indoorTemp = 0;
|
||||
datatype outdoorTemp = 0;
|
||||
float Kn = 0.0;
|
||||
float Kk = 0.0;
|
||||
float Kt = 0.0;
|
||||
|
||||
Equitherm() = default;
|
||||
|
||||
// kn, kk, kt
|
||||
Equitherm(float new_kn, float new_kk, float new_kt) {
|
||||
Kn = new_kn;
|
||||
Kk = new_kk;
|
||||
Kt = new_kt;
|
||||
}
|
||||
|
||||
// лимит выходной величины
|
||||
void setLimits(unsigned short min_output, unsigned short max_output) {
|
||||
_minOut = min_output;
|
||||
_maxOut = max_output;
|
||||
}
|
||||
|
||||
// возвращает новое значение при вызове
|
||||
datatype getResult() {
|
||||
datatype output = getResultN() + getResultK() + getResultT();
|
||||
output = constrain(output, _minOut, _maxOut); // ограничиваем выход
|
||||
return output;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned short _minOut = 20, _maxOut = 90;
|
||||
|
||||
// температура контура отопления в зависимости от наружной температуры
|
||||
datatype getResultN() {
|
||||
float a = (-0.21 * Kn) - 0.06; // a = -0,21k — 0,06
|
||||
float b = (6.04 * Kn) + 1.98; // b = 6,04k + 1,98
|
||||
float c = (-5.06 * Kn) + 18.06; // с = -5,06k + 18,06
|
||||
float x = (-0.2 * outdoorTemp) + 5; // x = -0.2*t1 + 5
|
||||
return (a * x * x) + (b * x) + c; // Tn = ax2 + bx + c
|
||||
}
|
||||
|
||||
// поправка на желаемую комнатную температуру
|
||||
datatype getResultK() {
|
||||
return (targetTemp - 20) * Kk;
|
||||
}
|
||||
|
||||
// Расчет поправки (ошибки) термостата
|
||||
datatype getResultT() {
|
||||
return constrain((targetTemp - indoorTemp), -3, 3) * Kt;
|
||||
}
|
||||
};
|
||||
@@ -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,4 +1,3 @@
|
||||
#pragma once
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include "lwip/etharp.h"
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
+361
-199
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+28
-61
@@ -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
|
||||
@@ -872,19 +866,19 @@ public:
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("equitherm")).c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishInputEquithermSlope(bool enabledByDefault = true) {
|
||||
bool publishInputEquithermFactorN(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("equitherm_slope"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_slope"));
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_n"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_n"));
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm slope");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:slope-uphill");
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm factor N");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:alpha-n-circle-outline");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.slope|float(0)|round(3) }}");
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.n_factor|float(0)|round(3) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"slope\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"n_factor\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 0.001f;
|
||||
doc[FPSTR(HA_MAX)] = 10;
|
||||
doc[FPSTR(HA_STEP)] = 0.001f;
|
||||
@@ -892,80 +886,56 @@ public:
|
||||
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
|
||||
doc.shrinkToFit();
|
||||
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_slope")).c_str(), doc);
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_n_factor")).c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishInputEquithermExponent(bool enabledByDefault = true) {
|
||||
bool publishInputEquithermFactorK(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("equitherm_exponent"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_exponent"));
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_k"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_k"));
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm exponent");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:exponent");
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm factor K");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:alpha-k-circle-outline");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.exponent|float(0)|round(3) }}");
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.k_factor|float(0)|round(2) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"exponent\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 0.1;
|
||||
doc[FPSTR(HA_MAX)] = 2;
|
||||
doc[FPSTR(HA_STEP)] = 0.001f;
|
||||
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
|
||||
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
|
||||
doc.shrinkToFit();
|
||||
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_exponent")).c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishInputEquithermShift(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("equitherm_shift"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_shift"));
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm shift");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:chart-areaspline");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.shift|float(0)|round(2) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"shift\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = -15;
|
||||
doc[FPSTR(HA_MAX)] = 15;
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"k_factor\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 0;
|
||||
doc[FPSTR(HA_MAX)] = 10;
|
||||
doc[FPSTR(HA_STEP)] = 0.01f;
|
||||
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
|
||||
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
|
||||
doc.shrinkToFit();
|
||||
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_shift")).c_str(), doc);
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_k_factor")).c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishInputEquithermTargetDiffFactor(bool enabledByDefault = true) {
|
||||
bool publishInputEquithermFactorT(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->settingsTopic.c_str();
|
||||
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.pid.enabled, 'offline', 'online') }}");
|
||||
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_target_diff_factor"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_target_diff_factor"));
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_t"));
|
||||
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_t"));
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm target diff factor");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:chart-timeline-variant-shimmer");
|
||||
doc[FPSTR(HA_NAME)] = F("Equitherm factor T");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:alpha-t-circle-outline");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.targetDiffFactor|float(0)|round(3) }}");
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.equitherm.t_factor|float(0)|round(2) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"targetDiffFactor\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"t_factor\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 0;
|
||||
doc[FPSTR(HA_MAX)] = 10;
|
||||
doc[FPSTR(HA_STEP)] = 0.001f;
|
||||
doc[FPSTR(HA_STEP)] = 0.01f;
|
||||
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
|
||||
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
|
||||
doc.shrinkToFit();
|
||||
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_target_diff_factor")).c_str(), doc);
|
||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_NUMBER), F("equitherm_t_factor")).c_str(), doc);
|
||||
}
|
||||
|
||||
|
||||
@@ -1184,10 +1154,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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -503,10 +503,9 @@ protected:
|
||||
|
||||
// equitherm
|
||||
this->haHelper->publishSwitchEquitherm();
|
||||
this->haHelper->publishInputEquithermSlope(false);
|
||||
this->haHelper->publishInputEquithermExponent(false);
|
||||
this->haHelper->publishInputEquithermShift(false);
|
||||
this->haHelper->publishInputEquithermTargetDiffFactor(false);
|
||||
this->haHelper->publishInputEquithermFactorN(false);
|
||||
this->haHelper->publishInputEquithermFactorK(false);
|
||||
this->haHelper->publishInputEquithermFactorT(false);
|
||||
|
||||
// states
|
||||
this->haHelper->publishStatusState();
|
||||
|
||||
+63
-142
@@ -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 || settings.heating.hysteresis.action != HysteresisAction::DISABLE_HEATING)
|
||||
&& !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;
|
||||
}
|
||||
|
||||
+34
-179
@@ -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;
|
||||
}
|
||||
|
||||
@@ -349,7 +331,6 @@ protected:
|
||||
|
||||
JsonDocument doc;
|
||||
networkSettingsToJson(networkSettings, doc);
|
||||
this->ethernetToJson(doc);
|
||||
doc.shrinkToFit();
|
||||
|
||||
this->bufferedWebServer->send(200, F("application/json"), doc);
|
||||
@@ -385,18 +366,10 @@ 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);
|
||||
@@ -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) {
|
||||
@@ -527,7 +491,6 @@ protected:
|
||||
doc.shrinkToFit();
|
||||
|
||||
fsSettings.update();
|
||||
applyEthernetSettings();
|
||||
tMqtt->resetPublishedSettingsTime();
|
||||
}
|
||||
});
|
||||
@@ -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() : "";
|
||||
@@ -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__;
|
||||
@@ -895,18 +839,7 @@ protected:
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -940,23 +873,46 @@ protected:
|
||||
#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()) {
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
+54
-39
@@ -1,5 +1,7 @@
|
||||
#include <Equitherm.h>
|
||||
#include <GyverPID.h>
|
||||
|
||||
Equitherm etRegulator;
|
||||
GyverPID pidRegulator(0, 0, 0);
|
||||
|
||||
|
||||
@@ -37,7 +39,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;
|
||||
@@ -57,12 +59,23 @@ protected:
|
||||
this->turbo();
|
||||
this->hysteresis();
|
||||
|
||||
vars.master.heating.targetTemp = settings.heating.target;
|
||||
vars.master.heating.setpointTemp = roundf(constrain(
|
||||
this->getHeatingSetpointTemp(),
|
||||
this->getHeatingMinSetpointTemp(),
|
||||
this->getHeatingMaxSetpointTemp()
|
||||
), 0);
|
||||
if (vars.master.heating.blocking && settings.heating.hysteresis.action == HysteresisAction::SET_ZERO_TARGET) {
|
||||
vars.master.heating.targetTemp = 0.0f;
|
||||
vars.master.heating.setpointTemp = 0.0f;
|
||||
|
||||
// tick if PID enabled
|
||||
if (settings.pid.enabled) {
|
||||
this->getHeatingSetpointTemp();
|
||||
}
|
||||
|
||||
} else {
|
||||
vars.master.heating.targetTemp = settings.heating.target;
|
||||
vars.master.heating.setpointTemp = roundf(constrain(
|
||||
this->getHeatingSetpointTemp(),
|
||||
this->getHeatingMinSetpointTemp(),
|
||||
this->getHeatingMaxSetpointTemp()
|
||||
), 0);
|
||||
}
|
||||
|
||||
Sensors::setValueByType(
|
||||
Sensors::Type::HEATING_SETPOINT_TEMP, vars.master.heating.setpointTemp,
|
||||
@@ -91,7 +104,7 @@ protected:
|
||||
void hysteresis() {
|
||||
bool useHyst = false;
|
||||
if (settings.heating.hysteresis.enabled && this->indoorSensorsConnected) {
|
||||
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeOTC;
|
||||
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl;
|
||||
}
|
||||
|
||||
if (useHyst) {
|
||||
@@ -108,13 +121,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 +148,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) {
|
||||
@@ -144,32 +157,39 @@ protected:
|
||||
|
||||
// if use equitherm
|
||||
if (settings.equitherm.enabled) {
|
||||
float tempDelta = settings.heating.target - vars.master.heating.outdoorTemp;
|
||||
float maxPoint = settings.heating.target - (
|
||||
settings.heating.maxTemp - settings.heating.target
|
||||
) / settings.equitherm.slope;
|
||||
unsigned short minTemp = settings.heating.minTemp;
|
||||
unsigned short maxTemp = settings.heating.maxTemp;
|
||||
float targetTemp = settings.heating.target;
|
||||
float indoorTemp = vars.master.heating.indoorTemp;
|
||||
float outdoorTemp = vars.master.heating.outdoorTemp;
|
||||
|
||||
float sf = (settings.heating.maxTemp - settings.heating.target) / pow(
|
||||
settings.heating.target - maxPoint,
|
||||
1.0f / settings.equitherm.exponent
|
||||
);
|
||||
float etResult = settings.heating.target + settings.equitherm.shift + sf * (
|
||||
tempDelta >= 0
|
||||
? pow(tempDelta, 1.0f / settings.equitherm.exponent)
|
||||
: -(pow(-(tempDelta), 1.0f / settings.equitherm.exponent))
|
||||
);
|
||||
|
||||
// add diff
|
||||
if (this->indoorSensorsConnected && !settings.pid.enabled && !settings.heating.turbo) {
|
||||
etResult += constrain(
|
||||
settings.heating.target - vars.master.heating.indoorTemp,
|
||||
-3.0f,
|
||||
3.0f
|
||||
) * settings.equitherm.targetDiffFactor;
|
||||
if (settings.system.unitSystem == UnitSystem::IMPERIAL) {
|
||||
minTemp = f2c(minTemp);
|
||||
maxTemp = f2c(maxTemp);
|
||||
targetTemp = f2c(targetTemp);
|
||||
indoorTemp = f2c(indoorTemp);
|
||||
outdoorTemp = f2c(outdoorTemp);
|
||||
}
|
||||
|
||||
// limit
|
||||
etResult = constrain(etResult, settings.heating.minTemp, settings.heating.maxTemp);
|
||||
if (!this->indoorSensorsConnected || settings.pid.enabled) {
|
||||
etRegulator.Kt = 0.0f;
|
||||
etRegulator.indoorTemp = 0.0f;
|
||||
|
||||
} else {
|
||||
etRegulator.Kt = settings.heating.turbo ? 0.0f : settings.equitherm.t_factor;
|
||||
etRegulator.indoorTemp = indoorTemp;
|
||||
}
|
||||
|
||||
etRegulator.setLimits(minTemp, maxTemp);
|
||||
etRegulator.Kn = settings.equitherm.n_factor;
|
||||
etRegulator.Kk = settings.equitherm.k_factor;
|
||||
etRegulator.targetTemp = targetTemp;
|
||||
etRegulator.outdoorTemp = outdoorTemp;
|
||||
float etResult = etRegulator.getResult();
|
||||
|
||||
if (settings.system.unitSystem == UnitSystem::IMPERIAL) {
|
||||
etResult = c2f(etResult);
|
||||
}
|
||||
|
||||
if (fabsf(prevEtResult - etResult) > 0.09f) {
|
||||
prevEtResult = etResult;
|
||||
@@ -240,11 +260,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
@@ -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
@@ -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
-28
@@ -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;
|
||||
@@ -139,8 +120,8 @@ struct Settings {
|
||||
} overheatProtection;
|
||||
|
||||
struct {
|
||||
uint8_t highTemp = 15;
|
||||
uint8_t lowTemp = 10;
|
||||
unsigned short thresholdTime = 600;
|
||||
} freezeProtection;
|
||||
} heating;
|
||||
|
||||
@@ -178,10 +159,9 @@ struct Settings {
|
||||
|
||||
struct {
|
||||
bool enabled = false;
|
||||
float slope = 0.7f;
|
||||
float exponent = 1.3f;
|
||||
float shift = 0.0f;
|
||||
float targetDiffFactor = 2.0f;
|
||||
float n_factor = 0.7f;
|
||||
float k_factor = 3.0f;
|
||||
float t_factor = 2.0f;
|
||||
} equitherm;
|
||||
|
||||
struct {
|
||||
@@ -290,7 +270,6 @@ struct Variables {
|
||||
struct {
|
||||
bool connected = false;
|
||||
int8_t rssi = 0;
|
||||
NetworkUtils::NetworkMgr::Uplink connectionType = NetworkUtils::NetworkMgr::Uplink::None;
|
||||
} network;
|
||||
|
||||
struct {
|
||||
@@ -323,7 +302,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 +387,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;
|
||||
|
||||
@@ -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
|
||||
@@ -201,9 +168,4 @@ enum class HysteresisAction : uint8_t {
|
||||
SET_ZERO_TARGET = 1
|
||||
};
|
||||
|
||||
enum class EthernetImplementation : uint8_t {
|
||||
NONE = 0,
|
||||
W5500 = 1
|
||||
};
|
||||
|
||||
char buffer[255];
|
||||
@@ -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());
|
||||
|
||||
+4
-20
@@ -48,7 +48,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 +55,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 +82,10 @@ 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,9 +116,9 @@ 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_K_FACTOR[] PROGMEM = "k_factor";
|
||||
const char S_LOGIN[] PROGMEM = "login";
|
||||
const char S_LOG_LEVEL[] PROGMEM = "logLevel";
|
||||
const char S_LOW_TEMP[] PROGMEM = "lowTemp";
|
||||
@@ -147,15 +137,14 @@ 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_N_FACTOR[] PROGMEM = "n_factor";
|
||||
const char S_OFFSET[] PROGMEM = "offset";
|
||||
const char S_ON_ENABLED_HEATING[] PROGMEM = "onEnabledHeating";
|
||||
const char S_ON_FAULT[] PROGMEM = "onFault";
|
||||
@@ -170,7 +159,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 +176,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";
|
||||
@@ -196,13 +183,10 @@ const char S_SERIAL[] PROGMEM = "serial";
|
||||
const char S_SERVER[] PROGMEM = "server";
|
||||
const char S_SETTINGS[] PROGMEM = "settings";
|
||||
const char S_SET_DATE_AND_TIME[] PROGMEM = "setDateAndTime";
|
||||
const char S_SHIFT[] PROGMEM = "shift";
|
||||
const char S_SIGNAL_QUALITY[] PROGMEM = "signalQuality";
|
||||
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";
|
||||
@@ -213,7 +197,6 @@ const char S_SUBNET[] PROGMEM = "subnet";
|
||||
const char S_SUMMER_WINTER_MODE[] PROGMEM = "summerWinterMode";
|
||||
const char S_SYSTEM[] PROGMEM = "system";
|
||||
const char S_TARGET[] PROGMEM = "target";
|
||||
const char S_TARGET_DIFF_FACTOR[] PROGMEM = "targetDiffFactor";
|
||||
const char S_TARGET_TEMP[] PROGMEM = "targetTemp";
|
||||
const char S_TELNET[] PROGMEM = "telnet";
|
||||
const char S_TEMPERATURE[] PROGMEM = "temperature";
|
||||
@@ -226,6 +209,7 @@ const char S_TRESHOLD_TIME[] PROGMEM = "tresholdTime";
|
||||
const char S_TURBO[] PROGMEM = "turbo";
|
||||
const char S_TURBO_FACTOR[] PROGMEM = "turboFactor";
|
||||
const char S_TYPE[] PROGMEM = "type";
|
||||
const char S_T_FACTOR[] PROGMEM = "t_factor";
|
||||
const char S_UNIT_SYSTEM[] PROGMEM = "unitSystem";
|
||||
const char S_UPTIME[] PROGMEM = "uptime";
|
||||
const char S_USE[] PROGMEM = "use";
|
||||
|
||||
+48
-148
@@ -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,11 +468,9 @@ 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;
|
||||
mqtt[FPSTR(S_SERVER)] = src.mqtt.server;
|
||||
@@ -534,8 +503,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;
|
||||
@@ -550,10 +519,9 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
|
||||
auto equitherm = dst[FPSTR(S_EQUITHERM)].to<JsonObject>();
|
||||
equitherm[FPSTR(S_ENABLED)] = src.equitherm.enabled;
|
||||
equitherm[FPSTR(S_SLOPE)] = roundf(src.equitherm.slope, 3);
|
||||
equitherm[FPSTR(S_EXPONENT)] = roundf(src.equitherm.exponent, 3);
|
||||
equitherm[FPSTR(S_SHIFT)] = roundf(src.equitherm.shift, 2);
|
||||
equitherm[FPSTR(S_TARGET_DIFF_FACTOR)] = roundf(src.equitherm.targetDiffFactor, 3);
|
||||
equitherm[FPSTR(S_N_FACTOR)] = roundf(src.equitherm.n_factor, 3);
|
||||
equitherm[FPSTR(S_K_FACTOR)] = roundf(src.equitherm.k_factor, 3);
|
||||
equitherm[FPSTR(S_T_FACTOR)] = roundf(src.equitherm.t_factor, 3);
|
||||
|
||||
auto pid = dst[FPSTR(S_PID)].to<JsonObject>();
|
||||
pid[FPSTR(S_ENABLED)] = src.pid.enabled;
|
||||
@@ -602,55 +570,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 +694,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 +1002,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 +1026,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 +1117,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;
|
||||
@@ -1217,38 +1129,29 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_SLOPE)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_SLOPE)].as<float>();
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_N_FACTOR)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_N_FACTOR)].as<float>();
|
||||
|
||||
if (value > 0.0f && value <= 10.0f && fabsf(value - dst.equitherm.slope) > 0.0001f) {
|
||||
dst.equitherm.slope = roundf(value, 3);
|
||||
if (value > 0 && value <= 10 && fabsf(value - dst.equitherm.n_factor) > 0.0001f) {
|
||||
dst.equitherm.n_factor = roundf(value, 3);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_EXPONENT)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_EXPONENT)].as<float>();
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_K_FACTOR)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_K_FACTOR)].as<float>();
|
||||
|
||||
if (value > 0.0f && value <= 2.0f && fabsf(value - dst.equitherm.exponent) > 0.0001f) {
|
||||
dst.equitherm.exponent = roundf(value, 3);
|
||||
if (value >= 0 && value <= 10 && fabsf(value - dst.equitherm.k_factor) > 0.0001f) {
|
||||
dst.equitherm.k_factor = roundf(value, 3);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_SHIFT)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_SHIFT)].as<float>();
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_T_FACTOR)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_T_FACTOR)].as<float>();
|
||||
|
||||
if (value >= -15.0f && value <= 15.0f && fabsf(value - dst.equitherm.shift) > 0.0001f) {
|
||||
dst.equitherm.shift = roundf(value, 2);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_TARGET_DIFF_FACTOR)].isNull()) {
|
||||
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_TARGET_DIFF_FACTOR)].as<float>();
|
||||
|
||||
if (value >= 0.0f && value <= 10.0f && fabsf(value - dst.equitherm.targetDiffFactor) > 0.0001f) {
|
||||
dst.equitherm.targetDiffFactor = roundf(value, 3);
|
||||
if (value >= 0 && value <= 10 && fabsf(value - dst.equitherm.t_factor) > 0.0001f) {
|
||||
dst.equitherm.t_factor = roundf(value, 3);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -1258,7 +1161,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;
|
||||
@@ -1503,15 +1406,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 +1415,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 +1694,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 +1719,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 +1912,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 +2088,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 +2111,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 +2152,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 +2172,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;
|
||||
|
||||
+14
-58
@@ -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": {
|
||||
@@ -408,26 +380,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 +442,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气候补偿功能不兼容。"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+13
-58
@@ -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": {
|
||||
@@ -409,26 +380,11 @@
|
||||
},
|
||||
|
||||
"equitherm": {
|
||||
"slope": {
|
||||
"title": "Slope",
|
||||
"note": "Heat loss compensation. Main tuning parameter."
|
||||
},
|
||||
"exponent": {
|
||||
"title": "Exponent",
|
||||
"note": "Radiator efficiency. Typical values: <code>1.1</code> - Floor heating, <code>1.2</code> - Cast iron, <code>1.3</code> - Panel radiators, <code>1.4</code> - Convectors."
|
||||
},
|
||||
"shift": {
|
||||
"title": "Shift",
|
||||
"note": "Compensates for additional heat losses (e.g., in pipes) or extra heat sources."
|
||||
},
|
||||
"targetDiffFactor": {
|
||||
"n": "N factor",
|
||||
"k": "K factor",
|
||||
"t": {
|
||||
"title": "T factor",
|
||||
"note": "Not used if PID is enabled. Adds to the setpoint the difference between the target and current indoor temp: <code>setpoint = setpoint + ((target - indoor) * T)</code>."
|
||||
},
|
||||
"chart": {
|
||||
"targetTemp": "Target indoor temperature",
|
||||
"setpointTemp": "Heat carrier temperature",
|
||||
"outdoorTemp": "Outdoor temperature"
|
||||
"note": "Not used if PID is enabled"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -486,13 +442,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."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+13
-57
@@ -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": {
|
||||
@@ -408,26 +380,11 @@
|
||||
},
|
||||
|
||||
"equitherm": {
|
||||
"slope": {
|
||||
"title": "Pendenza",
|
||||
"note": "Compensazione della perdita di calore. Parametro di regolazione principale."
|
||||
},
|
||||
"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."
|
||||
},
|
||||
"shift": {
|
||||
"title": "Spostamento",
|
||||
"note": "Compensa perdite di calore aggiuntive (ad es., nelle tubature) o fonti di calore extra."
|
||||
},
|
||||
"targetDiffFactor": {
|
||||
"n": "Fattore N",
|
||||
"k": "Fattore K",
|
||||
"t": {
|
||||
"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>."
|
||||
},
|
||||
"chart": {
|
||||
"targetTemp": "Temperatura interna target",
|
||||
"setpointTemp": "Temperatura del vettore termico",
|
||||
"outdoorTemp": "Temperatura esterna"
|
||||
"note": "Non usato se PID è attivato"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -485,13 +442,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."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+15
-62
@@ -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",
|
||||
@@ -378,26 +348,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 +407,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": {
|
||||
|
||||
+14
-58
@@ -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": {
|
||||
@@ -386,7 +358,7 @@
|
||||
"heating": {
|
||||
"hyst": {
|
||||
"title": "Гистерезис",
|
||||
"desc": "Гистерезис полезен для поддержания заданной внутр. темп. (при использовании «ПЗА» и/или «ПИД»). Принудительно откл. отопление, когда <code>current indoor > target + value</code>, и вкл. отопление, когда <code>current indoor < (target - value)</code>.",
|
||||
"desc": "Гистерезис полезен для поддержания заданной внутр. темп. (при использовании «Equitherm» и/или «PID»). Принудительно откл. отопление, когда <code>current indoor > target + value</code>, и вкл. отопление, когда <code>current indoor < (target - value)</code>.",
|
||||
"value": "Значение <small>(в градусах)</small>",
|
||||
"action": {
|
||||
"title": "Действие",
|
||||
@@ -408,26 +380,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": {
|
||||
"n": "Коэффициент N",
|
||||
"k": "Коэффициент K",
|
||||
"t": {
|
||||
"title": "Коэффициент T",
|
||||
"note": "Не используется, если ПИД включен. Добавляет разницу между целевой и текущей температурой в помещении: <code>setpoint = setpoint + ((target - indoor) * T)</code>."
|
||||
},
|
||||
"chart": {
|
||||
"targetTemp": "Целевая внутренняя температура",
|
||||
"setpointTemp": "Температура теплоносителя",
|
||||
"outdoorTemp": "Наружная температура"
|
||||
"note": "Не используется, если ПИД включен"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -485,13 +442,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> если котел требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+6
-115
@@ -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']);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -266,9 +241,7 @@
|
||||
setCheckboxValue("[name='filtering']", data.filtering, sensorForm);
|
||||
setInputValue("[name='filteringFactor']", data.filteringFactor, {}, sensorForm);
|
||||
|
||||
setTimeout(() => {
|
||||
sensorForm.querySelector("[name='type']").dispatchEvent(new Event("change"));
|
||||
}, 10);
|
||||
sensorForm.querySelector("[name='type']").dispatchEvent(new Event("change"));
|
||||
|
||||
setBusy(".form-busy", "form", false, sensorNode);
|
||||
};
|
||||
@@ -311,12 +284,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}");
|
||||
|
||||
+22
-278
@@ -106,7 +106,7 @@
|
||||
<option disabled selected data-i18n>settings.system.ntp.timezonePresets</option>
|
||||
</select>
|
||||
</div>
|
||||
</label>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@@ -265,15 +265,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>
|
||||
|
||||
@@ -383,44 +381,21 @@
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<canvas id="etChart"></canvas>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<div>
|
||||
<span data-i18n>settings.equitherm.chart.targetTemp</span>: <b class="etChartTargetTempValue"></b>°
|
||||
</div>
|
||||
<input class="etChartTargetTemp" type="range" value="0" min="0" max="0" step="0.5">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>settings.equitherm.slope.title</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[slope]" min="0.001" max="10" step="0.001" required>
|
||||
<small data-i18n>settings.equitherm.slope.note</small>
|
||||
<span data-i18n>settings.equitherm.n</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[n_factor]" min="0.001" max="10" step="0.001" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>settings.equitherm.exponent.title</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[exponent]" min="0.1" max="2" step="0.001" required>
|
||||
<small data-i18n>settings.equitherm.exponent.note</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>settings.equitherm.shift.title</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[shift]" min="-15" max="15" step="0.01" required>
|
||||
<small data-i18n>settings.equitherm.shift.note</small>
|
||||
<span data-i18n>settings.equitherm.k</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[k_factor]" min="0" max="10" step="0.01" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>settings.equitherm.targetDiffFactor.title</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[targetDiffFactor]" min="0" max="10" step="0.01" required>
|
||||
<small data-i18n>settings.equitherm.targetDiffFactor.note</small>
|
||||
<span data-i18n>settings.equitherm.t.title</span>
|
||||
<input type="number" inputmode="decimal" name="equitherm[t_factor]" min="0" max="10" step="0.01" required>
|
||||
<small data-i18n>settings.equitherm.t.note</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -694,17 +669,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>
|
||||
@@ -923,162 +893,10 @@
|
||||
</footer>
|
||||
|
||||
<script src="/static/app.js?{BUILD_TIME}"></script>
|
||||
<script src="/static/chart.js?{BUILD_TIME}"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
const lang = new Lang(document.getElementById('lang'));
|
||||
await lang.build();
|
||||
|
||||
let etChart = null;
|
||||
let etChartConfig = {
|
||||
slope: null,
|
||||
exponent: null,
|
||||
shift: null,
|
||||
unitSystem: null,
|
||||
targetTemp: null,
|
||||
minTemp: null,
|
||||
maxTemp: null,
|
||||
decimated: false
|
||||
};
|
||||
|
||||
const hasNeedDecimationChart = () => {
|
||||
return window.innerWidth <= 800;
|
||||
}
|
||||
|
||||
const makeEquithermChart = () => {
|
||||
if (etChart == null) {
|
||||
const ctx = document.getElementById('etChart').getContext('2d');
|
||||
|
||||
try {
|
||||
etChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
borderColor: (context) => {
|
||||
const chart = context.chart;
|
||||
const { ctx, chartArea } = chart;
|
||||
|
||||
if (!chartArea) {
|
||||
return;
|
||||
}
|
||||
|
||||
const gradient = ctx.createLinearGradient(0, chartArea.bottom, 0, chartArea.top);
|
||||
gradient.addColorStop(0, 'rgba(1, 114, 173, 1)');
|
||||
gradient.addColorStop(0.5, 'rgba(255, 99, 132, 1)');
|
||||
|
||||
return gradient;
|
||||
},
|
||||
borderWidth: 3,
|
||||
fill: false,
|
||||
tension: 0.1,
|
||||
pointRadius: 2,
|
||||
pointHoverRadius: 4,
|
||||
indexAxis: "x",
|
||||
data: []
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
resizeDelay: 500,
|
||||
parsing: false,
|
||||
interaction: {
|
||||
mode: 'nearest',
|
||||
intersect: false
|
||||
},
|
||||
plugins: {
|
||||
tooltip: {
|
||||
enabled: true,
|
||||
position: 'nearest',
|
||||
displayColors: false,
|
||||
callbacks: {
|
||||
title: (items) => {
|
||||
return `${i18n("settings.equitherm.chart.outdoorTemp")}: ${items[0].label}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
display: true,
|
||||
type: "linear",
|
||||
reverse: true,
|
||||
title: {
|
||||
display: true
|
||||
},
|
||||
ticks: {
|
||||
stepSize: 1,
|
||||
format: {
|
||||
style: "unit",
|
||||
unit: "degree",
|
||||
unitDisplay: "narrow"
|
||||
}
|
||||
}
|
||||
},
|
||||
y: {
|
||||
display: true,
|
||||
title: {
|
||||
display: true
|
||||
},
|
||||
ticks: {
|
||||
format: {
|
||||
style: "unit",
|
||||
unit: "degree",
|
||||
unitDisplay: "narrow"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!etChart) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = [];
|
||||
etChartConfig.decimated = hasNeedDecimationChart();
|
||||
for (let value = 30; value >= -30; value -= etChartConfig.decimated ? 2 : 1) {
|
||||
const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value);
|
||||
|
||||
data.push({
|
||||
x: parseFloat(outdoorTemp.toFixed(1)),
|
||||
y: parseFloat(calculateEquithermTemp(outdoorTemp).toFixed(1))
|
||||
});
|
||||
}
|
||||
|
||||
etChart.data.datasets[0].data = data;
|
||||
etChart.data.datasets[0].label = i18n("settings.equitherm.chart.setpointTemp");
|
||||
etChart.options.scales.x.title.text = i18n("settings.equitherm.chart.outdoorTemp");
|
||||
etChart.options.scales.y.title.text = i18n("settings.equitherm.chart.setpointTemp");
|
||||
etChart.update();
|
||||
}
|
||||
|
||||
const calculateEquithermTemp = (outdoorTemp) => {
|
||||
const tempDelta = etChartConfig.targetTemp - outdoorTemp;
|
||||
const maxPoint = etChartConfig.targetTemp - (
|
||||
etChartConfig.maxTemp - etChartConfig.targetTemp
|
||||
) / etChartConfig.slope;
|
||||
|
||||
const sf = (etChartConfig.maxTemp - etChartConfig.targetTemp) / Math.pow(
|
||||
etChartConfig.targetTemp - maxPoint,
|
||||
1 / etChartConfig.exponent
|
||||
);
|
||||
const result = etChartConfig.targetTemp + etChartConfig.shift + sf * (
|
||||
tempDelta >= 0
|
||||
? Math.pow(tempDelta, 1 / etChartConfig.exponent)
|
||||
: -(Math.pow(-(tempDelta), 1 / etChartConfig.exponent))
|
||||
);
|
||||
|
||||
return Math.max(Math.min(result, etChartConfig.maxTemp), etChartConfig.minTemp);
|
||||
}
|
||||
lang.build();
|
||||
|
||||
const fillData = (data) => {
|
||||
// System
|
||||
@@ -1124,9 +942,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
|
||||
@@ -1186,14 +1003,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 +1031,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
|
||||
@@ -1234,10 +1048,9 @@
|
||||
|
||||
// Equitherm
|
||||
setCheckboxValue("[name='equitherm[enabled]']", data.equitherm.enabled);
|
||||
setInputValue("[name='equitherm[slope]']", data.equitherm.slope);
|
||||
setInputValue("[name='equitherm[exponent]']", data.equitherm.exponent);
|
||||
setInputValue("[name='equitherm[shift]']", data.equitherm.shift);
|
||||
setInputValue("[name='equitherm[targetDiffFactor]']", data.equitherm.targetDiffFactor);
|
||||
setInputValue("[name='equitherm[n_factor]']", data.equitherm.n_factor);
|
||||
setInputValue("[name='equitherm[k_factor]']", data.equitherm.k_factor);
|
||||
setInputValue("[name='equitherm[t_factor]']", data.equitherm.t_factor);
|
||||
setBusy('#equitherm-settings-busy', '#equitherm-settings', false);
|
||||
|
||||
// PID
|
||||
@@ -1261,24 +1074,6 @@
|
||||
setInputValue("[name='pid[deadband][thresholdHigh]']", data.pid.deadband.thresholdHigh);
|
||||
setInputValue("[name='pid[deadband][thresholdLow]']", data.pid.deadband.thresholdLow);
|
||||
setBusy('#pid-settings-busy', '#pid-settings', false);
|
||||
|
||||
const etMinTemp = parseInt(data.system.unitSystem == 0 ? 5 : 41);
|
||||
const etMaxTemp = parseInt(data.system.unitSystem == 0 ? 30 : 86);
|
||||
const etTargetTemp = constrain(parseFloat(data.heating.target), etMinTemp, etMaxTemp);
|
||||
|
||||
setInputValue(".etChartTargetTemp", etTargetTemp.toFixed(1), {
|
||||
"min": etMinTemp,
|
||||
"max": etMaxTemp
|
||||
});
|
||||
|
||||
etChartConfig.slope = data.equitherm.slope;
|
||||
etChartConfig.exponent = data.equitherm.exponent;
|
||||
etChartConfig.shift = data.equitherm.shift;
|
||||
etChartConfig.unitSystem = data.system.unitSystem;
|
||||
etChartConfig.minTemp = data.heating.minTemp;
|
||||
etChartConfig.maxTemp = data.heating.maxTemp;
|
||||
|
||||
makeEquithermChart();
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -1331,57 +1126,6 @@
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
document.querySelector(".etChartTargetTemp").addEventListener("input", async (event) => {
|
||||
setValue('.etChartTargetTempValue', parseFloat(event.target.value).toFixed(1));
|
||||
});
|
||||
|
||||
document.querySelector(".etChartTargetTemp").addEventListener("change", async (event) => {
|
||||
if (!event.target.checkValidity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
etChartConfig.targetTemp = parseFloat(event.target.value);
|
||||
setValue('.etChartTargetTempValue', etChartConfig.targetTemp.toFixed(1));
|
||||
makeEquithermChart();
|
||||
});
|
||||
|
||||
document.querySelector("[name='equitherm[slope]']").addEventListener("change", async (event) => {
|
||||
if (!event.target.checkValidity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
etChartConfig.slope = parseFloat(event.target.value);
|
||||
makeEquithermChart();
|
||||
});
|
||||
|
||||
document.querySelector("[name='equitherm[exponent]']").addEventListener("change", async (event) => {
|
||||
if (!event.target.checkValidity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
etChartConfig.exponent = parseFloat(event.target.value);
|
||||
makeEquithermChart();
|
||||
});
|
||||
|
||||
document.querySelector("[name='equitherm[shift]']").addEventListener("change", async (event) => {
|
||||
if (!event.target.checkValidity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
etChartConfig.shift = parseFloat(event.target.value);
|
||||
makeEquithermChart();
|
||||
});
|
||||
|
||||
window.addEventListener('resize', async (event) => {
|
||||
if (etChart) {
|
||||
etChart.resize();
|
||||
|
||||
if (etChartConfig.decimated != hasNeedDecimationChart()) {
|
||||
makeEquithermChart();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/*!
|
||||
* Chart.js v4.5.0
|
||||
* https://www.chartjs.org
|
||||
* (c) 2025 Chart.js Contributors
|
||||
* Released under the MIT License
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";var t=Object.freeze({__proto__:null,get Colors(){return Jo},get Decimation(){return ta},get Filler(){return ba},get Legend(){return Ma},get SubTitle(){return Pa},get Title(){return ka},get Tooltip(){return Na}});function e(){}const i=(()=>{let t=0;return()=>t++})();function s(t){return null==t}function n(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function o(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function a(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function r(t,e){return a(t)?t:e}function l(t,e){return void 0===t?e:t}const h=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,c=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function d(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function u(t,e,i,s){let a,r,l;if(n(t))if(r=t.length,s)for(a=r-1;a>=0;a--)e.call(i,t[a],a);else for(a=0;a<r;a++)e.call(i,t[a],a);else if(o(t))for(l=Object.keys(t),r=l.length,a=0;a<r;a++)e.call(i,t[l[a]],l[a])}function f(t,e){let i,s,n,o;if(!t||!e||t.length!==e.length)return!1;for(i=0,s=t.length;i<s;++i)if(n=t[i],o=e[i],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function g(t){if(n(t))return t.map(g);if(o(t)){const e=Object.create(null),i=Object.keys(t),s=i.length;let n=0;for(;n<s;++n)e[i[n]]=g(t[i[n]]);return e}return t}function p(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function m(t,e,i,s){if(!p(t))return;const n=e[t],a=i[t];o(n)&&o(a)?x(n,a,s):e[t]=g(a)}function x(t,e,i){const s=n(e)?e:[e],a=s.length;if(!o(t))return t;const r=(i=i||{}).merger||m;let l;for(let e=0;e<a;++e){if(l=s[e],!o(l))continue;const n=Object.keys(l);for(let e=0,s=n.length;e<s;++e)r(n[e],t,l,i)}return t}function b(t,e){return x(t,e,{merger:_})}function _(t,e,i){if(!p(t))return;const s=e[t],n=i[t];o(s)&&o(n)?b(s,n):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=g(n))}const y={"":t=>t,x:t=>t.x,y:t=>t.y};function v(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function M(t,e){const i=y[e]||(y[e]=function(t){const e=v(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}(e));return i(t)}function w(t){return t.charAt(0).toUpperCase()+t.slice(1)}const k=t=>void 0!==t,S=t=>"function"==typeof t,P=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function D(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const C=Math.PI,O=2*C,A=O+C,T=Number.POSITIVE_INFINITY,L=C/180,E=C/2,R=C/4,I=2*C/3,z=Math.log10,F=Math.sign;function V(t,e,i){return Math.abs(t-e)<i}function B(t){const e=Math.round(t);t=V(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(z(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function W(t){const e=[],i=Math.sqrt(t);let s;for(s=1;s<i;s++)t%s==0&&(e.push(s),e.push(t/s));return i===(0|i)&&e.push(i),e.sort(((t,e)=>t-e)).pop(),e}function N(t){return!function(t){return"symbol"==typeof t||"object"==typeof t&&null!==t&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function H(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function j(t,e,i){let s,n,o;for(s=0,n=t.length;s<n;s++)o=t[s][i],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function $(t){return t*(C/180)}function Y(t){return t*(180/C)}function U(t){if(!a(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function X(t,e){const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);let o=Math.atan2(s,i);return o<-.5*C&&(o+=O),{angle:o,distance:n}}function q(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function K(t,e){return(t-e+A)%O-C}function G(t){return(t%O+O)%O}function J(t,e,i,s){const n=G(t),o=G(e),a=G(i),r=G(o-n),l=G(a-n),h=G(n-o),c=G(n-a);return n===o||n===a||s&&o===a||r>l&&h<c}function Z(t,e,i){return Math.max(e,Math.min(i,t))}function Q(t){return Z(t,-32768,32767)}function tt(t,e,i,s=1e-6){return t>=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function et(t,e,i){i=i||(i=>t[i]<e);let s,n=t.length-1,o=0;for(;n-o>1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const it=(t,e,i,s)=>et(t,i,s?s=>{const n=t[s][e];return n<i||n===i&&t[s+1][e]===i}:s=>t[s][e]<i),st=(t,e,i)=>et(t,i,(s=>t[s][e]>=i));function nt(t,e,i){let s=0,n=t.length;for(;s<n&&t[s]<e;)s++;for(;n>s&&t[n-1]>i;)n--;return s>0||n<t.length?t.slice(s,n):t}const ot=["push","pop","shift","splice","unshift"];function at(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),ot.forEach((e=>{const i="_onData"+w(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...eLine truncated
|
||||
/*!
|
||||
* @kurkle/color v0.3.2
|
||||
* https://github.com/kurkle/color#readme
|
||||
* (c) 2023 Jukka Kurkela
|
||||
* Released under the MIT License
|
||||
*/function _t(t){return t+.5|0}const yt=(t,e,i)=>Math.max(Math.min(t,i),e);function vt(t){return yt(_t(2.55*t),0,255)}function Mt(t){return yt(_t(255*t),0,255)}function wt(t){return yt(_t(t/2.55)/100,0,1)}function kt(t){return yt(_t(100*t),0,100)}const St={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Pt=[..."0123456789ABCDEF"],Dt=t=>Pt[15&t],Ct=t=>Pt[(240&t)>>4]+Pt[15&t],Ot=t=>(240&t)>>4==(15&t);function At(t){var e=(t=>Ot(t.r)&&Ot(t.g)&&Ot(t.b)&&Ot(t.a))(t)?Dt:Ct;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}const Tt=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Lt(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function Et(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function Rt(t,e,i){const s=Lt(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function It(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=function(t,e,i,s,n){return t===n?(e-i)/s+(e<i?6:0):e===n?(i-t)/s+2:(t-e)/s+4}(e,i,s,h,n),r=60*r+.5),[0|r,l||0,a]}function zt(t,e,i,s){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,i,s)).map(Mt)}function Ft(t,e,i){return zt(Lt,t,e,i)}function Vt(t){return(t%360+360)%360}function Bt(t){const e=Tt.exec(t);let i,s=255;if(!e)return;e[5]!==i&&(s=e[6]?vt(+e[5]):Mt(+e[5]));const n=Vt(+e[2]),o=+e[3]/100,a=+e[4]/100;return i="hwb"===e[1]?function(t,e,i){return zt(Rt,t,e,i)}(n,o,a):"hsv"===e[1]?function(t,e,i){return zt(Et,t,e,i)}(n,o,a):Ft(n,o,a),{r:i[0],g:i[1],b:i[2],a:s}}const Wt={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Nt={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};let Ht;function jt(t){Ht||(Ht=function(){const t={},e=Object.keys(Nt),i=Object.keys(Wt);let s,n,o,a,r;for(s=0;s<e.length;s++){for(a=r=e[s],n=0;n<i.length;n++)o=i[n],r=r.replace(o,Wt[o]);o=parseInt(Nt[a],16),t[r]=[o>>16&255,o>>8&255,255&o]}return t}(),Ht.transparent=[0,0,0,0]);const e=Ht[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}const $t=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const Yt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,Ut=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function Xt(t,e,i){if(t){let s=It(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),Line truncated
|
||||
//# sourceMappingURL=chart.umd.min.js.map
|
||||
@@ -5,13 +5,8 @@ const setupForm = (formSelector, onResultCallback = null, noCastItems = []) => {
|
||||
}
|
||||
|
||||
form.querySelectorAll('input').forEach(item => {
|
||||
item.addEventListener('change', (event) => {
|
||||
if (!event.target.checkValidity()) {
|
||||
event.target.setAttribute('aria-invalid', true);
|
||||
|
||||
} else if (event.target.hasAttribute('aria-invalid')) {
|
||||
event.target.removeAttribute('aria-invalid');
|
||||
}
|
||||
item.addEventListener('change', (e) => {
|
||||
e.target.setAttribute('aria-invalid', !e.target.checkValidity());
|
||||
})
|
||||
});
|
||||
|
||||
@@ -92,7 +87,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 +248,7 @@ const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
|
||||
};
|
||||
|
||||
form.addEventListener('submit', onSubmitFn);
|
||||
if (autorun) {
|
||||
onSubmitFn();
|
||||
}
|
||||
onSubmitFn();
|
||||
}
|
||||
|
||||
const setupRestoreBackupForm = (formSelector) => {
|
||||
@@ -637,10 +630,6 @@ const setCheckboxValue = (selector, value, parent = undefined) => {
|
||||
}
|
||||
|
||||
item.checked = value;
|
||||
|
||||
setTimeout(() => {
|
||||
item.dispatchEvent(new Event("change"));
|
||||
}, 10);
|
||||
}
|
||||
|
||||
const setRadioValue = (selector, value, parent = undefined) => {
|
||||
@@ -654,14 +643,7 @@ const setRadioValue = (selector, value, parent = undefined) => {
|
||||
}
|
||||
|
||||
for (let item of items) {
|
||||
const checked = item.value == value;
|
||||
if (item.checked != checked) {
|
||||
item.checked = checked;
|
||||
|
||||
setTimeout(() => {
|
||||
item.dispatchEvent(new Event("change"));
|
||||
}, 10);
|
||||
}
|
||||
item.checked = item.value == value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,17 +658,13 @@ const setInputValue = (selector, value, attrs = {}, parent = undefined) => {
|
||||
}
|
||||
|
||||
for (let item of items) {
|
||||
item.value = value;
|
||||
|
||||
if (attrs instanceof Object) {
|
||||
for (let attrKey of Object.keys(attrs)) {
|
||||
item.setAttribute(attrKey, attrs[attrKey]);
|
||||
}
|
||||
}
|
||||
|
||||
item.value = value;
|
||||
|
||||
setTimeout(() => {
|
||||
item.dispatchEvent(new Event("change"));
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,11 +854,3 @@ function dec2hex(i) {
|
||||
function constrain(amt, low, high) {
|
||||
return ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)));
|
||||
}
|
||||
|
||||
function c2f(value) {
|
||||
return (9 / 5) * value + 32;
|
||||
}
|
||||
|
||||
function f2c(value) {
|
||||
return (value - 32) * (5 / 9);
|
||||
}
|
||||
Reference in new issue
Block a user