Compare commits

..
8 Commits
45 changed files with 1741 additions and 4448 deletions

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
name: PlatformIO Dependabot
on:
workflow_dispatch: # option to manually trigger the workflow
schedule:
# Runs every day at 00:00
- cron: "0 0 * * *"
permissions:
contents: write
pull-requests: write
jobs:
dependabot:
runs-on: ubuntu-latest
name: run PlatformIO Dependabot
steps:
- name: Checkout
uses: actions/checkout@v5
- name: run PlatformIO Dependabot
uses: peterus/platformio_dependabot@v1.2.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@v11 - uses: actions/stale@v10
with: with:
stale-issue-message: > 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. 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.
+2 -5
View File
@@ -1,5 +1,5 @@
# Blueprint for reporting indoor/outdoor temperature to OpenTherm Gateway from any home assistant sensor # Blueprint for reporting indoor/outdoor temperature to OpenTherm Gateway from any home assistant sensor
# Updated: 26.01.2026 # Updated: 03.09.2024
blueprint: blueprint:
name: Report temp to OpenTherm Gateway name: Report temp to OpenTherm Gateway
@@ -15,6 +15,7 @@ blueprint:
multiple: false multiple: false
filter: filter:
- domain: sensor - domain: sensor
device_class: temperature
target_entity: target_entity:
name: Target entity name: Target entity
description: "Usually ``number.opentherm_indoor_temp`` or ``number.opentherm_outdoor_temp``" 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' }}" value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action: action:
- if: - if:
- condition: or
conditions:
- condition: template - condition: template
value_template: "{{ (states(source_entity)|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.01 }}" 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 }}"
then: then:
- service: number.set_value - service: number.set_value
data: data:
@@ -1,5 +1,5 @@
# Blueprint for reporting temperature to OpenTherm Gateway from home assistant weather integration # Blueprint for reporting temperature to OpenTherm Gateway from home assistant weather integration
# Updated: 26.01.2026 # Updated: 03.09.2024
blueprint: blueprint:
name: Report temp to OpenTherm Gateway from Weather name: Report temp to OpenTherm Gateway from Weather
@@ -37,12 +37,8 @@ condition:
value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}" value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action: action:
- if: - if:
- condition: or
conditions:
- condition: template - condition: template
value_template: "{{ (state_attr(source_entity, 'temperature')|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.1 }}" 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 }}"
then: then:
- service: number.set_value - service: number.set_value
data: data:
-3
View File
@@ -27,9 +27,6 @@ let paths = {
'src_data/scripts/i18n.min.js', 'src_data/scripts/i18n.min.js',
'src_data/scripts/lang.js', 'src_data/scripts/lang.js',
'src_data/scripts/utils.js' 'src_data/scripts/utils.js'
],
'chart.js': [
'src_data/scripts/chart.js'
] ]
} }
}, },
+25 -64
View File
@@ -70,79 +70,40 @@ public:
} }
} }
inline auto sendBoilerReset() { bool sendBoilerReset() {
return this->sendRequestCode(1); unsigned int data = 1;
} data <<= 8;
inline auto sendServiceReset() {
return this->sendRequestCode(10);
}
inline auto sendWaterFilling() {
return this->sendRequestCode(2);
}
bool sendRequestCode(const uint8_t requestCode) {
unsigned long response = this->sendRequest(buildRequest( unsigned long response = this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA, OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest, OpenThermMessageID::RemoteRequest,
static_cast<unsigned int>(requestCode) << 8 data
)); ));
if (!isValidResponse(response) || !isValidResponseId(response, OpenThermMessageID::RemoteRequest)) { return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
return false;
} }
const uint8_t responseRequestCode = (response & 0xFFFF) >> 8; bool sendServiceReset() {
const uint8_t responseCode = response & 0xFF; unsigned int data = 10;
if (responseRequestCode != requestCode || responseCode < 128) { data <<= 8;
return false; unsigned long response = this->sendRequest(buildRequest(
}
// reset
this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA, OpenThermMessageType::WRITE_DATA,
OpenThermMessageID::RemoteRequest, OpenThermMessageID::RemoteRequest,
0u << 8 data
)); ));
return true; return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
} }
bool getStr(OpenThermMessageID id, char* buffer, uint16_t length = 50) { bool sendWaterFilling() {
if (buffer == nullptr || length == 0) { unsigned int data = 2;
return false; data <<= 8;
} unsigned long response = this->sendRequest(buildRequest(
OpenThermMessageType::WRITE_DATA,
unsigned long response; OpenThermMessageID::RemoteRequest,
uint8_t index = 0; data
uint8_t maxIndex = 255;
while (index <= maxIndex && index < length) {
response = this->sendRequest(buildRequest(
OpenThermMessageType::READ_DATA,
id,
static_cast<unsigned int>(index) << 8
)); ));
if (!isValidResponse(response) || !isValidResponseId(response, id)) { return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
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;
} }
static bool isCh2Active(unsigned long response) { static bool isCh2Active(unsigned long response) {
@@ -150,9 +111,9 @@ public:
} }
static bool isValidResponseId(unsigned long response, OpenThermMessageID id) { 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) { static uint8_t getResponseMessageTypeId(unsigned long response) {
@@ -163,10 +124,10 @@ public:
uint8_t msgType = getResponseMessageTypeId(response); uint8_t msgType = getResponseMessageTypeId(response);
switch (msgType) { switch (msgType) {
case static_cast<uint8_t>(OpenThermMessageType::READ_ACK): case (uint8_t) OpenThermMessageType::READ_ACK:
case static_cast<uint8_t>(OpenThermMessageType::WRITE_ACK): case (uint8_t) OpenThermMessageType::WRITE_ACK:
case static_cast<uint8_t>(OpenThermMessageType::DATA_INVALID): case (uint8_t) OpenThermMessageType::DATA_INVALID:
case static_cast<uint8_t>(OpenThermMessageType::UNKNOWN_DATA_ID): case (uint8_t) OpenThermMessageType::UNKNOWN_DATA_ID:
return CustomOpenTherm::messageTypeToString( return CustomOpenTherm::messageTypeToString(
static_cast<OpenThermMessageType>(msgType) static_cast<OpenThermMessageType>(msgType)
); );
+63
View File
@@ -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 -12
View File
@@ -147,19 +147,8 @@ public:
return topic; return topic;
} }
template <class DT, class VT>
String getEntityIdWithPrefix(DT domain, VT value, char separator = '_') {
String topic = "";
topic.concat(domain);
topic.concat('.');
topic.concat(this->devicePrefix);
topic.concat(separator);
topic.concat(value);
return topic;
}
template <class T> template <class T>
String getUniqueIdWithPrefix(T value, char separator = '_') { String getObjectIdWithPrefix(T value, char separator = '_') {
String topic = ""; String topic = "";
topic.concat(this->devicePrefix); topic.concat(this->devicePrefix);
topic.concat(separator); topic.concat(separator);
+45 -46
View File
@@ -12,67 +12,66 @@ const char HA_ENTITY_SELECT[] PROGMEM = "select";
const char HA_ENTITY_SENSOR[] PROGMEM = "sensor"; const char HA_ENTITY_SENSOR[] PROGMEM = "sensor";
const char HA_ENTITY_SWITCH[] PROGMEM = "switch"; const char HA_ENTITY_SWITCH[] PROGMEM = "switch";
// https://www.home-assistant.io/integrations/mqtt/#supported-abbreviations-in-mqtt-discovery-messages const char HA_DEVICE[] PROGMEM = "device";
const char HA_DEFAULT_ENTITY_ID[] PROGMEM = "def_ent_id"; // "default_entity_id " const char HA_IDENTIFIERS[] PROGMEM = "identifiers";
const char HA_DEVICE[] PROGMEM = "dev"; // "device" const char HA_SW_VERSION[] PROGMEM = "sw_version";
const char HA_IDENTIFIERS[] PROGMEM = "ids"; // "identifiers" const char HA_MANUFACTURER[] PROGMEM = "manufacturer";
const char HA_SW_VERSION[] PROGMEM = "sw"; // "sw_version" const char HA_MODEL[] PROGMEM = "model";
const char HA_MANUFACTURER[] PROGMEM = "mf"; // "manufacturer"
const char HA_MODEL[] PROGMEM = "mdl"; // "model"
const char HA_NAME[] PROGMEM = "name"; const char HA_NAME[] PROGMEM = "name";
const char HA_CONF_URL[] PROGMEM = "cu"; // "configuration_url" const char HA_CONF_URL[] PROGMEM = "configuration_url";
const char HA_COMMAND_TOPIC[] PROGMEM = "cmd_t"; // "command_topic" const char HA_COMMAND_TOPIC[] PROGMEM = "command_topic";
const char HA_COMMAND_TEMPLATE[] PROGMEM = "cmd_tpl"; // "command_template" const char HA_COMMAND_TEMPLATE[] PROGMEM = "command_template";
const char HA_ENABLED_BY_DEFAULT[] PROGMEM = "en"; // "enabled_by_default" const char HA_ENABLED_BY_DEFAULT[] PROGMEM = "enabled_by_default";
const char HA_UNIQUE_ID[] PROGMEM = "uniq_id"; // "unique_id" const char HA_UNIQUE_ID[] PROGMEM = "unique_id";
const char HA_ENTITY_CATEGORY[] PROGMEM = "ent_cat"; // "entity_category" const char HA_OBJECT_ID[] PROGMEM = "object_id";
const char HA_ENTITY_CATEGORY[] PROGMEM = "entity_category";
const char HA_ENTITY_CATEGORY_DIAGNOSTIC[] PROGMEM = "diagnostic"; const char HA_ENTITY_CATEGORY_DIAGNOSTIC[] PROGMEM = "diagnostic";
const char HA_ENTITY_CATEGORY_CONFIG[] PROGMEM = "config"; const char HA_ENTITY_CATEGORY_CONFIG[] PROGMEM = "config";
const char HA_STATE_TOPIC[] PROGMEM = "stat_t"; // "state_topic" const char HA_STATE_TOPIC[] PROGMEM = "state_topic";
const char HA_VALUE_TEMPLATE[] PROGMEM = "val_tpl"; // "value_template" const char HA_VALUE_TEMPLATE[] PROGMEM = "value_template";
const char HA_OPTIONS[] PROGMEM = "ops"; // "options" const char HA_OPTIONS[] PROGMEM = "options";
const char HA_AVAILABILITY[] PROGMEM = "avty"; // "availability" const char HA_AVAILABILITY[] PROGMEM = "availability";
const char HA_AVAILABILITY_MODE[] PROGMEM = "avty_mode"; // "availability_mode" const char HA_AVAILABILITY_MODE[] PROGMEM = "availability_mode";
const char HA_TOPIC[] PROGMEM = "t"; // "topic" const char HA_TOPIC[] PROGMEM = "topic";
const char HA_DEVICE_CLASS[] PROGMEM = "dev_cla"; // "device_class" const char HA_DEVICE_CLASS[] PROGMEM = "device_class";
const char HA_UNIT_OF_MEASUREMENT[] PROGMEM = "unit_of_meas"; // "unit_of_measurement" const char HA_UNIT_OF_MEASUREMENT[] PROGMEM = "unit_of_measurement";
const char HA_UNIT_OF_MEASUREMENT_C[] PROGMEM = "°C"; const char HA_UNIT_OF_MEASUREMENT_C[] PROGMEM = "°C";
const char HA_UNIT_OF_MEASUREMENT_F[] PROGMEM = "°F"; const char HA_UNIT_OF_MEASUREMENT_F[] PROGMEM = "°F";
const char HA_UNIT_OF_MEASUREMENT_PERCENT[] PROGMEM = "%"; const char HA_UNIT_OF_MEASUREMENT_PERCENT[] PROGMEM = "%";
const char HA_UNIT_OF_MEASUREMENT_L_MIN[] PROGMEM = "L/min"; const char HA_UNIT_OF_MEASUREMENT_L_MIN[] PROGMEM = "L/min";
const char HA_UNIT_OF_MEASUREMENT_GAL_MIN[] PROGMEM = "gal/min"; const char HA_UNIT_OF_MEASUREMENT_GAL_MIN[] PROGMEM = "gal/min";
const char HA_ICON[] PROGMEM = "ic"; // "icon" const char HA_ICON[] PROGMEM = "icon";
const char HA_MIN[] PROGMEM = "min"; const char HA_MIN[] PROGMEM = "min";
const char HA_MAX[] PROGMEM = "max"; const char HA_MAX[] PROGMEM = "max";
const char HA_STEP[] PROGMEM = "step"; const char HA_STEP[] PROGMEM = "step";
const char HA_MODE[] PROGMEM = "mode"; const char HA_MODE[] PROGMEM = "mode";
const char HA_MODE_BOX[] PROGMEM = "box"; const char HA_MODE_BOX[] PROGMEM = "box";
const char HA_STATE_ON[] PROGMEM = "stat_on"; // "state_on" const char HA_STATE_ON[] PROGMEM = "state_on";
const char HA_STATE_OFF[] PROGMEM = "stat_off"; // "state_off" const char HA_STATE_OFF[] PROGMEM = "state_off";
const char HA_PAYLOAD_ON[] PROGMEM = "pl_on"; // "payload_on" const char HA_PAYLOAD_ON[] PROGMEM = "payload_on";
const char HA_PAYLOAD_OFF[] PROGMEM = "pl_off"; // "payload_off" const char HA_PAYLOAD_OFF[] PROGMEM = "payload_off";
const char HA_STATE_CLASS[] PROGMEM = "stat_cla"; // "state_class" const char HA_STATE_CLASS[] PROGMEM = "state_class";
const char HA_STATE_CLASS_MEASUREMENT[] PROGMEM = "measurement"; const char HA_STATE_CLASS_MEASUREMENT[] PROGMEM = "measurement";
const char HA_EXPIRE_AFTER[] PROGMEM = "exp_aft"; // "expire_after" const char HA_EXPIRE_AFTER[] PROGMEM = "expire_after";
const char HA_CURRENT_TEMPERATURE_TOPIC[] PROGMEM = "curr_temp_t"; // "current_temperature_topic" const char HA_CURRENT_TEMPERATURE_TOPIC[] PROGMEM = "current_temperature_topic";
const char HA_CURRENT_TEMPERATURE_TEMPLATE[] PROGMEM = "curr_temp_tpl"; // "current_temperature_template" const char HA_CURRENT_TEMPERATURE_TEMPLATE[] PROGMEM = "current_temperature_template";
const char HA_TEMPERATURE_COMMAND_TOPIC[] PROGMEM = "temp_cmd_t"; // "temperature_command_topic" const char HA_TEMPERATURE_COMMAND_TOPIC[] PROGMEM = "temperature_command_topic";
const char HA_TEMPERATURE_COMMAND_TEMPLATE[] PROGMEM = "temp_cmd_tpl"; // "temperature_command_template" const char HA_TEMPERATURE_COMMAND_TEMPLATE[] PROGMEM = "temperature_command_template";
const char HA_TEMPERATURE_STATE_TOPIC[] PROGMEM = "temp_stat_t"; // "temperature_state_topic" const char HA_TEMPERATURE_STATE_TOPIC[] PROGMEM = "temperature_state_topic";
const char HA_TEMPERATURE_STATE_TEMPLATE[] PROGMEM = "temp_stat_tpl"; // "temperature_state_template" const char HA_TEMPERATURE_STATE_TEMPLATE[] PROGMEM = "temperature_state_template";
const char HA_TEMPERATURE_UNIT[] PROGMEM = "temp_unit"; // "temperature_unit" const char HA_TEMPERATURE_UNIT[] PROGMEM = "temperature_unit";
const char HA_MODE_COMMAND_TOPIC[] PROGMEM = "mode_cmd_t"; // "mode_command_topic" const char HA_MODE_COMMAND_TOPIC[] PROGMEM = "mode_command_topic";
const char HA_MODE_COMMAND_TEMPLATE[] PROGMEM = "mode_cmd_tpl"; // "mode_command_template" const char HA_MODE_COMMAND_TEMPLATE[] PROGMEM = "mode_command_template";
const char HA_MODE_STATE_TOPIC[] PROGMEM = "mode_stat_t"; // "mode_state_topic" const char HA_MODE_STATE_TOPIC[] PROGMEM = "mode_state_topic";
const char HA_MODE_STATE_TEMPLATE[] PROGMEM = "mode_stat_tpl"; // "mode_state_template" const char HA_MODE_STATE_TEMPLATE[] PROGMEM = "mode_state_template";
const char HA_MODES[] PROGMEM = "modes"; const char HA_MODES[] PROGMEM = "modes";
const char HA_ACTION_TOPIC[] PROGMEM = "act_t"; // "action_topic" const char HA_ACTION_TOPIC[] PROGMEM = "action_topic";
const char HA_ACTION_TEMPLATE[] PROGMEM = "act_tpl"; // "action_template" const char HA_ACTION_TEMPLATE[] PROGMEM = "action_template";
const char HA_MIN_TEMP[] PROGMEM = "min_temp"; const char HA_MIN_TEMP[] PROGMEM = "min_temp";
const char HA_MAX_TEMP[] PROGMEM = "max_temp"; const char HA_MAX_TEMP[] PROGMEM = "max_temp";
const char HA_TEMP_STEP[] PROGMEM = "temp_step"; const char HA_TEMP_STEP[] PROGMEM = "temp_step";
const char HA_PRESET_MODE_COMMAND_TOPIC[] PROGMEM = "pr_mode_cmd_t"; // "preset_mode_command_topic" const char HA_PRESET_MODE_COMMAND_TOPIC[] PROGMEM = "preset_mode_command_topic";
const char HA_PRESET_MODE_COMMAND_TEMPLATE[] PROGMEM = "pr_mode_cmd_tpl"; // "preset_mode_command_template" const char HA_PRESET_MODE_COMMAND_TEMPLATE[] PROGMEM = "preset_mode_command_template";
const char HA_PRESET_MODE_STATE_TOPIC[] PROGMEM = "pr_mode_stat_t"; // "preset_mode_state_topic" const char HA_PRESET_MODE_STATE_TOPIC[] PROGMEM = "preset_mode_state_topic";
const char HA_PRESET_MODE_VALUE_TEMPLATE[] PROGMEM = "pr_mode_val_tpl"; // "preset_mode_value_template" const char HA_PRESET_MODE_VALUE_TEMPLATE[] PROGMEM = "preset_mode_value_template";
const char HA_PRESET_MODES[] PROGMEM = "pr_modes"; // "preset_modes" const char HA_PRESET_MODES[] PROGMEM = "preset_modes";
-113
View File
@@ -1,113 +0,0 @@
#pragma once
#include <NetworkUplink.h>
#include <NetworkWifi.h>
namespace NetworkUtils {
/**
* @brief Fallback AP: the setup network, raised when the station cannot carry the uplink
*/
class ApUplink : public NetworkUplink {
public:
ApUplink(UplinkContext* context, WifiUplink* wifi) : NetworkUplink(context), wifi(wifi) {}
void loop() override {
// the association carries the traffic again: retire the AP once it is stable and idle
if (this->wifi->isActive()) {
if (
this->isEnabled() && !this->hasClients()
&& millis() - this->wifi->getConnectedTime() >= this->retireDelay
) {
Log.sinfoln(FPSTR(L_NETWORK), F("Stop AP because STA connected"));
this->stop();
}
return;
}
if (this->isEnabled()) {
this->attempt.disarm();
return;
}
// a failed softAP() retries once the window runs out
if (this->attempt.isPending()) {
return;
}
this->start();
}
/**
* @brief The AP interface is up, whether or not anyone is on it
*
* A parked radio means the AP is not carrying anything, whatever the mode still says.
*/
bool isActive() override {
return this->isEnabled() && !this->wifi->isSuspended();
}
bool isEnabled() {
return (WiFi.getMode() & WIFI_AP) != 0;
}
bool hasClients() {
if (!this->isEnabled()) {
return false;
}
return WiFi.softAPgetStationNum() > 0;
}
void start() {
Log.sinfoln(
FPSTR(L_NETWORK),
this->wifi->hasCredentials()
? F("Disconnected for a long time, start AP")
: F("No STA credentials, start AP")
);
WiFi.mode(WIFI_AP_STA);
this->context->delayCallback(250);
if (!WiFi.softAP(this->context->apName, this->context->apPassword, this->context->apChannel)) {
this->attempt.arm(this->startTimeout);
}
}
void stop() {
WiFi.mode(WIFI_STA);
this->attempt.disarm();
}
IPAddress localIP() override {
return WiFi.softAPIP();
}
IPAddress subnetMask() override {
#ifdef ARDUINO_ARCH_ESP32
return WiFi.softAPSubnetMask();
#else
return IPAddress(255, 255, 255, 0);
#endif
}
IPAddress gatewayIP() override {
return WiFi.softAPIP();
}
IPAddress dnsIP() override {
return WiFi.softAPIP();
}
String macAddress() override {
return WiFi.softAPmacAddress();
}
protected:
const unsigned long retireDelay = 15000;
const unsigned long startTimeout = 5000;
WifiUplink* wifi;
};
}
-1
View File
@@ -1,4 +1,3 @@
#pragma once
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include "lwip/etharp.h" #include "lwip/etharp.h"
-269
View File
@@ -1,269 +0,0 @@
#pragma once
#include <NetworkUplink.h>
#ifdef NETWORK_HAS_ETHERNET
#include <ETH.h>
#endif
namespace NetworkUtils {
/**
* @brief Ethernet uplink: the W5500 driver, its cable and its DHCP lease
*/
class EthernetUplink : public NetworkUplink {
public:
explicit EthernetUplink(UplinkContext* context) : NetworkUplink(context) {}
void loop() override {
#ifdef NETWORK_HAS_ETHERNET
if (this->restartFlag) {
this->restartFlag = false;
// The W5500 driver cannot be re-initialized in place: Arduino's ETH.end() leaves
// the SPI bus allocated, so a wiring change only takes effect after a restart.
if (this->started) {
Log.swarningln(FPSTR(L_NETWORK), F("Ethernet: settings changed, restart required to apply them"));
}
}
if (!this->enabled || !this->hasPins()) {
if (this->active || this->linkUp) {
this->active = false;
this->linkUp = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: disabled, handing the uplink back to WiFi"));
}
this->attempt.disarm();
return;
}
if (!this->started) {
if (this->startUnavailable) {
return;
}
Log.sinfoln(
FPSTR(L_NETWORK),
F("Ethernet: init W5500 (CS: %u, IRQ: %u, RST: %u, CLK: %u, MISO: %u, MOSI: %u)"),
this->cs,
this->irq,
this->rst,
this->clk,
this->miso,
this->mosi
);
if (!ETH.begin(ETH_PHY_W5500, 1, this->cs, this->irq, this->rst, SPI2_HOST, this->clk, this->miso, this->mosi, 12)) {
// A failed init leaves the SPI bus allocated, so retrying cannot succeed;
// wait for a restart instead of flapping.
this->startUnavailable = true;
this->attempt.disarm();
Log.serrorln(FPSTR(L_NETWORK), F("Ethernet: W5500 init failed, check the wiring and restart"));
return;
}
this->started = true;
this->running = true;
this->prevLinkCheck = 0;
this->attempt.arm(this->linkGrace);
if (!this->context->useDhcp) {
ETH.config(this->context->staticIp, this->context->staticGateway, this->context->staticSubnet, this->context->staticDns);
}
if (strlen(this->context->hostname) && UplinkContext::isHostnameValid(this->context->hostname)) {
ETH.setHostname(this->context->hostname);
}
return;
}
if (millis() - this->prevLinkCheck < this->linkCheckInterval) {
return;
}
this->prevLinkCheck = millis();
if (!ETH.linkUp()) {
if (this->linkUp) {
this->linkUp = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: cable disconnected"));
}
this->attempt.disarm();
if (this->active) {
this->active = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: link lost, falling back to WiFi"));
this->context->delayCallback(250);
}
return;
}
if (!this->linkUp) {
this->linkUp = true;
this->attempt.arm(this->leaseGrace);
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: cable connected"));
}
if (!ETH.connected() || this->active) {
return;
}
this->active = true;
this->attempt.disarm();
Log.sinfoln(
FPSTR(L_NETWORK),
F("Ethernet: using ethernet instead of WiFi, IP: %s, link: %u Mbps, duplex: %u"),
ETH.localIP().toString().c_str(),
ETH.linkSpeed(),
ETH.fullDuplex() ? 1 : 0
);
#endif
}
/**
* @brief Ethernet carries the uplink: cable plugged in and DHCP lease obtained
*/
bool isActive() override {
#ifdef NETWORK_HAS_ETHERNET
if (!this->enabled || !this->started) {
return false;
}
return ETH.linkUp() && ETH.connected();
#else
return false;
#endif
}
/**
* @brief Enable/disable the interface, taking the driver in and out of the FSM
*/
void setEnabled(bool value) {
this->enabled = value;
#ifdef NETWORK_HAS_ETHERNET
// The driver stays installed: stop() only takes the link and the netif down, while the
// SPI bus, the MAC and the netif itself stay allocated, so start() resumes without a restart
if (this->started && ETH.handle() != nullptr && value != this->running) {
esp_err_t ret = value ? esp_eth_start(ETH.handle()) : esp_eth_stop(ETH.handle());
if (ret == ESP_OK) {
this->running = value;
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Ethernet: driver %s failed"), value ? "start" : "stop");
}
}
#endif
}
/**
* @brief Configure the W5500 wiring. Use GPIO_IS_NOT_CONFIGURED to disable
*/
void setPins(uint8_t clk, uint8_t mosi, uint8_t miso, uint8_t cs, uint8_t irq, uint8_t rst) {
if (
clk != this->clk || mosi != this->mosi || miso != this->miso
|| cs != this->cs || irq != this->irq || rst != this->rst
) {
this->markSettingsChanged();
}
this->clk = clk;
this->mosi = mosi;
this->miso = miso;
this->cs = cs;
this->irq = irq;
this->rst = rst;
}
/**
* @brief A setting the driver reads changed: applying it needs a restart
*/
void markSettingsChanged() {
if (this->started) {
this->restartFlag = true;
}
}
bool hasPins() {
return this->clk != GPIO_IS_NOT_CONFIGURED
&& this->mosi != GPIO_IS_NOT_CONFIGURED
&& this->miso != GPIO_IS_NOT_CONFIGURED
&& this->cs != GPIO_IS_NOT_CONFIGURED
&& this->irq != GPIO_IS_NOT_CONFIGURED
&& this->rst != GPIO_IS_NOT_CONFIGURED;
}
IPAddress localIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.localIP();
#else
return IPAddress();
#endif
}
IPAddress subnetMask() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.subnetMask();
#else
return IPAddress();
#endif
}
IPAddress gatewayIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.gatewayIP();
#else
return IPAddress();
#endif
}
IPAddress dnsIP() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.dnsIP();
#else
return IPAddress();
#endif
}
String macAddress() override {
#ifdef NETWORK_HAS_ETHERNET
return ETH.macAddress();
#else
return String();
#endif
}
protected:
const unsigned long linkCheckInterval = 1000;
const unsigned long linkGrace = 5000;
const unsigned long leaseGrace = 20000;
bool enabled = false;
bool started = false;
bool running = false;
bool active = false;
bool linkUp = false;
bool restartFlag = false;
bool startUnavailable = false;
uint8_t clk = GPIO_IS_NOT_CONFIGURED;
uint8_t mosi = GPIO_IS_NOT_CONFIGURED;
uint8_t miso = GPIO_IS_NOT_CONFIGURED;
uint8_t cs = GPIO_IS_NOT_CONFIGURED;
uint8_t irq = GPIO_IS_NOT_CONFIGURED;
uint8_t rst = GPIO_IS_NOT_CONFIGURED;
unsigned long prevLinkCheck = 0;
};
}
+355 -193
View File
@@ -1,258 +1,380 @@
#pragma once #if defined(ARDUINO_ARCH_ESP8266)
#include <NetworkAp.h> #include <ESP8266WiFi.h>
#include "lwip/etharp.h"
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#include <esp_wifi.h>
#endif
#include <NetworkConnection.h> #include <NetworkConnection.h>
#include <NetworkEthernet.h>
#include <NetworkUplink.h>
#include <NetworkWifi.h>
namespace NetworkUtils { 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 { class NetworkMgr {
public: public:
NetworkMgr() : wifi(&this->context), ap(&this->context, &this->wifi), ethernet(&this->context) { typedef std::function<void()> YieldCallback;
NetworkConnection::setup(this->context.useDhcp); typedef std::function<void(unsigned int)> DelayCallback;
this->wifi.resetWifi();
NetworkMgr() {
NetworkConnection::setup(this->useDhcp);
this->resetWifi();
} }
NetworkMgr* setYieldCallback(YieldCallback callback = nullptr) { NetworkMgr* setYieldCallback(YieldCallback callback = nullptr) {
this->context.yieldCallback = callback; this->yieldCallback = callback;
return this; return this;
} }
NetworkMgr* setDelayCallback(DelayCallback callback = nullptr) { NetworkMgr* setDelayCallback(DelayCallback callback = nullptr) {
this->context.delayCallback = callback; this->delayCallback = callback;
return this; return this;
} }
NetworkMgr* setHostname(const char* value) { NetworkMgr* setHostname(const char* value) {
this->context.hostname = value; this->hostname = value;
return this; return this;
} }
NetworkMgr* setApCredentials(const char* ssid, const char* password = nullptr, uint8_t channel = 0) { NetworkMgr* setApCredentials(const char* ssid, const char* password = nullptr, uint8_t channel = 0) {
this->context.apName = ssid; this->apName = ssid;
this->context.apPassword = password; this->apPassword = password;
this->context.apChannel = channel; this->apChannel = channel;
return this; return this;
} }
NetworkMgr* setStaCredentials(const char* ssid = nullptr, const char* password = nullptr, uint8_t channel = 0) { NetworkMgr* setStaCredentials(const char* ssid = nullptr, const char* password = nullptr, uint8_t channel = 0) {
this->context.staSsid = ssid; this->staSsid = ssid;
this->context.staPassword = password; this->staPassword = password;
this->context.staChannel = channel; this->staChannel = channel;
return this; return this;
} }
NetworkMgr* setUseDhcp(bool value) { NetworkMgr* setUseDhcp(bool value) {
if (value != this->context.useDhcp) { this->useDhcp = value;
this->ethernet.markSettingsChanged(); NetworkConnection::setup(this->useDhcp);
}
this->context.useDhcp = value;
NetworkConnection::setup(this->context.useDhcp);
return this; return this;
} }
NetworkMgr* setStaticConfig(const char* ip, const char* gateway, const char* subnet, const char* dns) { NetworkMgr* setStaticConfig(const char* ip, const char* gateway, const char* subnet, const char* dns) {
IPAddress valueIp, valueGateway, valueSubnet, valueDns; this->staticIp.fromString(ip);
this->staticGateway.fromString(gateway);
valueIp.fromString(ip); this->staticSubnet.fromString(subnet);
valueGateway.fromString(gateway); this->staticDns.fromString(dns);
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;
return this; return this;
} }
NetworkMgr* setStaticConfig(IPAddress& ip, IPAddress& gateway, IPAddress& subnet, IPAddress& dns) { NetworkMgr* setStaticConfig(IPAddress& ip, IPAddress& gateway, IPAddress& subnet, IPAddress& dns) {
if ( this->staticIp = ip;
ip != this->context.staticIp || gateway != this->context.staticGateway this->staticGateway = gateway;
|| subnet != this->context.staticSubnet || dns != this->context.staticDns this->staticSubnet = subnet;
) { this->staticDns = dns;
this->ethernet.markSettingsChanged();
}
this->context.staticIp = ip;
this->context.staticGateway = gateway;
this->context.staticSubnet = subnet;
this->context.staticDns = dns;
return this; return this;
} }
/** bool hasStaCredentials() {
* @brief Enable/disable the ethernet interface (W5500 over SPI) return this->staSsid != nullptr;
*/
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 isConnected() { bool isConnected() {
return this->getUplink() >= Uplink::Wifi; return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTED;
} }
/** bool isConnecting() {
* @brief WiFi signal quality in percent, 0 when WiFi is not carrying the uplink return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTING;
*/
uint8_t getSignalQuality() {
return this->getUplink() == Uplink::Wifi ? rssiToSignalQuality(this->wifi.rssi()) : 0;
} }
/** bool isStaEnabled() {
* @return "ethernet", "wifi", "wifi-ap" or "none" return (WiFi.getMode() & WIFI_STA) != 0;
*/
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 isApEnabled() { 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() { short int getRssi() {
return this->station()->rssi(); return WiFi.RSSI();
} }
IPAddress getApIp() { IPAddress getApIp() {
return this->ap.localIP(); return WiFi.softAPIP();
} }
IPAddress getStaIp() { IPAddress getStaIp() {
return this->station()->localIP(); return WiFi.localIP();
} }
IPAddress getStaSubnet() { IPAddress getStaSubnet() {
return this->station()->subnetMask(); return WiFi.subnetMask();
} }
IPAddress getStaGateway() { IPAddress getStaGateway() {
return this->station()->gatewayIP(); return WiFi.gatewayIP();
} }
IPAddress getStaDns() { IPAddress getStaDns() {
return this->station()->dnsIP(); return WiFi.dnsIP();
} }
String getStaMac() { String getStaMac() {
return this->station()->macAddress(); return WiFi.macAddress();
} }
const char* getStaSsid() { const char* getStaSsid() {
return this->context.staSsid; return this->staSsid;
}
const char* getStaPassword() {
return this->staPassword;
} }
uint8_t getStaChannel() { 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() { 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() { void loop() {
// The top of the hierarchy polls every pass so it can take the uplink whenever it can if (this->reconnectFlag) {
this->ethernet.loop(); this->delayCallback(5000);
this->trackUplink(); Log.sinfoln(FPSTR(L_NETWORK), F("Reconnecting..."));
this->updateWifiRadio(); this->reconnectFlag = false;
this->disconnect();
NetworkConnection::reset();
this->delayCallback(1000);
if (this->getUplink() == Uplink::Ethernet) { } 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; return;
} }
// a pending ethernet attempt holds the hierarchy: nothing below it starts until it resolves #ifdef ARDUINO_ARCH_ESP8266
if (this->ethernet.isPending() && !this->wifi.isActive() && !this->ap.isActive()) { if (millis() - this->prevArpGratuitous > 60000) {
return; 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
);
} }
this->wifi.loop(); if (!this->hasStaCredentials() && !this->isApEnabled()) {
Log.sinfoln(FPSTR(L_NETWORK), F("No STA credentials, start AP"));
// the ladder only reaches the AP once the station is out of the running WiFi.mode(WIFI_AP_STA);
if (!this->wifi.isActive() && this->wifi.isPending()) { this->delayCallback(250);
return; 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->ap.loop(); this->prevReconnectingTime = millis();
}
}
} }
static uint8_t rssiToSignalQuality(short int rssi) { static uint8_t rssiToSignalQuality(short int rssi) {
@@ -260,55 +382,95 @@ namespace NetworkUtils {
} }
protected: protected:
UplinkContext context; const unsigned int reconnectInterval = 15000;
WifiUplink wifi; const unsigned int failedConnectTimeout = 185000;
ApUplink ap; const unsigned int connectionTimeout = 10000;
EthernetUplink ethernet; const unsigned int resetConnectionTimeout = 90000;
Uplink uplink = Uplink::None; YieldCallback yieldCallback = []() {
::yield();
};
DelayCallback delayCallback = [](unsigned int time) {
::delay(time);
};
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;
}
if (strcmp(WiFi.getHostname(), hostname) == 0) {
return true;
}
return WiFi.setHostname(hostname);
}
#ifdef ARDUINO_ARCH_ESP8266
/** /**
* @brief The interface holding the station address: the wired one while it carries the * @brief
* uplink, the station otherwise * https://github.com/arendst/Tasmota/blob/e6515883f0ee5451931b6280ff847b117de5a231/tasmota/tasmota_support/support_wifi.ino#L1196
*/ */
NetworkUplink* station() { static void stationKeepAliveNow(void) {
if (this->getUplink() == Uplink::Ethernet) { for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
return &this->ethernet; 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;
} }
return &this->wifi;
} }
}
#endif
/** /**
* @brief Notice an uplink change so the hierarchy is walked from the top again * @brief check RFC compliance
*/
void trackUplink() {
const Uplink current = this->getUplink();
if (current == this->uplink) {
return;
}
Log.sinfoln(FPSTR(L_NETWORK), F("Uplink: %s -> %s"), uplinkName(this->uplink), uplinkName(current));
this->uplink = current;
}
/**
* @brief Keep the WiFi radio in step with the uplink
* *
* WiFi is only in service while it carries the traffic. The AP is for first configuration: * @param value
* once a cable carries the uplink the radio goes off, and if that uplink never comes up the * @return true
* ladder falls back to the AP again on its own. * @return false
*/ */
void updateWifiRadio() { static bool isHostnameValid(const char* value) {
if (this->ethernet.isActive()) { size_t len = strlen(value);
this->wifi.suspend(); if (len > 24) {
return false;
return; } else if (value[len - 1] == '-') {
return false;
} }
this->wifi.resume(); for (size_t i = 0; i < len; i++) {
if (!isalnum(value[i]) && value[i] != '-') {
return false;
}
}
return true;
} }
}; };
} }
-143
View File
@@ -1,143 +0,0 @@
#pragma once
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h>
#include "lwip/etharp.h"
#elif defined(ARDUINO_ARCH_ESP32)
#include <WiFi.h>
#include <esp_wifi.h>
#endif
// W5500 support needs both the ESP32 core (for ETH.h) and the per-env USE_ETHERNET flag.
// USE_ETHERNET defaults to false in defines.h, so this must be a value test, not #ifdef.
#if USE_ETHERNET && defined(ARDUINO_ARCH_ESP32)
#define NETWORK_HAS_ETHERNET
#endif
namespace NetworkUtils {
typedef std::function<void()> YieldCallback;
typedef std::function<void(unsigned int)> DelayCallback;
/**
* @brief Settings and callbacks every uplink reads
*/
struct UplinkContext {
const char* hostname = "esp";
const char* staSsid = nullptr;
const char* staPassword = nullptr;
uint8_t staChannel = 0;
const char* apName = "ESP";
const char* apPassword = nullptr;
uint8_t apChannel = 1;
bool useDhcp = true;
IPAddress staticIp;
IPAddress staticGateway;
IPAddress staticSubnet;
IPAddress staticDns;
YieldCallback yieldCallback = []() {
::yield();
};
DelayCallback delayCallback = [](unsigned int time) {
::delay(time);
};
/**
* @brief check RFC compliance
*
* @param value
* @return true
* @return false
*/
static bool isHostnameValid(const char* value) {
size_t len = strlen(value);
if (len > 24) {
return false;
} else if (value[len - 1] == '-') {
return false;
}
for (size_t i = 0; i < len; i++) {
if (!isalnum(value[i]) && value[i] != '-') {
return false;
}
}
return true;
}
};
/**
* @brief How long an uplink may still take the pass
*
* Armed when the uplink starts trying, disarmed when it resolves either way. A window that has
* run out means the uplink gave up, which lets the class below it take over.
*/
class UplinkAttempt {
public:
void arm(unsigned long window) {
this->start = millis() ? millis() : 1;
this->window = window;
}
void disarm() {
this->start = 0;
this->window = 0;
}
bool isArmed() const {
return this->window > 0;
}
bool isPending() const {
return this->window > 0 && (millis() - this->start) < this->window;
}
protected:
unsigned long start = 0;
unsigned long window = 0;
};
/**
* @brief One interface that is able to carry the uplink
*/
class NetworkUplink {
public:
explicit NetworkUplink(UplinkContext* context) : context(context) {}
virtual ~NetworkUplink() {}
/**
* @brief Run one pass of this interface's state machine
*/
virtual void loop() = 0;
/**
* @brief The interface is able to carry traffic right now
*/
virtual bool isActive() = 0;
/**
* @brief The interface may still become active, so nothing below it should start
*/
virtual bool isPending() {
return !this->isActive() && this->attempt.isPending();
}
virtual IPAddress localIP() = 0;
virtual IPAddress subnetMask() = 0;
virtual IPAddress gatewayIP() = 0;
virtual IPAddress dnsIP() = 0;
virtual String macAddress() = 0;
virtual short int rssi() {
return 0;
}
protected:
UplinkContext* context;
UplinkAttempt attempt;
};
}
-431
View File
@@ -1,431 +0,0 @@
#pragma once
#include <NetworkConnection.h>
#include <NetworkUplink.h>
namespace NetworkUtils {
/**
* @brief WiFi uplink: the station association, its radio, and the fallback AP
*/
class WifiUplink : public NetworkUplink {
public:
explicit WifiUplink(UplinkContext* context) : NetworkUplink(context) {}
void loop() override {
if (this->reconnectFlag) {
this->context->delayCallback(5000);
Log.sinfoln(FPSTR(L_NETWORK), F("Reconnecting..."));
this->reconnectFlag = false;
this->disconnect();
NetworkConnection::reset();
this->context->delayCallback(1000);
return;
}
if (this->isAssociated() && !this->hasCredentials()) {
Log.sinfoln(FPSTR(L_NETWORK), F("Reset"));
this->resetWifi();
NetworkConnection::reset();
this->context->delayCallback(1000);
return;
}
if (this->isAssociated()) {
this->attempt.disarm();
if (!this->connected) {
this->connectedTime = millis();
this->connected = true;
Log.sinfoln(
FPSTR(L_NETWORK),
F("Connected, downtime: %lu s., IP: %s, RSSI: %hhd"),
(millis() - this->disconnectedTime) / 1000,
WiFi.localIP().toString().c_str(),
WiFi.RSSI()
);
}
#ifdef ARDUINO_ARCH_ESP8266
if (millis() - this->prevArpGratuitous > 60000) {
this->stationKeepAliveNow();
this->prevArpGratuitous = millis();
}
#endif
return;
}
// the association is down: track the downtime and keep asking for the network
if (this->connected) {
this->disconnectedTime = millis();
this->connected = false;
this->attempt.arm(this->failedConnectTimeout);
Log.sinfoln(
FPSTR(L_NETWORK),
F("Disconnected, reason: %d, uptime: %lu s."),
NetworkConnection::getDisconnectReason(),
(millis() - this->connectedTime) / 1000
);
}
if (!this->hasCredentials()) {
this->attempt.disarm();
return;
}
if (!this->attempt.isArmed()) {
this->attempt.arm(this->failedConnectTimeout);
}
if (this->isConnecting() && millis() - this->prevReconnectingTime > this->resetConnectionTimeout) {
Log.swarningln(FPSTR(L_NETWORK), F("Connection timeout, reset wifi..."));
this->resetWifi();
NetworkConnection::reset();
this->context->delayCallback(250);
return;
}
if (!this->isConnecting() && (!this->prevReconnectingTime || millis() - this->prevReconnectingTime > this->reconnectInterval)) {
Log.sinfoln(FPSTR(L_NETWORK), F("Try connect..."));
NetworkConnection::reset();
if (!this->connect(true, this->connectionTimeout)) {
Log.straceln(FPSTR(L_NETWORK), F("Connection failed. Status: %d, reason: %d, raw reason: %d"), NetworkConnection::getStatus(), NetworkConnection::getDisconnectReason(), NetworkConnection::rawDisconnectReason);
}
this->prevReconnectingTime = millis();
}
}
/**
* @brief WiFi carries the uplink: radio running and associated
*/
bool isActive() override {
return !this->suspended && this->isAssociated();
}
bool isAssociated() {
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTED;
}
bool isConnecting() {
return this->isStaEnabled() && NetworkConnection::getStatus() == NetworkConnection::Status::CONNECTING;
}
bool isStaEnabled() {
return (WiFi.getMode() & WIFI_STA) != 0;
}
bool isApEnabled() {
return (WiFi.getMode() & WIFI_AP) != 0;
}
/**
* @brief When the association first came up, for the fallback AP's retirement delay
*/
unsigned long getConnectedTime() {
return this->connectedTime;
}
/**
* @brief Stop the radio while another uplink carries the traffic
*
* esp_wifi_stop() parks the radio without tearing the driver and its netifs down.
* WiFi.mode(WIFI_OFF) does the same job but also deinitialises, which panicked when it
* was called from this task with lwIP live — keep the driver allocated.
*/
void suspend() {
#ifdef ARDUINO_ARCH_ESP32
if (this->suspended) {
return;
}
if (WiFi.getMode() == WIFI_MODE_NULL) {
return;
}
// a scan holds the radio: parking it mid-scan leaves the driver half torn down
if (WiFi.scanComplete() == WIFI_SCAN_RUNNING) {
return;
}
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: uplink active, switching the WiFi radio off"));
esp_wifi_stop();
this->suspended = true;
#endif
}
/**
* @brief Bring the radio back when no other uplink carries the traffic
*/
void resume() {
#ifdef ARDUINO_ARCH_ESP32
if (!this->suspended) {
return;
}
this->suspended = false;
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: uplink lost, switching the WiFi radio back on"));
esp_wifi_start();
this->connected = false;
this->disconnectedTime = millis();
this->prevReconnectingTime = 0;
this->attempt.arm(this->failedConnectTimeout);
NetworkConnection::reset();
if (this->hasCredentials()) {
WiFi.begin(this->context->staSsid, this->context->staPassword);
Log.sinfoln(FPSTR(L_NETWORK), F("Ethernet: reconnecting to WiFi \"%s\""), this->context->staSsid);
}
#endif
}
bool isSuspended() {
return this->suspended;
}
bool resetWifi() {
// set policy manual for work 13 ch
{
#ifdef ARDUINO_ARCH_ESP8266
wifi_country_t country = {"JP", 1, 14, WIFI_COUNTRY_POLICY_MANUAL};
wifi_set_country(&country);
#elif defined(ARDUINO_ARCH_ESP32)
const wifi_country_t country = {"JP", 1, 14, CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER, WIFI_COUNTRY_POLICY_MANUAL};
esp_wifi_set_country(&country);
#endif
}
WiFi.persistent(false);
#if !defined(ESP_ARDUINO_VERSION_MAJOR) || ESP_ARDUINO_VERSION_MAJOR < 3
WiFi.setAutoConnect(false);
#endif
WiFi.setAutoReconnect(false);
#ifdef ARDUINO_ARCH_ESP8266
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#elif defined(ARDUINO_ARCH_ESP32)
WiFi.setSleep(USE_BLE ? WIFI_PS_MIN_MODEM : WIFI_PS_NONE);
#endif
WiFi.softAPdisconnect();
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_softap_dhcps_status() == DHCP_STARTED) {
wifi_softap_dhcps_stop();
}*/
#endif
WiFi.disconnect(false, true);
#ifdef ARDUINO_ARCH_ESP8266
/*if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}*/
wifi_station_dhcpc_set_maxtry(5);
#endif
#if defined(ARDUINO_ARCH_ESP32) && ESP_ARDUINO_VERSION_MAJOR < 3
// Nothing. Because memory leaks when turn off WiFi on ESP32 SDK < 3.0.0
return true;
#else
return WiFi.mode(WIFI_OFF);
#endif
}
/**
* @brief Ask for a fresh connect
*
* The attempt window is armed here so the ladder keeps the fallback AP out of the way while
* the station works on this reconnect; it expires like any other failed attempt.
*/
void reconnect() {
this->attempt.arm(this->failedConnectTimeout);
this->reconnectFlag = true;
}
bool connect(bool force = false, unsigned int timeout = 1000u) {
if (this->isAssociated() && !force) {
return true;
}
if (force && !this->isApEnabled()) {
this->resetWifi();
NetworkConnection::reset();
} else {
/*#ifdef ARDUINO_ARCH_ESP8266
if (wifi_station_dhcpc_status() == DHCP_STARTED) {
wifi_station_dhcpc_stop();
}
#endif*/
this->disconnect();
}
if (!this->hasCredentials()) {
return false;
}
this->context->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP32
if (this->setHostname(this->context->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->context->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->context->hostname);
}
#endif
if (!WiFi.mode((WiFiMode_t)(WiFi.getMode() | WIFI_STA))) {
return false;
}
this->context->delayCallback(250);
#ifdef ARDUINO_ARCH_ESP8266
if (this->setHostname(this->context->hostname)) {
Log.straceln(FPSTR(L_NETWORK), F("Set hostname '%s': success"), this->context->hostname);
} else {
Log.serrorln(FPSTR(L_NETWORK), F("Set hostname '%s': fail"), this->context->hostname);
}
this->context->delayCallback(250);
#endif
#ifdef ARDUINO_ARCH_ESP32
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
#endif
if (!this->context->useDhcp) {
WiFi.begin(this->context->staSsid, this->context->staPassword, this->context->staChannel, nullptr, false);
WiFi.config(this->context->staticIp, this->context->staticGateway, this->context->staticSubnet, this->context->staticDns);
WiFi.reconnect();
} else {
#ifdef ARDUINO_ARCH_ESP32
// the interface keeps a static address from an earlier association, so the addressing has
// to be reset before the station reconnects or the switch back to DHCP never takes effect
const IPAddress noIp(0, 0, 0, 0);
WiFi.config(noIp, noIp, noIp);
#endif
WiFi.begin(this->context->staSsid, this->context->staPassword, this->context->staChannel, nullptr, true);
}
unsigned long beginConnectionTime = millis();
while (millis() - beginConnectionTime < timeout) {
this->context->delayCallback(100);
NetworkConnection::Status status = NetworkConnection::getStatus();
if (status != NetworkConnection::Status::CONNECTING && status != NetworkConnection::Status::NONE) {
return status == NetworkConnection::Status::CONNECTED;
}
}
return false;
}
void disconnect() {
#ifdef ARDUINO_ARCH_ESP32
WiFi.disconnectAsync(false, true);
const unsigned long start = millis();
while (WiFi.isConnected() && (millis() - start) < 5000) {
this->context->delayCallback(100);
}
#else
WiFi.disconnect(false, true);
#endif
}
bool setHostname(const char* hostname) {
if (!UplinkContext::isHostnameValid(hostname)) {
return false;
}
if (strcmp(WiFi.getHostname(), hostname) == 0) {
return true;
}
return WiFi.setHostname(hostname);
}
bool hasCredentials() {
return this->context->staSsid != nullptr;
}
IPAddress localIP() override {
return WiFi.localIP();
}
IPAddress subnetMask() override {
return WiFi.subnetMask();
}
IPAddress gatewayIP() override {
return WiFi.gatewayIP();
}
IPAddress dnsIP() override {
return WiFi.dnsIP();
}
String macAddress() override {
return WiFi.macAddress();
}
short int rssi() override {
return WiFi.RSSI();
}
protected:
const unsigned int reconnectInterval = 15000;
const unsigned int failedConnectTimeout = 185000;
const unsigned int connectionTimeout = 10000;
const unsigned int resetConnectionTimeout = 90000;
bool connected = false;
bool reconnectFlag = false;
bool suspended = false;
unsigned long prevArpGratuitous = 0;
unsigned long prevReconnectingTime = 0;
unsigned long connectedTime = 0;
unsigned long disconnectedTime = 0;
#ifdef ARDUINO_ARCH_ESP8266
/**
* @brief
* https://github.com/arendst/Tasmota/blob/e6515883f0ee5451931b6280ff847b117de5a231/tasmota/tasmota_support/support_wifi.ino#L1196
*/
static void stationKeepAliveNow(void) {
for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
if (
(interface->flags & NETIF_FLAG_LINK_UP)
&& (interface->flags & NETIF_FLAG_UP)
&& interface->num == STATION_IF
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
) {
etharp_gratuitous(interface);
break;
}
}
}
#endif
};
}
+84 -105
View File
@@ -1,6 +1,6 @@
#include <Arduino.h> #include <Arduino.h>
class UpgradeHandler : public RequestHandler { class UpgradeHandler : public AsyncWebHandler {
public: public:
enum class UpgradeType { enum class UpgradeType {
FIRMWARE = 0, FIRMWARE = 0,
@@ -12,7 +12,7 @@ public:
NO_FILE, NO_FILE,
SUCCESS, SUCCESS,
PROHIBITED, PROHIBITED,
ABORTED, SIZE_MISMATCH,
ERROR_ON_START, ERROR_ON_START,
ERROR_ON_WRITE, ERROR_ON_WRITE,
ERROR_ON_FINISH ERROR_ON_FINISH
@@ -22,27 +22,20 @@ public:
UpgradeType type; UpgradeType type;
UpgradeStatus status; UpgradeStatus status;
String error; String error;
unsigned int written = 0;
} UpgradeResult; } UpgradeResult;
typedef std::function<bool(HTTPMethod, const String&)> CanHandleCallback; typedef std::function<bool(AsyncWebServerRequest *request, UpgradeType)> BeforeUpgradeCallback;
typedef std::function<bool(const String&)> CanUploadCallback; typedef std::function<void(AsyncWebServerRequest *request, const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
typedef std::function<bool(UpgradeType)> BeforeUpgradeCallback;
typedef std::function<void(const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
UpgradeHandler(const char* uri) { UpgradeHandler(AsyncURIMatcher uri) : uri(uri) {}
this->uri = uri;
bool canHandle(AsyncWebServerRequest *request) const override final {
if (!request->isHTTP()) {
return false;
} }
UpgradeHandler* setCanHandleCallback(CanHandleCallback callback = nullptr) { return this->uri.matches(request);
this->canHandleCallback = callback;
return this;
}
UpgradeHandler* setCanUploadCallback(CanUploadCallback callback = nullptr) {
this->canUploadCallback = callback;
return this;
} }
UpgradeHandler* setBeforeUpgradeCallback(BeforeUpgradeCallback callback = nullptr) { UpgradeHandler* setBeforeUpgradeCallback(BeforeUpgradeCallback callback = nullptr) {
@@ -57,67 +50,55 @@ public:
return this; return this;
} }
#if defined(ARDUINO_ARCH_ESP32) void handleRequest(AsyncWebServerRequest *request) override final {
bool canHandle(WebServer &server, HTTPMethod method, const String &uri) override {
return this->canHandle(method, uri);
}
#endif
bool canHandle(HTTPMethod method, const String& uri) override {
return method == HTTP_POST && uri.equals(this->uri) && (!this->canHandleCallback || this->canHandleCallback(method, uri));
}
#if defined(ARDUINO_ARCH_ESP32)
bool canUpload(WebServer &server, const String &uri) override {
return this->canUpload(uri);
}
#endif
bool canUpload(const String& uri) override {
return uri.equals(this->uri) && (!this->canUploadCallback || this->canUploadCallback(uri));
}
bool handle(WebServer& server, HTTPMethod method, const String& uri) override {
if (this->afterUpgradeCallback) { if (this->afterUpgradeCallback) {
this->afterUpgradeCallback(this->firmwareResult, this->filesystemResult); this->afterUpgradeCallback(request, this->firmwareResult, this->filesystemResult);
} }
this->firmwareResult.status = UpgradeStatus::NONE; this->firmwareResult.status = UpgradeStatus::NONE;
this->firmwareResult.error.clear(); this->firmwareResult.error.clear();
this->firmwareResult.written = 0;
this->filesystemResult.status = UpgradeStatus::NONE; this->filesystemResult.status = UpgradeStatus::NONE;
this->filesystemResult.error.clear(); this->filesystemResult.error.clear();
this->filesystemResult.written = 0;
return true;
} }
void upload(WebServer& server, const String& uri, HTTPUpload& upload) override { void handleUpload(AsyncWebServerRequest *request, const String &fileName, size_t index, uint8_t *data, size_t dataLength, bool isFinal) override final {
UpgradeResult* result; UpgradeResult* result = nullptr;
if (upload.name.equals(F("firmware"))) { unsigned int fileSize = 0;
const auto& fwName = request->hasParam("fw[name]", true) ? request->getParam("fw[name]", true)->value() : String();
const auto& fsName = request->hasParam("fs[name]", true) ? request->getParam("fs[name]", true)->value() : String();
if (fileName.equals(fwName)) {
result = &this->firmwareResult; result = &this->firmwareResult;
if (request->hasParam("fw[size]", true)) {
fileSize = request->getParam("fw[size]", true)->value().toInt();
}
} else if (upload.name.equals(F("filesystem"))) { } else if (fileName.equals(fsName)) {
result = &this->filesystemResult; result = &this->filesystemResult;
if (request->hasParam("fs[size]", true)) {
fileSize = request->getParam("fs[size]", true)->value().toInt();
}
}
} else { if (result == nullptr || result->status != UpgradeStatus::NONE) {
return; return;
} }
if (result->status != UpgradeStatus::NONE) { if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(request, result->type)) {
return;
}
if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(result->type)) {
result->status = UpgradeStatus::PROHIBITED; result->status = UpgradeStatus::PROHIBITED;
return; return;
} }
if (!upload.filename.length()) { if (!fileName.length() || !fileSize) {
result->status = UpgradeStatus::NO_FILE; result->status = UpgradeStatus::NO_FILE;
return; return;
} }
if (upload.status == UPLOAD_FILE_START) { if (index == 0) {
// reset // reset
if (Update.isRunning()) { if (Update.isRunning()) {
Update.end(false); Update.end(false);
@@ -125,91 +106,89 @@ public:
} }
bool begin = false; bool begin = false;
#ifdef ARDUINO_ARCH_ESP8266
Update.runAsync(true);
if (result->type == UpgradeType::FIRMWARE) {
begin = Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000, U_FLASH);
} else if (result->type == UpgradeType::FILESYSTEM) {
close_all_fs();
begin = Update.begin((size_t)FS_end - (size_t)FS_start, U_FS);
}
#elif defined(ARDUINO_ARCH_ESP32)
if (result->type == UpgradeType::FIRMWARE) { if (result->type == UpgradeType::FIRMWARE) {
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH); begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH);
} else if (result->type == UpgradeType::FILESYSTEM) { } else if (result->type == UpgradeType::FILESYSTEM) {
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_SPIFFS); begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_SPIFFS);
} }
#endif
if (!begin || Update.hasError()) { if (!begin || Update.hasError()) {
result->status = UpgradeStatus::ERROR_ON_START; result->status = UpgradeStatus::ERROR_ON_START;
#ifdef ARDUINO_ARCH_ESP8266
result->error = Update.getErrorString();
#else
result->error = Update.errorString(); result->error = Update.errorString();
#endif
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on start: %s"), upload.filename.c_str(), result->error.c_str()); Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on start: %s"), fileName.c_str(), result->error.c_str());
return; return;
} }
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', started"), upload.filename.c_str()); Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', started"), fileName.c_str());
}
} else if (upload.status == UPLOAD_FILE_WRITE) { if (dataLength) {
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { result->written += dataLength;
if (Update.write(data, dataLength) != dataLength) {
Update.end(false); Update.end(false);
result->status = UpgradeStatus::ERROR_ON_WRITE; result->status = UpgradeStatus::ERROR_ON_WRITE;
#ifdef ARDUINO_ARCH_ESP8266
result->error = Update.getErrorString();
#else
result->error = Update.errorString(); result->error = Update.errorString();
#endif
Log.serrorln( Log.serrorln(
FPSTR(L_PORTAL_OTA), FPSTR(L_PORTAL_OTA),
F("File '%s', on writing %d bytes: %s"), F("File '%s', on write %d bytes, %d of %d bytes"),
upload.filename.c_str(), upload.totalSize, result->error.c_str() fileName.c_str(),
dataLength,
result->written,
fileSize
); );
return;
} else {
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', writed %d bytes"), upload.filename.c_str(), upload.totalSize);
} }
} else if (upload.status == UPLOAD_FILE_END) { Log.sinfoln(
if (Update.end(true)) { FPSTR(L_PORTAL_OTA),
result->status = UpgradeStatus::SUCCESS; F("File '%s', write %d bytes, %d of %d bytes"),
fileName.c_str(),
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s': finish"), upload.filename.c_str()); dataLength,
result->written,
} else { fileSize
result->status = UpgradeStatus::ERROR_ON_FINISH; );
#ifdef ARDUINO_ARCH_ESP8266
result->error = Update.getErrorString();
#else
result->error = Update.errorString();
#endif
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on finish: %s"), upload.filename.c_str(), result->error);
} }
} else if (upload.status == UPLOAD_FILE_ABORTED) { if (result->written > fileSize || (isFinal && result->written < fileSize)) {
Update.end(false); Update.end(false);
result->status = UpgradeStatus::ABORTED; result->status = UpgradeStatus::SIZE_MISMATCH;
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s': aborted"), upload.filename.c_str()); Log.serrorln(
FPSTR(L_PORTAL_OTA),
F("File '%s', size mismatch: %d of %d bytes"),
fileName.c_str(),
result->written,
fileSize
);
return;
} }
if (isFinal) {
if (!Update.end(true)) {
result->status = UpgradeStatus::ERROR_ON_FINISH;
result->error = Update.errorString();
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on finish: %s"), fileName.c_str(), result->error);
return;
}
result->status = UpgradeStatus::SUCCESS;
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s': finish"), fileName.c_str());
}
}
bool isRequestHandlerTrivial() const override final {
return false;
} }
protected: protected:
CanHandleCallback canHandleCallback;
CanUploadCallback canUploadCallback;
BeforeUpgradeCallback beforeUpgradeCallback; BeforeUpgradeCallback beforeUpgradeCallback;
AfterUpgradeCallback afterUpgradeCallback; AfterUpgradeCallback afterUpgradeCallback;
const char* uri = nullptr; AsyncURIMatcher uri;
UpgradeResult firmwareResult{UpgradeType::FIRMWARE, UpgradeStatus::NONE}; UpgradeResult firmwareResult{UpgradeType::FIRMWARE, UpgradeStatus::NONE};
UpgradeResult filesystemResult{UpgradeType::FILESYSTEM, UpgradeStatus::NONE}; UpgradeResult filesystemResult{UpgradeType::FILESYSTEM, UpgradeStatus::NONE};
+3 -3
View File
@@ -4,12 +4,12 @@
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"devDependencies": { "devDependencies": {
"cssnano": "^9.3.2", "cssnano": "^7.0.2",
"cssnano-preset-advanced": "^10.0.0", "cssnano-preset-advanced": "^7.0.2",
"gulp": "^5.0.0", "gulp": "^5.0.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-gzip": "^1.4.2", "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-jsonminify": "^1.1.0",
"gulp-postcss": "^10.0.0", "gulp-postcss": "^10.0.0",
"gulp-terser": "^2.1.0", "gulp-terser": "^2.1.0",
+87 -196
View File
@@ -1,22 +1,14 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
;extra_configs = secrets.ini ;extra_configs = secrets.ini
extra_configs = secrets.default.ini extra_configs = secrets.default.ini
core_dir = .pio core_dir = .pio
[env] [env]
version = 1.6.0 version = 1.5.7-passiveble
framework = arduino framework = arduino
lib_deps = lib_deps = ESP32Async/AsyncTCP
;ESP32Async/ESPAsyncWebServer
https://github.com/ESP32Async/ESPAsyncWebServer#main
bblanchon/ArduinoJson@^7.4.2 bblanchon/ArduinoJson@^7.4.2
;ihormelnyk/OpenTherm Library@^1.1.5 ;ihormelnyk/OpenTherm Library@^1.1.5
https://github.com/Laxilef/opentherm_library#esp32_timer https://github.com/Laxilef/opentherm_library#esp32_timer
@@ -25,17 +17,18 @@ lib_deps =
gyverlibs/FileData@^1.0.3 gyverlibs/FileData@^1.0.3
gyverlibs/GyverPID@^3.3.2 gyverlibs/GyverPID@^3.3.2
gyverlibs/GyverBlinker@^1.1.1 gyverlibs/GyverBlinker@^1.1.1
pstolarz/OneWireNg@^0.14.1 https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
milesburton/DallasTemperature@^4.0.6
laxilef/TinyLogger@^1.1.1 laxilef/TinyLogger@^1.1.1
lib_ignore = OneWire
build_type = ${secrets.build_type} build_type = ${secrets.build_type}
build_flags = build_flags = -mtext-section-literals
-mtext-section-literals -Wno-deprecated-declarations
-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1 -D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial ;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
-D BUILD_VERSION='"${this.version}"' -D BUILD_VERSION='"${this.version}"'
-D BUILD_ENV='"$PIOENV"' -D BUILD_ENV='"$PIOENV"'
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
-D ARDUINOJSON_USE_DOUBLE=0
-D ARDUINOJSON_USE_LONG_LONG=0
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled} -D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud} -D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled} -D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
@@ -57,30 +50,23 @@ build_flags =
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
;monitor_filters = direct ;monitor_filters = direct
monitor_filters = monitor_filters = esp32_exception_decoder
esp32_exception_decoder
esp8266_exception_decoder esp8266_exception_decoder
board_build.flash_mode = dio board_build.flash_mode = dio
board_build.filesystem = littlefs board_build.filesystem = littlefs
check_tool = ; pvs-studio check_tool = ;pvs-studio
check_flags = check_flags = ;pvs-studio: --analysis-mode=4 --exclude-path=./.pio/libdeps
; pvs-studio:
; --analysis-mode=4
; --exclude-path=./.pio/libdeps
; Defaults ; Defaults
[esp8266_defaults] [esp8266_defaults]
platform = espressif8266@^4.2.1 platform = espressif8266@^4.2.1
platform_packages = ${env.platform_packages} platform_packages = ${env.platform_packages}
lib_deps = lib_deps = ${env.lib_deps}
${env.lib_deps}
nrwiersma/ESP8266Scheduler@^1.2 nrwiersma/ESP8266Scheduler@^1.2
lib_ignore = ${env.lib_ignore} lib_ignore =
extra_scripts = extra_scripts = post:tools/build.py
post:tools/build.py
build_type = ${env.build_type} build_type = ${env.build_type}
build_flags = build_flags = ${env.build_flags}
${env.build_flags}
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH ;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305 -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
@@ -89,25 +75,44 @@ check_tool = ${env.check_tool}
check_flags = ${env.check_flags} check_flags = ${env.check_flags}
[esp32_defaults] [esp32_defaults]
;platform = espressif32@^6.7 platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.32/platform-espressif32.zip
;platform = https://github.com/platformio/platform-espressif32.git
;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_packages = ${env.platform_packages} platform_packages = ${env.platform_packages}
board_build.partitions = esp32_partitions.csv board_build.partitions = esp32_partitions.csv
lib_deps = lib_deps = ${env.lib_deps}
${env.lib_deps}
laxilef/ESP32Scheduler@^1.0.1 laxilef/ESP32Scheduler@^1.0.1
nimble_lib = h2zero/NimBLE-Arduino@2.3.7 nimble_lib = https://github.com/h2zero/NimBLE-Arduino
lib_ignore = ${env.lib_ignore} lib_ignore = BluetoothSerial
extra_scripts = SimpleBLE
post:tools/esp32.py ESP RainMaker
RainMaker
ESP Insights
Insights
Zigbee
Matter
OpenThread
dsp
custom_component_remove = espressif/esp_hosted
espressif/esp_wifi_remote
espressif/esp-dsp
espressif/esp_modem
espressif/esp_rainmaker
espressif/rmaker_common
espressif/esp_insights
espressif/esp_diag_data_store
espressif/esp_diagnostics
espressif/libsodium
espressif/esp-modbus
espressif/esp-cbor
espressif/esp-sr
espressif/esp32-camera
espressif/qrcode
espressif/esp-zboss-lib
espressif/esp-zigbee-lib
chmorgan/esp-libhelix-mp3
extra_scripts = post:tools/esp32.py
post:tools/build.py post:tools/build.py
build_type = ${env.build_type} build_type = ${env.build_type}
build_flags = build_flags = ${env.build_flags}
${env.build_flags}
-D CORE_DEBUG_LEVEL=0 -D CORE_DEBUG_LEVEL=0
-Wl,--wrap=esp_panic_handler -Wl,--wrap=esp_panic_handler
check_tool = ${env.check_tool} check_tool = ${env.check_tool}
@@ -116,98 +121,54 @@ check_flags = ${env.check_flags}
; Boards ; Boards
[env:d1_mini] [env:d1_mini]
platform = ${esp8266_defaults.platform} extends = esp8266_defaults
platform_packages = ${esp8266_defaults.platform_packages}
board = d1_mini board = d1_mini
lib_deps = ${esp8266_defaults.lib_deps} build_flags = ${esp8266_defaults.build_flags}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags =
${esp8266_defaults.build_flags}
-D DEFAULT_OT_IN_GPIO=4 -D DEFAULT_OT_IN_GPIO=4
-D DEFAULT_OT_OUT_GPIO=5 -D DEFAULT_OT_OUT_GPIO=5
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12 -D DEFAULT_SENSOR_OUTDOOR_GPIO=12
-D DEFAULT_SENSOR_INDOOR_GPIO=14 -D DEFAULT_SENSOR_INDOOR_GPIO=14
-D DEFAULT_STATUS_LED_GPIO=13 -D DEFAULT_STATUS_LED_GPIO=13
-D DEFAULT_OT_RX_LED_GPIO=15 -D DEFAULT_OT_RX_LED_GPIO=15
check_tool = ${esp8266_defaults.check_tool}
check_flags = ${esp8266_defaults.check_flags}
[env:d1_mini_lite] [env:d1_mini_lite]
platform = ${esp8266_defaults.platform} extends = esp8266_defaults
platform_packages = ${esp8266_defaults.platform_packages}
board = d1_mini_lite board = d1_mini_lite
lib_deps = ${esp8266_defaults.lib_deps} build_flags = ${esp8266_defaults.build_flags}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags =
${esp8266_defaults.build_flags}
-D DEFAULT_OT_IN_GPIO=4 -D DEFAULT_OT_IN_GPIO=4
-D DEFAULT_OT_OUT_GPIO=5 -D DEFAULT_OT_OUT_GPIO=5
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12 -D DEFAULT_SENSOR_OUTDOOR_GPIO=12
-D DEFAULT_SENSOR_INDOOR_GPIO=14 -D DEFAULT_SENSOR_INDOOR_GPIO=14
-D DEFAULT_STATUS_LED_GPIO=13 -D DEFAULT_STATUS_LED_GPIO=13
-D DEFAULT_OT_RX_LED_GPIO=15 -D DEFAULT_OT_RX_LED_GPIO=15
check_tool = ${esp8266_defaults.check_tool}
check_flags = ${esp8266_defaults.check_flags}
[env:d1_mini_pro] [env:d1_mini_pro]
platform = ${esp8266_defaults.platform} extends = esp8266_defaults
platform_packages = ${esp8266_defaults.platform_packages}
board = d1_mini_pro board = d1_mini_pro
lib_deps = ${esp8266_defaults.lib_deps} build_flags = ${esp8266_defaults.build_flags}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags =
${esp8266_defaults.build_flags}
-D DEFAULT_OT_IN_GPIO=4 -D DEFAULT_OT_IN_GPIO=4
-D DEFAULT_OT_OUT_GPIO=5 -D DEFAULT_OT_OUT_GPIO=5
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12 -D DEFAULT_SENSOR_OUTDOOR_GPIO=12
-D DEFAULT_SENSOR_INDOOR_GPIO=14 -D DEFAULT_SENSOR_INDOOR_GPIO=14
-D DEFAULT_STATUS_LED_GPIO=13 -D DEFAULT_STATUS_LED_GPIO=13
-D DEFAULT_OT_RX_LED_GPIO=15 -D DEFAULT_OT_RX_LED_GPIO=15
check_tool = ${esp8266_defaults.check_tool}
check_flags = ${esp8266_defaults.check_flags}
[env:nodemcu_8266] [env:nodemcu_8266]
platform = ${esp8266_defaults.platform} extends = esp8266_defaults
platform_packages = ${esp8266_defaults.platform_packages}
board = nodemcuv2 board = nodemcuv2
lib_deps = ${esp8266_defaults.lib_deps} build_flags = ${esp8266_defaults.build_flags}
lib_ignore = ${esp8266_defaults.lib_ignore}
extra_scripts = ${esp8266_defaults.extra_scripts}
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
build_type = ${esp8266_defaults.build_type}
build_flags =
${esp8266_defaults.build_flags}
-D DEFAULT_OT_IN_GPIO=13 -D DEFAULT_OT_IN_GPIO=13
-D DEFAULT_OT_OUT_GPIO=15 -D DEFAULT_OT_OUT_GPIO=15
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12 -D DEFAULT_SENSOR_OUTDOOR_GPIO=12
-D DEFAULT_SENSOR_INDOOR_GPIO=4 -D DEFAULT_SENSOR_INDOOR_GPIO=4
-D DEFAULT_STATUS_LED_GPIO=2 -D DEFAULT_STATUS_LED_GPIO=2
-D DEFAULT_OT_RX_LED_GPIO=16 -D DEFAULT_OT_RX_LED_GPIO=16
check_tool = ${esp8266_defaults.check_tool}
check_flags = ${esp8266_defaults.check_flags}
[env:s2_mini] [env:s2_mini]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_s2_mini board = lolin_s2_mini
board_build.partitions = ${esp32_defaults.board_build.partitions} build_unflags = -DARDUINO_USB_MODE=1
lib_deps = ${esp32_defaults.lib_deps} build_flags = ${esp32_defaults.build_flags}
lib_ignore = ${esp32_defaults.lib_ignore}
extra_scripts = ${esp32_defaults.extra_scripts}
build_unflags =
-DARDUINO_USB_MODE=1
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D ARDUINO_USB_MODE=0 -D ARDUINO_USB_MODE=0
-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_CDC_ON_BOOT=1
-D DEFAULT_OT_IN_GPIO=33 -D DEFAULT_OT_IN_GPIO=33
@@ -216,53 +177,32 @@ build_flags =
-D DEFAULT_SENSOR_INDOOR_GPIO=7 -D DEFAULT_SENSOR_INDOOR_GPIO=7
-D DEFAULT_STATUS_LED_GPIO=11 -D DEFAULT_STATUS_LED_GPIO=11
-D DEFAULT_OT_RX_LED_GPIO=12 -D DEFAULT_OT_RX_LED_GPIO=12
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:s3_mini] [env:s3_mini]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_s3_mini board = lolin_s3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions} lib_deps = ${esp32_defaults.lib_deps}
lib_deps =
${esp32_defaults.lib_deps}
${esp32_defaults.nimble_lib} ${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore} build_unflags = -DARDUINO_USB_MODE=1
extra_scripts = ${esp32_defaults.extra_scripts} build_flags = ${esp32_defaults.build_flags}
build_unflags =
-DARDUINO_USB_MODE=1
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D ARDUINO_USB_MODE=0 -D ARDUINO_USB_MODE=0
-D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_USB_CDC_ON_BOOT=1
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D USE_BLE=1 -D USE_BLE=1
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D DEFAULT_OT_IN_GPIO=35 -D DEFAULT_OT_IN_GPIO=35
-D DEFAULT_OT_OUT_GPIO=36 -D DEFAULT_OT_OUT_GPIO=36
-D DEFAULT_SENSOR_OUTDOOR_GPIO=13 -D DEFAULT_SENSOR_OUTDOOR_GPIO=13
-D DEFAULT_SENSOR_INDOOR_GPIO=12 -D DEFAULT_SENSOR_INDOOR_GPIO=12
-D DEFAULT_STATUS_LED_GPIO=11 -D DEFAULT_STATUS_LED_GPIO=11
-D DEFAULT_OT_RX_LED_GPIO=10 -D DEFAULT_OT_RX_LED_GPIO=10
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:c3_mini] [env:c3_mini]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_c3_mini board = lolin_c3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions} lib_deps = ${esp32_defaults.lib_deps}
lib_deps =
${esp32_defaults.lib_deps}
${esp32_defaults.nimble_lib} ${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore} build_unflags = -mtext-section-literals
extra_scripts = ${esp32_defaults.extra_scripts} build_flags = ${esp32_defaults.build_flags}
build_unflags =
-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D USE_BLE=1 -D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=8 -D DEFAULT_OT_IN_GPIO=8
-D DEFAULT_OT_OUT_GPIO=10 -D DEFAULT_OT_OUT_GPIO=10
@@ -270,22 +210,13 @@ build_flags =
-D DEFAULT_SENSOR_INDOOR_GPIO=1 -D DEFAULT_SENSOR_INDOOR_GPIO=1
-D DEFAULT_STATUS_LED_GPIO=4 -D DEFAULT_STATUS_LED_GPIO=4
-D DEFAULT_OT_RX_LED_GPIO=5 -D DEFAULT_OT_RX_LED_GPIO=5
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:nodemcu_32] [env:nodemcu_32]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = nodemcu-32s board = nodemcu-32s
board_build.partitions = ${esp32_defaults.board_build.partitions} lib_deps = ${esp32_defaults.lib_deps}
lib_deps =
${esp32_defaults.lib_deps}
${esp32_defaults.nimble_lib} ${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore} build_flags = ${esp32_defaults.build_flags}
extra_scripts = ${esp32_defaults.extra_scripts}
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D USE_BLE=1 -D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=16 -D DEFAULT_OT_IN_GPIO=16
-D DEFAULT_OT_OUT_GPIO=4 -D DEFAULT_OT_OUT_GPIO=4
@@ -293,26 +224,17 @@ build_flags =
-D DEFAULT_SENSOR_INDOOR_GPIO=26 -D DEFAULT_SENSOR_INDOOR_GPIO=26
-D DEFAULT_STATUS_LED_GPIO=2 -D DEFAULT_STATUS_LED_GPIO=2
-D DEFAULT_OT_RX_LED_GPIO=19 -D DEFAULT_OT_RX_LED_GPIO=19
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:nodemcu_32_160mhz] [env:nodemcu_32_160mhz]
extends = env:nodemcu_32 extends = env:nodemcu_32
board_build.f_cpu = 160000000L ; set frequency to 160MHz board_build.f_cpu = 160000000L ; set frequency to 160MHz
[env:d1_mini32] [env:d1_mini32]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = wemos_d1_mini32 board = wemos_d1_mini32
board_build.partitions = ${esp32_defaults.board_build.partitions} lib_deps = ${esp32_defaults.lib_deps}
lib_deps =
${esp32_defaults.lib_deps}
${esp32_defaults.nimble_lib} ${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore} build_flags = ${esp32_defaults.build_flags}
extra_scripts = ${esp32_defaults.extra_scripts}
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D USE_BLE=1 -D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=21 -D DEFAULT_OT_IN_GPIO=21
-D DEFAULT_OT_OUT_GPIO=22 -D DEFAULT_OT_OUT_GPIO=22
@@ -320,65 +242,34 @@ build_flags =
-D DEFAULT_SENSOR_INDOOR_GPIO=18 -D DEFAULT_SENSOR_INDOOR_GPIO=18
-D DEFAULT_STATUS_LED_GPIO=2 -D DEFAULT_STATUS_LED_GPIO=2
-D DEFAULT_OT_RX_LED_GPIO=19 -D DEFAULT_OT_RX_LED_GPIO=19
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:esp32_c6] [env:esp32_c6]
; W5500 ethernet (USE_ETHERNET) is hardware-validated on this target only; every other env extends = esp32_defaults
; inherits the `false` default from src/defines.h and compiles the driver out. board = esp32-c6-devkitc-1
platform = ${esp32_defaults.platform}
framework = arduino, espidf
platform_packages = ${esp32_defaults.platform_packages}
board = esp32-c6-devkitm-1
board_build.partitions = ${esp32_defaults.board_build.partitions}
board_build.embed_txtfiles =
managed_components/espressif__esp_insights/server_certs/https_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
lib_deps = ${esp32_defaults.lib_deps} lib_deps = ${esp32_defaults.lib_deps}
lib_ignore = ${esp32_defaults.nimble_lib}
${esp32_defaults.lib_ignore} build_unflags = -mtext-section-literals
extra_scripts = ${esp32_defaults.extra_scripts} build_flags = ${esp32_defaults.build_flags}
build_unflags =
-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D USE_BLE=1 -D USE_BLE=1
-D USE_ETHERNET=1
-D DEFAULT_OT_IN_GPIO=15 -D DEFAULT_OT_IN_GPIO=15
-D DEFAULT_OT_OUT_GPIO=23 -D DEFAULT_OT_OUT_GPIO=23
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0 -D DEFAULT_SENSOR_OUTDOOR_GPIO=0
-D DEFAULT_SENSOR_INDOOR_GPIO=0 -D DEFAULT_SENSOR_INDOOR_GPIO=0
-D DEFAULT_STATUS_LED_GPIO=11 -D DEFAULT_STATUS_LED_GPIO=11
-D DEFAULT_OT_RX_LED_GPIO=10 -D DEFAULT_OT_RX_LED_GPIO=10
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
[env:otthing] [env:otthing]
platform = ${esp32_defaults.platform} extends = esp32_defaults
platform_packages = ${esp32_defaults.platform_packages}
board = lolin_c3_mini board = lolin_c3_mini
board_build.partitions = ${esp32_defaults.board_build.partitions} lib_deps = ${esp32_defaults.lib_deps}
lib_deps =
${esp32_defaults.lib_deps}
${esp32_defaults.nimble_lib} ${esp32_defaults.nimble_lib}
lib_ignore = ${esp32_defaults.lib_ignore} build_unflags = -mtext-section-literals
extra_scripts = ${esp32_defaults.extra_scripts} build_flags = ${esp32_defaults.build_flags}
build_unflags =
-mtext-section-literals
build_type = ${esp32_defaults.build_type}
build_flags =
${esp32_defaults.build_flags}
-D MYNEWT_VAL_BLE_EXT_ADV=1
-D USE_BLE=1 -D USE_BLE=1
-D DEFAULT_OT_IN_GPIO=3 -D DEFAULT_OT_IN_GPIO=3
-D DEFAULT_OT_OUT_GPIO=1 -D DEFAULT_OT_OUT_GPIO=1
; -D DEFAULT_SENSOR_OUTDOOR_GPIO=0 ;-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
; -D DEFAULT_SENSOR_INDOOR_GPIO=1 ;-D DEFAULT_SENSOR_INDOOR_GPIO=1
-D DEFAULT_STATUS_LED_GPIO=8 -D DEFAULT_STATUS_LED_GPIO=8
-D DEFAULT_OT_RX_LED_GPIO=2 -D DEFAULT_OT_RX_LED_GPIO=2
-D OT_BYPASS_RELAY_GPIO=20 -D OT_BYPASS_RELAY_GPIO=20
check_tool = ${esp32_defaults.check_tool}
check_flags = ${esp32_defaults.check_flags}
-5
View File
@@ -9,11 +9,6 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=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 # BT config
CONFIG_BT_ENABLED=y CONFIG_BT_ENABLED=y
+106 -162
View File
@@ -25,12 +25,6 @@ public:
} }
bool publishDynamicSensor(Sensors::Settings& sSensor, Sensors::ValueType vType = Sensors::ValueType::PRIMARY, UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) { 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; JsonDocument doc;
// set device class & unit of measurement // set device class & unit of measurement
@@ -267,13 +261,8 @@ public:
} }
// object id's // object id's
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(objId.c_str()); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(objId.c_str());
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix( doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
sSensor.type == Sensors::Type::MANUAL
? FPSTR(HA_ENTITY_NUMBER)
: FPSTR(HA_ENTITY_SENSOR),
objId.c_str()
);
const String& configTopic = this->makeConfigTopic( const String& configTopic = this->makeConfigTopic(
sSensor.type == Sensors::Type::MANUAL ? FPSTR(HA_ENTITY_NUMBER) : FPSTR(HA_ENTITY_SENSOR), sSensor.type == Sensors::Type::MANUAL ? FPSTR(HA_ENTITY_NUMBER) : FPSTR(HA_ENTITY_SENSOR),
@@ -334,8 +323,8 @@ public:
String objId = Sensors::makeObjectIdWithSuffix(sSensor.name, F("connected")); String objId = Sensors::makeObjectIdWithSuffix(sSensor.name, F("connected"));
// object id's // object id's
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(objId.c_str()); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(objId.c_str());
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), objId.c_str()); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
// state topic // state topic
doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic( doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic(
@@ -381,8 +370,8 @@ public:
String objId = Sensors::makeObjectIdWithSuffix(sSensor.name, F("signal_quality")); String objId = Sensors::makeObjectIdWithSuffix(sSensor.name, F("signal_quality"));
// object id's // object id's
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(objId.c_str()); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(objId.c_str());
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), objId.c_str()); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
// state topic // state topic
doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic( doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic(
@@ -418,6 +407,7 @@ public:
} }
bool deleteSignalQualityDynamicSensor(Sensors::Settings& sSensor) { bool deleteSignalQualityDynamicSensor(Sensors::Settings& sSensor) {
JsonDocument doc;
const String& configTopic = this->makeConfigTopic( const String& configTopic = this->makeConfigTopic(
FPSTR(HA_ENTITY_SENSOR), FPSTR(HA_ENTITY_SENSOR),
Sensors::makeObjectIdWithSuffix(sSensor.name, F("signal_quality")).c_str() Sensors::makeObjectIdWithSuffix(sSensor.name, F("signal_quality")).c_str()
@@ -431,8 +421,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_turbo")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating_turbo"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Turbo heating"); doc[FPSTR(HA_NAME)] = F("Turbo heating");
doc[FPSTR(HA_ICON)] = F("mdi:rocket-launch-outline"); doc[FPSTR(HA_ICON)] = F("mdi:rocket-launch-outline");
@@ -449,34 +439,12 @@ public:
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")).c_str(), doc); return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")).c_str(), doc);
} }
bool publishSwitchHeatingHysteresis(bool enabledByDefault = true) {
JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_hysteresis"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis"));
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Use heating hysteresis");
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
doc[FPSTR(HA_STATE_ON)] = true;
doc[FPSTR(HA_STATE_OFF)] = false;
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.enabled }}");
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
doc[FPSTR(HA_PAYLOAD_ON)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : true}}}");
doc[FPSTR(HA_PAYLOAD_OFF)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : false}}}");
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
doc.shrinkToFit();
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis")).c_str(), doc);
}
bool publishInputHeatingHysteresis(UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) { bool publishInputHeatingHysteresis(UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) {
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_hysteresis")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating_hysteresis"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("heating_hysteresis")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -490,9 +458,9 @@ public:
doc[FPSTR(HA_NAME)] = F("Heating hysteresis"); doc[FPSTR(HA_NAME)] = F("Heating hysteresis");
doc[FPSTR(HA_ICON)] = F("mdi:altimeter"); doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str(); doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.value|float(0)|round(2) }}"); doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis|float(0)|round(2) }}");
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str(); doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {\"value\" : {{ value }}}}}"); doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {{ value }}}}");
doc[FPSTR(HA_MIN)] = 0; doc[FPSTR(HA_MIN)] = 0;
doc[FPSTR(HA_MAX)] = 15; doc[FPSTR(HA_MAX)] = 15;
doc[FPSTR(HA_STEP)] = 0.01f; doc[FPSTR(HA_STEP)] = 0.01f;
@@ -507,8 +475,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_turbo_factor")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating_turbo_factor"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("heating_turbo_factor")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = F("power_factor"); doc[FPSTR(HA_DEVICE_CLASS)] = F("power_factor");
doc[FPSTR(HA_NAME)] = F("Heating turbo factor"); doc[FPSTR(HA_NAME)] = F("Heating turbo factor");
@@ -531,8 +499,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_min_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating_min_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("heating_min_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -565,8 +533,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_max_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating_max_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("heating_max_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -600,8 +568,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("dhw_min_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("dhw_min_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("dhw_min_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -634,8 +602,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("dhw_max_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("dhw_max_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("dhw_max_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -669,8 +637,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("pid")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("PID"); doc[FPSTR(HA_NAME)] = F("PID");
doc[FPSTR(HA_ICON)] = F("mdi:chart-bar-stacked"); doc[FPSTR(HA_ICON)] = F("mdi:chart-bar-stacked");
@@ -691,8 +659,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_p")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_p"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_p")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("PID factor P"); doc[FPSTR(HA_NAME)] = F("PID factor P");
doc[FPSTR(HA_ICON)] = F("mdi:alpha-p-circle-outline"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-p-circle-outline");
@@ -714,8 +682,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_i")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_i"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_i")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("PID factor I"); doc[FPSTR(HA_NAME)] = F("PID factor I");
doc[FPSTR(HA_ICON)] = F("mdi:alpha-i-circle-outline"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-i-circle-outline");
@@ -737,8 +705,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_d")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_d"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_d")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("PID factor D"); doc[FPSTR(HA_NAME)] = F("PID factor D");
doc[FPSTR(HA_ICON)] = F("mdi:alpha-d-circle-outline"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-d-circle-outline");
@@ -760,8 +728,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_dt")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_dt"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_dt")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = F("duration"); doc[FPSTR(HA_DEVICE_CLASS)] = F("duration");
doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("s"); doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("s");
@@ -785,8 +753,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_min_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_min_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_min_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -819,8 +787,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("pid_max_temp")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("pid_max_temp"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("pid_max_temp")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_TEMPERATURE);
@@ -854,8 +822,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("equitherm"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("equitherm")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Equitherm"); doc[FPSTR(HA_NAME)] = F("Equitherm");
doc[FPSTR(HA_ICON)] = F("mdi:sun-snowflake-variant"); doc[FPSTR(HA_ICON)] = F("mdi:sun-snowflake-variant");
@@ -872,19 +840,19 @@ public:
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("equitherm")).c_str(), doc); 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; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_slope")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("equitherm_n"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_slope")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Equitherm slope"); doc[FPSTR(HA_NAME)] = F("Equitherm factor N");
doc[FPSTR(HA_ICON)] = F("mdi:slope-uphill"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-n-circle-outline");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str(); 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_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_MIN)] = 0.001f;
doc[FPSTR(HA_MAX)] = 10; doc[FPSTR(HA_MAX)] = 10;
doc[FPSTR(HA_STEP)] = 0.001f; doc[FPSTR(HA_STEP)] = 0.001f;
@@ -892,88 +860,64 @@ public:
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter; doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
doc.shrinkToFit(); 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; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_exponent")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("equitherm_k"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_exponent")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Equitherm exponent"); doc[FPSTR(HA_NAME)] = F("Equitherm factor K");
doc[FPSTR(HA_ICON)] = F("mdi:exponent"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-k-circle-outline");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str(); 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_TOPIC)] = this->setSettingsTopic.c_str();
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"exponent\" : {{ value }}}}"); doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"equitherm\": {\"k_factor\" : {{ value }}}}");
doc[FPSTR(HA_MIN)] = 0.1; doc[FPSTR(HA_MIN)] = 0;
doc[FPSTR(HA_MAX)] = 2; doc[FPSTR(HA_MAX)] = 10;
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_STEP)] = 0.01f; doc[FPSTR(HA_STEP)] = 0.01f;
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX); doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter; doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
doc.shrinkToFit(); 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; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); 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_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)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.pid.enabled, 'offline', 'online') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("equitherm_target_diff_factor")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("equitherm_t"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_NUMBER), F("equitherm_target_diff_factor")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_NAME)] = F("Equitherm target diff factor"); doc[FPSTR(HA_NAME)] = F("Equitherm factor T");
doc[FPSTR(HA_ICON)] = F("mdi:chart-timeline-variant-shimmer"); doc[FPSTR(HA_ICON)] = F("mdi:alpha-t-circle-outline");
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str(); 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_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_MIN)] = 0;
doc[FPSTR(HA_MAX)] = 10; 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_MODE)] = FPSTR(HA_MODE_BOX);
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter; doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
doc.shrinkToFit(); 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);
} }
bool publishStatusState(bool enabledByDefault = true) { bool publishStatusState(bool enabledByDefault = true) {
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("status")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("status"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("status")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("problem"); doc[FPSTR(HA_DEVICE_CLASS)] = F("problem");
doc[FPSTR(HA_NAME)] = F("Status"); doc[FPSTR(HA_NAME)] = F("Status");
@@ -990,8 +934,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("emergency")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("emergency"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("emergency")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("problem"); doc[FPSTR(HA_DEVICE_CLASS)] = F("problem");
doc[FPSTR(HA_NAME)] = F("Emergency"); doc[FPSTR(HA_NAME)] = F("Emergency");
@@ -1008,8 +952,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("ot_status")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("ot_status"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("ot_status")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("connectivity"); doc[FPSTR(HA_DEVICE_CLASS)] = F("connectivity");
doc[FPSTR(HA_NAME)] = F("Opentherm status"); doc[FPSTR(HA_NAME)] = F("Opentherm status");
@@ -1029,8 +973,9 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true);
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("heating")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
//doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("running"); doc[FPSTR(HA_DEVICE_CLASS)] = F("running");
doc[FPSTR(HA_NAME)] = F("Heating"); doc[FPSTR(HA_NAME)] = F("Heating");
doc[FPSTR(HA_ICON)] = F("mdi:radiator"); doc[FPSTR(HA_ICON)] = F("mdi:radiator");
@@ -1049,8 +994,9 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true);
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("dhw")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("dhw"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("dhw")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
//doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("running"); doc[FPSTR(HA_DEVICE_CLASS)] = F("running");
doc[FPSTR(HA_NAME)] = F("DHW"); doc[FPSTR(HA_NAME)] = F("DHW");
doc[FPSTR(HA_ICON)] = F("mdi:faucet"); doc[FPSTR(HA_ICON)] = F("mdi:faucet");
@@ -1069,8 +1015,9 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true);
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("flame")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("flame"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("flame")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
//doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("running"); doc[FPSTR(HA_DEVICE_CLASS)] = F("running");
doc[FPSTR(HA_NAME)] = F("Flame"); doc[FPSTR(HA_NAME)] = F("Flame");
doc[FPSTR(HA_ICON)] = F("mdi:gas-burner"); doc[FPSTR(HA_ICON)] = F("mdi:gas-burner");
@@ -1089,8 +1036,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true);
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("fault")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("fault"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("fault")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("problem"); doc[FPSTR(HA_DEVICE_CLASS)] = F("problem");
doc[FPSTR(HA_NAME)] = F("Fault"); doc[FPSTR(HA_NAME)] = F("Fault");
@@ -1110,8 +1057,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_OT_CONN, true);
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC)); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC)); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("problem"); doc[FPSTR(HA_DEVICE_CLASS)] = F("problem");
doc[FPSTR(HA_NAME)] = F("Diagnostic"); doc[FPSTR(HA_NAME)] = F("Diagnostic");
@@ -1128,8 +1075,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("ext_pump")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("ext_pump"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BINARY_SENSOR), F("ext_pump")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("running"); doc[FPSTR(HA_DEVICE_CLASS)] = F("running");
doc[FPSTR(HA_NAME)] = F("External pump"); doc[FPSTR(HA_NAME)] = F("External pump");
@@ -1149,8 +1096,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.connected and value_json.slave.fault.active, 'online', 'offline') }}"); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.connected and value_json.slave.fault.active, 'online', 'offline') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("fault_code")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("fault_code"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), F("fault_code")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_NAME)] = F("Fault code"); doc[FPSTR(HA_NAME)] = F("Fault code");
doc[FPSTR(HA_ICON)] = F("mdi:cog-box"); doc[FPSTR(HA_ICON)] = F("mdi:cog-box");
@@ -1169,8 +1116,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.connected and value_json.slave.fault.active or value_json.slave.diag.active, 'online', 'offline') }}"); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.connected and value_json.slave.fault.active or value_json.slave.diag.active, 'online', 'offline') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("diagnostic_code")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("diagnostic_code"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), F("diagnostic_code")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_NAME)] = F("Diagnostic code"); doc[FPSTR(HA_NAME)] = F("Diagnostic code");
doc[FPSTR(HA_ICON)] = F("mdi:information-box"); doc[FPSTR(HA_ICON)] = F("mdi:information-box");
@@ -1184,13 +1131,10 @@ public:
bool publishNetworkRssi(bool enabledByDefault = true) { bool publishNetworkRssi(bool enabledByDefault = true) {
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][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_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(FPSTR(S_RSSI)); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(FPSTR(S_RSSI));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), FPSTR(S_RSSI)); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("signal_strength"); doc[FPSTR(HA_DEVICE_CLASS)] = F("signal_strength");
doc[FPSTR(HA_STATE_CLASS)] = FPSTR(HA_STATE_CLASS_MEASUREMENT); doc[FPSTR(HA_STATE_CLASS)] = FPSTR(HA_STATE_CLASS_MEASUREMENT);
@@ -1209,8 +1153,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("uptime")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("uptime"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SENSOR), F("uptime")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_DIAGNOSTIC);
doc[FPSTR(HA_DEVICE_CLASS)] = F("duration"); doc[FPSTR(HA_DEVICE_CLASS)] = F("duration");
doc[FPSTR(HA_STATE_CLASS)] = F("total_increasing"); doc[FPSTR(HA_STATE_CLASS)] = F("total_increasing");
@@ -1230,8 +1174,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("heating"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_CLIMATE), F("heating")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_NAME)] = F("Heating"); doc[FPSTR(HA_NAME)] = F("Heating");
doc[FPSTR(HA_ICON)] = F("mdi:radiator"); doc[FPSTR(HA_ICON)] = F("mdi:radiator");
@@ -1282,8 +1226,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("dhw")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("dhw"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_CLIMATE), F("dhw")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_NAME)] = F("DHW"); doc[FPSTR(HA_NAME)] = F("DHW");
doc[FPSTR(HA_ICON)] = F("mdi:faucet"); doc[FPSTR(HA_ICON)] = F("mdi:faucet");
@@ -1327,8 +1271,8 @@ public:
JsonDocument doc; JsonDocument doc;
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str(); doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(FPSTR(S_RESTART)); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(FPSTR(S_RESTART));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BUTTON), FPSTR(S_RESTART)); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART);
doc[FPSTR(HA_NAME)] = F("Restart"); doc[FPSTR(HA_NAME)] = F("Restart");
@@ -1347,8 +1291,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.fault.active, 'online', 'offline') }}"); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.fault.active, 'online', 'offline') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("reset_fault")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("reset_fault"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BUTTON), F("reset_fault")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART);
doc[FPSTR(HA_NAME)] = F("Reset fault"); doc[FPSTR(HA_NAME)] = F("Reset fault");
@@ -1367,8 +1311,8 @@ public:
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.diag.active, 'online', 'offline') }}"); doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.slave.diag.active, 'online', 'offline') }}");
doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all");
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("reset_diagnostic")); doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectIdWithPrefix(F("reset_diagnostic"));
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_BUTTON), F("reset_diagnostic")); doc[FPSTR(HA_OBJECT_ID)] = doc[FPSTR(HA_UNIQUE_ID)];
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG); doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART); doc[FPSTR(HA_DEVICE_CLASS)] = FPSTR(S_RESTART);
doc[FPSTR(HA_NAME)] = F("Reset diagnostic"); doc[FPSTR(HA_NAME)] = F("Reset diagnostic");
+23 -27
View File
@@ -43,12 +43,18 @@ protected:
bool telnetStarted = false; bool telnetStarted = false;
bool emergencyDetected = false; bool emergencyDetected = false;
unsigned long emergencyFlipTime = 0; unsigned long emergencyFlipTime = 0;
bool freezeDetected = false;
unsigned long freezeDetectedTime = 0;
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
const char* getTaskName() override { const char* getTaskName() override {
return "Main"; return "Main";
} }
uint32_t getTaskStackSize() override {
return 6000;
}
/*BaseType_t getTaskCore() override { /*BaseType_t getTaskCore() override {
return 1; return 1;
}*/ }*/
@@ -102,8 +108,7 @@ protected:
vars.mqtt.connected = tMqtt->isConnected(); vars.mqtt.connected = tMqtt->isConnected();
vars.network.connected = network->isConnected(); vars.network.connected = network->isConnected();
vars.network.rssi = network->getRssi(); vars.network.rssi = network->isConnected() ? WiFi.RSSI() : 0;
vars.network.connectionType = network->getUplink();
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) { if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
if (Log.getLevel() != settings.system.logLevel) { if (Log.getLevel() != settings.system.logLevel) {
@@ -134,6 +139,8 @@ protected:
tMqtt->disable(); tMqtt->disable();
} }
Sensors::setConnectionStatusByType(Sensors::Type::MANUAL, !settings.mqtt.enabled || vars.mqtt.connected, false);
} else { } else {
if (this->ntpStarted) { if (this->ntpStarted) {
this->ntpStarted = false; this->ntpStarted = false;
@@ -242,7 +249,7 @@ protected:
void heating() { void heating() {
// freeze protection // freeze protection
{ if (!settings.heating.enabled) {
float lowTemp = 255.0f; float lowTemp = 255.0f;
uint8_t availableSensors = 0; uint8_t availableSensors = 0;
@@ -273,40 +280,29 @@ protected:
availableSensors++; availableSensors++;
} }
if (availableSensors) { if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
if (vars.master.heating.freezing) { if (!this->freezeDetected) {
if (lowTemp - (float) settings.heating.freezeProtection.highTemp + 0.0001f >= 0.0f) { this->freezeDetected = true;
vars.master.heating.freezing = false; this->freezeDetectedTime = millis();
Log.sinfoln( } else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) {
FPSTR(L_MAIN), this->freezeDetected = false;
F("No freezing detected. Current low temp: %.2f, threshold (high): %hhu"),
lowTemp, settings.heating.freezeProtection.highTemp
);
}
} 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; settings.heating.enabled = true;
fsSettings.update(); fsSettings.update();
}
Log.sinfoln( Log.sinfoln(
FPSTR(L_MAIN), FPSTR(L_MAIN),
F("Freezing detected! Current low temp: %.2f, threshold (low): %hhu"), F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp lowTemp, settings.heating.freezeProtection.lowTemp
); );
} }
} else if (this->freezeDetected) {
this->freezeDetected = false;
} }
} else if (vars.master.heating.freezing) { } else if (this->freezeDetected) {
vars.master.heating.freezing = false; this->freezeDetected = false;
Log.sinfoln(FPSTR(L_MAIN), F("No sensors available, freeze protection unavailable!"));
}
} }
} }
@@ -327,7 +323,7 @@ protected:
emergencyFlags |= 0b00000010; emergencyFlags |= 0b00000010;
} }
if (settings.opentherm.options.nativeOTC) { if (settings.opentherm.options.nativeHeatingControl) {
emergencyFlags |= 0b00000100; emergencyFlags |= 0b00000100;
} }
} }
+3 -5
View File
@@ -486,7 +486,6 @@ protected:
void publishHaEntities() { void publishHaEntities() {
// heating // heating
this->haHelper->publishSwitchHeatingTurbo(false); this->haHelper->publishSwitchHeatingTurbo(false);
this->haHelper->publishSwitchHeatingHysteresis();
this->haHelper->publishInputHeatingHysteresis(settings.system.unitSystem); this->haHelper->publishInputHeatingHysteresis(settings.system.unitSystem);
this->haHelper->publishInputHeatingTurboFactor(false); this->haHelper->publishInputHeatingTurboFactor(false);
this->haHelper->publishInputHeatingMinTemp(settings.system.unitSystem); this->haHelper->publishInputHeatingMinTemp(settings.system.unitSystem);
@@ -503,10 +502,9 @@ protected:
// equitherm // equitherm
this->haHelper->publishSwitchEquitherm(); this->haHelper->publishSwitchEquitherm();
this->haHelper->publishInputEquithermSlope(false); this->haHelper->publishInputEquithermFactorN(false);
this->haHelper->publishInputEquithermExponent(false); this->haHelper->publishInputEquithermFactorK(false);
this->haHelper->publishInputEquithermShift(false); this->haHelper->publishInputEquithermFactorT(false);
this->haHelper->publishInputEquithermTargetDiffFactor(false);
// states // states
this->haHelper->publishStatusState(); this->haHelper->publishStatusState();
+54 -129
View File
@@ -38,6 +38,10 @@ protected:
return "OpenTherm"; return "OpenTherm";
} }
uint32_t getTaskStackSize() override {
return 7500;
}
BaseType_t getTaskCore() override { BaseType_t getTaskCore() override {
return 1; return 1;
} }
@@ -170,7 +174,8 @@ protected:
// Heating settings // Heating settings
vars.master.heating.enabled = this->isReady() vars.master.heating.enabled = this->isReady()
&& settings.heating.enabled && settings.heating.enabled
&& (vars.master.heating.freezing || (vars.cascadeControl.input && !vars.master.heating.blocking)) && vars.cascadeControl.input
&& !vars.master.heating.blocking
&& !vars.master.heating.overheat; && !vars.master.heating.overheat;
// DHW settings // DHW settings
@@ -185,9 +190,7 @@ protected:
|| (settings.opentherm.options.dhwToCh2 && settings.opentherm.options.dhwSupport && settings.dhw.enabled); || (settings.opentherm.options.dhwToCh2 && settings.opentherm.options.dhwSupport && settings.dhw.enabled);
if (settings.opentherm.options.heatingToCh2) { if (settings.opentherm.options.heatingToCh2) {
vars.master.ch2.targetTemp = !settings.opentherm.options.nativeOTC vars.master.ch2.targetTemp = vars.master.heating.setpointTemp;
? vars.master.heating.setpointTemp
: vars.master.heating.targetTemp;
} else if (settings.opentherm.options.dhwToCh2) { } else if (settings.opentherm.options.dhwToCh2) {
vars.master.ch2.targetTemp = vars.master.dhw.targetTemp; vars.master.ch2.targetTemp = vars.master.dhw.targetTemp;
@@ -219,7 +222,7 @@ protected:
vars.master.heating.enabled, vars.master.heating.enabled,
vars.master.dhw.enabled, vars.master.dhw.enabled,
settings.opentherm.options.coolingSupport, settings.opentherm.options.coolingSupport,
settings.opentherm.options.nativeOTC, settings.opentherm.options.nativeHeatingControl,
vars.master.ch2.enabled, vars.master.ch2.enabled,
summerWinterMode, summerWinterMode,
dhwBlocking, dhwBlocking,
@@ -306,7 +309,6 @@ protected:
Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_BURNER_HOURS, false); Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_BURNER_HOURS, false);
Sensors::setConnectionStatusByType(Sensors::Type::OT_HEATING_PUMP_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_DHW_PUMP_HOURS, false);
Sensors::setConnectionStatusByType(Sensors::Type::OT_COOLING_HOURS, false);
this->initialized = false; this->initialized = false;
this->disconnectedTime = millis(); this->disconnectedTime = millis();
@@ -679,21 +681,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 // Auto fault reset
if (settings.opentherm.options.autoFaultReset && vars.slave.fault.active && !vars.actions.resetFault) { if (settings.opentherm.options.autoFaultReset && vars.slave.fault.active && !vars.actions.resetFault) {
vars.actions.resetFault = true; vars.actions.resetFault = true;
@@ -809,7 +796,7 @@ protected:
bool result = this->updateDhwTemp(); bool result = this->updateDhwTemp();
if (result) { if (result) {
const float convertedDhwTemp = convertTemp( float convertedDhwTemp = convertTemp(
vars.slave.dhw.currentTemp, vars.slave.dhw.currentTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -833,7 +820,7 @@ protected:
// Update DHW temp 2 // Update DHW temp 2
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2, true)) { if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2, true)) {
if (this->updateDhwTemp2()) { if (this->updateDhwTemp2()) {
const float convertedDhwTemp2 = convertTemp( float convertedDhwTemp2 = convertTemp(
vars.slave.dhw.currentTemp2, vars.slave.dhw.currentTemp2,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -857,7 +844,7 @@ protected:
// Update DHW flow rate // Update DHW flow rate
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE, true)) { if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE, true)) {
if (this->updateDhwFlowRate()) { if (this->updateDhwFlowRate()) {
const float convertedDhwFlowRate = convertVolume( float convertedDhwFlowRate = convertVolume(
vars.slave.dhw.flowRate, vars.slave.dhw.flowRate,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -881,7 +868,7 @@ protected:
// Update heating temp // Update heating temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP, true)) {
if (this->updateHeatingTemp()) { if (this->updateHeatingTemp()) {
const float convertedHeatingTemp = convertTemp( float convertedHeatingTemp = convertTemp(
vars.slave.heating.currentTemp, vars.slave.heating.currentTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -905,7 +892,7 @@ protected:
// Update heating return temp // Update heating return temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP, true)) {
if (this->updateHeatingReturnTemp()) { if (this->updateHeatingReturnTemp()) {
const float convertedHeatingReturnTemp = convertTemp( float convertedHeatingReturnTemp = convertTemp(
vars.slave.heating.returnTemp, vars.slave.heating.returnTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -928,9 +915,9 @@ protected:
// Update CH2 temp // Update CH2 temp
if (Sensors::getAmountByType(Sensors::Type::OT_CH2_TEMP, true)) { 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()) { if (this->updateCh2Temp()) {
const float convertedCh2Temp = convertTemp( float convertedCh2Temp = convertTemp(
vars.slave.ch2.currentTemp, vars.slave.ch2.currentTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -955,7 +942,7 @@ protected:
// Update exhaust temp // Update exhaust temp
if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP, true)) {
if (this->updateExhaustTemp()) { if (this->updateExhaustTemp()) {
const float convertedExhaustTemp = convertTemp( float convertedExhaustTemp = convertTemp(
vars.slave.exhaust.temp, vars.slave.exhaust.temp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -979,7 +966,7 @@ protected:
// Update heat exchanger temp // Update heat exchanger temp
if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP, true)) {
if (this->updateHeatExchangerTemp()) { if (this->updateHeatExchangerTemp()) {
const float convertedHeatExchTemp = convertTemp( float convertedHeatExchTemp = convertTemp(
vars.slave.heatExchangerTemp, vars.slave.heatExchangerTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -1003,7 +990,7 @@ protected:
// Update outdoor temp // Update outdoor temp
if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP, true)) {
if (this->updateOutdoorTemp()) { if (this->updateOutdoorTemp()) {
const float convertedOutdoorTemp = convertTemp( float convertedOutdoorTemp = convertTemp(
vars.slave.heating.outdoorTemp, vars.slave.heating.outdoorTemp,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -1027,7 +1014,7 @@ protected:
// Update solar storage temp // Update solar storage temp
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_STORAGE_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_STORAGE_TEMP, true)) {
if (this->updateSolarStorageTemp()) { if (this->updateSolarStorageTemp()) {
const float convertedSolarStorageTemp = convertTemp( float convertedSolarStorageTemp = convertTemp(
vars.slave.solar.storage, vars.slave.solar.storage,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -1051,7 +1038,7 @@ protected:
// Update solar collector temp // Update solar collector temp
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_COLLECTOR_TEMP, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_COLLECTOR_TEMP, true)) {
if (this->updateSolarCollectorTemp()) { if (this->updateSolarCollectorTemp()) {
const float convertedSolarCollectorTemp = convertTemp( float convertedSolarCollectorTemp = convertTemp(
vars.slave.solar.collector, vars.slave.solar.collector,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -1097,7 +1084,7 @@ protected:
// Update pressure // Update pressure
if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE, true)) { if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE, true)) {
if (this->updatePressure()) { if (this->updatePressure()) {
const float convertedPressure = convertPressure( float convertedPressure = convertPressure(
vars.slave.pressure, vars.slave.pressure,
settings.opentherm.unitSystem, settings.opentherm.unitSystem,
settings.system.unitSystem settings.system.unitSystem
@@ -1203,12 +1190,9 @@ protected:
// Update DHW temp // Update DHW temp
if (vars.master.dhw.enabled) { if (vars.master.dhw.enabled) {
// Target dhw temp
const float& targetTemp = vars.master.dhw.targetTemp;
// Converted target dhw temp // Converted target dhw temp
const float convertedTemp = convertTemp( float convertedTemp = convertTemp(
targetTemp, vars.master.dhw.targetTemp,
settings.system.unitSystem, settings.system.unitSystem,
settings.opentherm.unitSystem settings.opentherm.unitSystem
); );
@@ -1220,7 +1204,7 @@ protected:
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_DHW), F("Set temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
@@ -1229,19 +1213,16 @@ protected:
} }
} }
// Send indoor temp if AlwaysSendIndoorTemp option is enabled. // Native heating control
if (settings.opentherm.options.nativeOTC || settings.opentherm.options.alwaysSendIndoorTemp) { if (settings.opentherm.options.nativeHeatingControl) {
// Current indoor temp
const float& indoorTemp = vars.master.heating.indoorTemp;
// Converted current indoor temp // 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 // Set current indoor temp
if (this->setRoomTemp(convertedTemp)) { if (this->setRoomTemp(convertedTemp)) {
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set current indoor temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
@@ -1253,26 +1234,17 @@ protected:
if (this->setRoomTempCh2(convertedTemp)) { if (this->setRoomTempCh2(convertedTemp)) {
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set current CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
Log.swarningln(FPSTR(L_OT_HEATING), F("Failed set current CH2 indoor temp")); 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 // Converted target indoor temp
const float convertedTemp = convertTemp( convertedTemp = convertTemp(vars.master.heating.targetTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
// Set target indoor temp // Set target indoor temp
if (this->needSetHeatingTemp(convertedTemp)) { if (this->needSetHeatingTemp(convertedTemp)) {
@@ -1281,7 +1253,7 @@ protected:
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target indoor temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
@@ -1296,7 +1268,7 @@ protected:
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
@@ -1305,22 +1277,10 @@ protected:
} }
} }
// Set heating temp // Normal heating control
{ if (!settings.opentherm.options.nativeHeatingControl && vars.master.heating.enabled) {
// 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;
}
// Converted target heating temp // Converted target heating temp
const float convertedTemp = convertTemp( float convertedTemp = convertTemp(vars.master.heating.setpointTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
targetTemp,
settings.system.unitSystem,
settings.opentherm.unitSystem
);
if (this->needSetHeatingTemp(convertedTemp)) { if (this->needSetHeatingTemp(convertedTemp)) {
// Set max heating temp // Set max heating temp
@@ -1328,13 +1288,13 @@ protected:
if (this->setMaxHeatingTemp(convertedTemp)) { if (this->setMaxHeatingTemp(convertedTemp)) {
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set max heating temp: %.2f (converted: %.2f)"), FPSTR(L_OT_HEATING), F("Set max heating temp: %.2f (converted: %.2f)"),
targetTemp, convertedTemp vars.master.heating.setpointTemp, convertedTemp
); );
} else { } else {
Log.swarningln( Log.swarningln(
FPSTR(L_OT_HEATING), F("Failed set max heating temp: %.2f (converted: %.2f)"), FPSTR(L_OT_HEATING), F("Failed set max heating temp: %.2f (converted: %.2f)"),
targetTemp, convertedTemp vars.master.heating.setpointTemp, convertedTemp
); );
} }
} }
@@ -1345,7 +1305,7 @@ protected:
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_HEATING), F("Set target temp: %.2f (converted: %.2f, response: %.2f)"), 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 { } else {
@@ -1355,15 +1315,11 @@ protected:
} }
// Set CH2 temp // Set CH2 temp
if (!settings.opentherm.options.nativeHeatingControl && vars.master.ch2.enabled) {
if (settings.opentherm.options.heatingToCh2 || settings.opentherm.options.dhwToCh2) { 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;
// Converted target CH2 temp // Converted target CH2 temp
const float convertedTemp = convertTemp( float convertedTemp = convertTemp(
targetTemp, vars.master.ch2.targetTemp,
settings.system.unitSystem, settings.system.unitSystem,
settings.opentherm.unitSystem settings.opentherm.unitSystem
); );
@@ -1374,7 +1330,7 @@ protected:
Log.sinfoln( Log.sinfoln(
FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"), FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
targetTemp, convertedTemp, vars.slave.ch2.targetTemp vars.master.ch2.targetTemp, convertedTemp, vars.slave.ch2.targetTemp
); );
} else { } else {
@@ -1382,11 +1338,12 @@ protected:
} }
} }
} }
}
// Heating overheat control // Heating overheat control
if (settings.heating.overheatProtection.highTemp > 0 && settings.heating.overheatProtection.lowTemp > 0) { if (settings.heating.overheatProtection.highTemp > 0 && settings.heating.overheatProtection.lowTemp > 0) {
const float highTemp = convertTemp( float highTemp = convertTemp(
max({ max({
vars.slave.heating.currentTemp, vars.slave.heating.currentTemp,
vars.slave.heating.returnTemp, vars.slave.heating.returnTemp,
@@ -1423,7 +1380,7 @@ protected:
// DHW overheat control // DHW overheat control
if (settings.dhw.overheatProtection.highTemp > 0 && settings.dhw.overheatProtection.lowTemp > 0) { if (settings.dhw.overheatProtection.highTemp > 0 && settings.dhw.overheatProtection.lowTemp > 0) {
const float highTemp = convertTemp( float highTemp = convertTemp(
max({ max({
vars.slave.heating.currentTemp, vars.slave.heating.currentTemp,
vars.slave.heating.returnTemp, vars.slave.heating.returnTemp,
@@ -1517,19 +1474,6 @@ protected:
} else { } else {
Log.swarningln(FPSTR(L_OT), F("Failed set master config")); 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() { bool isReady() {
@@ -1707,7 +1651,7 @@ protected:
} }
bool setRoomTemp(const float temperature) { bool setRoomTemp(float temperature) {
const unsigned int request = CustomOpenTherm::temperatureToData(temperature); const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermMessageType::WRITE_DATA, OpenThermMessageType::WRITE_DATA,
@@ -1727,7 +1671,7 @@ protected:
return CustomOpenTherm::getUInt(response) == request; return CustomOpenTherm::getUInt(response) == request;
} }
bool setRoomTempCh2(const float temperature) { bool setRoomTempCh2(float temperature) {
const unsigned int request = CustomOpenTherm::temperatureToData(temperature); const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermMessageType::WRITE_DATA, OpenThermMessageType::WRITE_DATA,
@@ -2229,25 +2173,6 @@ protected:
return true; 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() { bool updateModulationLevel() {
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermRequestType::READ_DATA, OpenThermRequestType::READ_DATA,
@@ -2262,7 +2187,7 @@ protected:
return false; return false;
} }
const float value = CustomOpenTherm::getFloat(response); float value = CustomOpenTherm::getFloat(response);
if (value < 0) { if (value < 0) {
return false; return false;
} }
@@ -2286,7 +2211,7 @@ protected:
return false; return false;
} }
const float value = CustomOpenTherm::getFloat(response); float value = CustomOpenTherm::getFloat(response);
if (value <= 0) { if (value <= 0) {
return false; return false;
} }
@@ -2310,7 +2235,7 @@ protected:
return false; return false;
} }
const float value = CustomOpenTherm::getFloat(response); float value = CustomOpenTherm::getFloat(response);
if (value <= 0) { if (value <= 0) {
return false; return false;
} }
@@ -2364,7 +2289,7 @@ protected:
return false; return false;
} }
const float value = CustomOpenTherm::getFloat(response); float value = CustomOpenTherm::getFloat(response);
if (value <= 0) { if (value <= 0) {
return false; return false;
} }
@@ -2428,7 +2353,7 @@ protected:
return false; return false;
} }
const float value = (float) CustomOpenTherm::getInt(response); float value = (float) CustomOpenTherm::getInt(response);
if (!isValidTemp(value, settings.opentherm.unitSystem, -40, 500)) { if (!isValidTemp(value, settings.opentherm.unitSystem, -40, 500)) {
return false; return false;
} }
@@ -2452,7 +2377,7 @@ protected:
return false; return false;
} }
const float value = (float) CustomOpenTherm::getInt(response); float value = (float) CustomOpenTherm::getInt(response);
if (value <= 0) { if (value <= 0) {
return false; return false;
} }
@@ -2553,7 +2478,7 @@ protected:
return false; return false;
} }
const float value = CustomOpenTherm::getFloat(response); float value = CustomOpenTherm::getFloat(response);
if (value < 0) { if (value < 0) {
return false; return false;
} }
+312 -726
View File
File diff suppressed because it is too large. Load diff
+44 -36
View File
@@ -1,5 +1,7 @@
#include <Equitherm.h>
#include <GyverPID.h> #include <GyverPID.h>
Equitherm etRegulator;
GyverPID pidRegulator(0, 0, 0); GyverPID pidRegulator(0, 0, 0);
@@ -20,6 +22,10 @@ protected:
return "Regulator"; return "Regulator";
} }
uint32_t getTaskStackSize() override {
return 5000;
}
/*BaseType_t getTaskCore() override { /*BaseType_t getTaskCore() override {
return 1; return 1;
}*/ }*/
@@ -37,7 +43,7 @@ protected:
this->indoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::INDOOR_TEMP); this->indoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::INDOOR_TEMP);
//this->outdoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::OUTDOOR_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.indoorTempControl = true;
vars.master.heating.minTemp = THERMOSTAT_INDOOR_MIN_TEMP; vars.master.heating.minTemp = THERMOSTAT_INDOOR_MIN_TEMP;
vars.master.heating.maxTemp = THERMOSTAT_INDOOR_MAX_TEMP; vars.master.heating.maxTemp = THERMOSTAT_INDOOR_MAX_TEMP;
@@ -90,15 +96,15 @@ protected:
void hysteresis() { void hysteresis() {
bool useHyst = false; bool useHyst = false;
if (settings.heating.hysteresis.enabled && this->indoorSensorsConnected) { if (settings.heating.hysteresis > 0.01f && 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) { if (useHyst) {
if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis.value) { if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis) {
vars.master.heating.blocking = true; vars.master.heating.blocking = true;
} else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis.value)) { } else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis)) {
vars.master.heating.blocking = false; vars.master.heating.blocking = false;
} }
@@ -108,13 +114,13 @@ protected:
} }
inline float getHeatingMinSetpointTemp() { inline float getHeatingMinSetpointTemp() {
return settings.opentherm.options.nativeOTC return settings.opentherm.options.nativeHeatingControl
? vars.master.heating.minTemp ? vars.master.heating.minTemp
: settings.heating.minTemp; : settings.heating.minTemp;
} }
inline float getHeatingMaxSetpointTemp() { inline float getHeatingMaxSetpointTemp() {
return settings.opentherm.options.nativeOTC return settings.opentherm.options.nativeHeatingControl
? vars.master.heating.maxTemp ? vars.master.heating.maxTemp
: settings.heating.maxTemp; : settings.heating.maxTemp;
} }
@@ -135,7 +141,7 @@ protected:
if (vars.emergency.state) { if (vars.emergency.state) {
return settings.emergency.target; return settings.emergency.target;
} else if (settings.opentherm.options.nativeOTC) { } else if (settings.opentherm.options.nativeHeatingControl) {
return settings.heating.target; return settings.heating.target;
} else if (!settings.equitherm.enabled && !settings.pid.enabled) { } else if (!settings.equitherm.enabled && !settings.pid.enabled) {
@@ -144,32 +150,39 @@ protected:
// if use equitherm // if use equitherm
if (settings.equitherm.enabled) { if (settings.equitherm.enabled) {
float tempDelta = settings.heating.target - vars.master.heating.outdoorTemp; unsigned short minTemp = settings.heating.minTemp;
float maxPoint = settings.heating.target - ( unsigned short maxTemp = settings.heating.maxTemp;
settings.heating.maxTemp - settings.heating.target float targetTemp = settings.heating.target;
) / settings.equitherm.slope; float indoorTemp = vars.master.heating.indoorTemp;
float outdoorTemp = vars.master.heating.outdoorTemp;
float sf = (settings.heating.maxTemp - settings.heating.target) / pow( if (settings.system.unitSystem == UnitSystem::IMPERIAL) {
settings.heating.target - maxPoint, minTemp = f2c(minTemp);
1.0f / settings.equitherm.exponent maxTemp = f2c(maxTemp);
); targetTemp = f2c(targetTemp);
float etResult = settings.heating.target + settings.equitherm.shift + sf * ( indoorTemp = f2c(indoorTemp);
tempDelta >= 0 outdoorTemp = f2c(outdoorTemp);
? 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;
} }
// limit if (!this->indoorSensorsConnected || settings.pid.enabled) {
etResult = constrain(etResult, settings.heating.minTemp, settings.heating.maxTemp); 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) { if (fabsf(prevEtResult - etResult) > 0.09f) {
prevEtResult = etResult; prevEtResult = etResult;
@@ -240,11 +253,6 @@ protected:
) * settings.heating.turboFactor; ) * 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; return newTemp;
} }
}; };
+3 -4
View File
@@ -34,7 +34,6 @@ public:
OT_DHW_BURNER_HOURS = 24, OT_DHW_BURNER_HOURS = 24,
OT_HEATING_PUMP_HOURS = 25, OT_HEATING_PUMP_HOURS = 25,
OT_DHW_PUMP_HOURS = 26, OT_DHW_PUMP_HOURS = 26,
OT_COOLING_HOURS = 27,
NTC_10K_TEMP = 50, NTC_10K_TEMP = 50,
DALLAS_TEMP = 51, DALLAS_TEMP = 51,
@@ -330,12 +329,12 @@ public:
static float getMeanValueByPurpose(Purpose purpose, const ValueType valueType, bool onlyConnected = true) { static float getMeanValueByPurpose(Purpose purpose, const ValueType valueType, bool onlyConnected = true) {
if (settings == nullptr || results == nullptr) { if (settings == nullptr || results == nullptr) {
return 0.0f; return 0;
} }
uint8_t valueId = (uint8_t) valueType; uint8_t valueId = (uint8_t) valueType;
if (!isValidValueId(valueId)) { if (!isValidValueId(valueId)) {
return 0.0f; return 0;
} }
float value = 0.0f; float value = 0.0f;
@@ -364,7 +363,7 @@ public:
static bool existsConnectedSensorsByPurpose(Purpose purpose) { static bool existsConnectedSensorsByPurpose(Purpose purpose) {
if (settings == nullptr || results == nullptr) { if (settings == nullptr || results == nullptr) {
return false; return 0;
} }
for (uint8_t id = 0; id <= getMaxSensorId(); id++) { for (uint8_t id = 0; id <= getMaxSensorId(); id++) {
+198 -578
View File
@@ -9,41 +9,136 @@
extern FileData fsSensorsSettings; extern FileData fsSensorsSettings;
#if USE_BLE #if USE_BLE
class BluetoothClientCallbacks : public NimBLEClientCallbacks { class BluetoothScanCallbacks : public NimBLEScanCallbacks {
public: public:
BluetoothClientCallbacks(uint8_t sensorId) : sensorId(sensorId) {} void onDiscovered(const NimBLEAdvertisedDevice* device) override {
auto& deviceAddress = device->getAddress();
void onConnect(NimBLEClient* pClient) { bool found = false;
auto& sSensor = Sensors::settings[this->sensorId];
Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': connected to %s"),
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str()
);
}
void onDisconnect(NimBLEClient* pClient, int reason) {
auto& sSensor = Sensors::settings[this->sensorId];
Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': disconnected, reason %i"),
sensorId, sSensor.name, reason
);
}
void onConnectFail(NimBLEClient* pClient, int reason) {
auto& sSensor = Sensors::settings[this->sensorId];
Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to connect, reason %i"),
sensorId, sSensor.name, reason
);
pClient->cancelConnect();
}
protected:
uint8_t sensorId; uint8_t sensorId;
for (sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) {
auto& sSensor = Sensors::settings[sensorId];
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
continue;
}
const auto sensorAddress = NimBLEAddress(sSensor.address, deviceAddress.getType());
if (sensorAddress.isNull() || sensorAddress != deviceAddress) {
continue;
}
found = true;
break;
}
if (!found) {
return;
}
auto& sSensor = Sensors::settings[sensorId];
auto& rSensor = Sensors::results[sensorId];
auto deviceName = device->getName();
auto deviceRssi = device->getRSSI();
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': discovered device %s, name: %s, RSSI: %hhd"),
sensorId, sSensor.name,
deviceAddress.toString().c_str(), deviceName.c_str(), deviceRssi
);
if (!device->haveServiceData()) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found service data"),
sensorId, sSensor.name
);
return;
}
auto serviceDataCount = device->getServiceDataCount();
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found %hhu service data"),
sensorId, sSensor.name, serviceDataCount
);
NimBLEUUID serviceUuid((uint16_t) 0x181A);
auto serviceData = device->getServiceData(serviceUuid);
if (!serviceData.size()) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': NOT found %s env service data"),
sensorId, sSensor.name, serviceUuid.toString().c_str()
);
return;
}
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found %s env service data"),
sensorId, sSensor.name, serviceUuid.toString().c_str()
);
float temperature, humidity;
uint16_t batteryMv;
uint8_t batteryLevel;
if (serviceData.size() == 13) {
// atc1441 format
// Temperature (2 bytes, big-endian)
temperature = (
(static_cast<uint8_t>(serviceData[6]) << 8) | static_cast<uint8_t>(serviceData[7])
) * 0.1f;
// Humidity (1 byte)
humidity = static_cast<uint8_t>(serviceData[8]);
// Battery mV (2 bytes, big-endian)
batteryMv = (static_cast<uint8_t>(serviceData[10]) << 8) | static_cast<uint8_t>(serviceData[11]);
// Battery level (1 byte)
batteryLevel = static_cast<uint8_t>(serviceData[9]);
} else if (serviceData.size() == 15) {
// custom pvvx format
// Temperature (2 bytes, little-endian)
temperature = (
(static_cast<uint8_t>(serviceData[7]) << 8) | static_cast<uint8_t>(serviceData[6])
) * 0.01f;
// Humidity (2 bytes, little-endian)
humidity = (
(static_cast<uint8_t>(serviceData[9]) << 8) | static_cast<uint8_t>(serviceData[8])
) * 0.01f;
// Battery mV (2 bytes, little-endian)
batteryMv = (static_cast<uint8_t>(serviceData[11]) << 8) | static_cast<uint8_t>(serviceData[10]);
// Battery level (1 byte)
batteryLevel = static_cast<uint8_t>(serviceData[12]);
} else {
// unknown format
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': unknown data format (size: %i)"),
sensorId, sSensor.name, serviceData.size()
);
return;
}
Log.straceln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s', received temp: %.2f; humidity: %.2f, battery voltage: %hu, battery level: %hhu"),
sensorId, sSensor.name,
temperature, humidity, batteryMv, batteryLevel
);
// update data
Sensors::setValueById(sensorId, temperature, Sensors::ValueType::TEMPERATURE, true, true);
Sensors::setValueById(sensorId, humidity, Sensors::ValueType::HUMIDITY, true, true);
Sensors::setValueById(sensorId, batteryLevel, Sensors::ValueType::BATTERY, true, true);
// update rssi
Sensors::setValueById(sensorId, deviceRssi, Sensors::ValueType::RSSI, false, false);
}
}; };
#endif #endif
@@ -55,6 +150,10 @@ public:
this->dallasSearchTime.reserve(2); this->dallasSearchTime.reserve(2);
this->dallasPolling.reserve(2); this->dallasPolling.reserve(2);
this->dallasLastPollingTime.reserve(2); this->dallasLastPollingTime.reserve(2);
#if USE_BLE
this->pBLEScanCallbacks = new BluetoothScanCallbacks();
#endif
} }
~SensorsTask() { ~SensorsTask() {
@@ -63,17 +162,17 @@ public:
this->dallasSearchTime.clear(); this->dallasSearchTime.clear();
this->dallasPolling.clear(); this->dallasPolling.clear();
this->dallasLastPollingTime.clear(); this->dallasLastPollingTime.clear();
#if USE_BLE
delete this->pBLEScanCallbacks;
#endif
} }
protected: protected:
const unsigned int wiredDisconnectTimeout = 180000u; const unsigned int disconnectedTimeout = 180000u;
const unsigned int wirelessDisconnectTimeout = 600000u; const unsigned short dallasSearchInterval = 60000u;
const unsigned short dallasSearchInterval = 60000; const unsigned short dallasPollingInterval = 10000u;
const unsigned short dallasPollingInterval = 10000; const unsigned short globalPollingInterval = 15000u;
const unsigned short globalPollingInterval = 15000;
#if USE_BLE
const unsigned int bleSetDtInterval = 7200000;
#endif
std::unordered_map<uint8_t, OneWire> owInstances; std::unordered_map<uint8_t, OneWire> owInstances;
std::unordered_map<uint8_t, DallasTemperature> dallasInstances; std::unordered_map<uint8_t, DallasTemperature> dallasInstances;
@@ -81,9 +180,9 @@ protected:
std::unordered_map<uint8_t, bool> dallasPolling; std::unordered_map<uint8_t, bool> dallasPolling;
std::unordered_map<uint8_t, unsigned long> dallasLastPollingTime; std::unordered_map<uint8_t, unsigned long> dallasLastPollingTime;
#if USE_BLE #if USE_BLE
std::unordered_map<uint8_t, NimBLEClient*> bleClients; NimBLEScan* pBLEScan = nullptr;
std::unordered_map<uint8_t, bool> bleSubscribed; BluetoothScanCallbacks* pBLEScanCallbacks = nullptr;
std::unordered_map<uint8_t, unsigned long> bleLastSetDtTime; bool activeScanBle = false;
#endif #endif
unsigned long globalLastPollingTime = 0; unsigned long globalLastPollingTime = 0;
@@ -92,6 +191,10 @@ protected:
return "Sensors"; return "Sensors";
} }
uint32_t getTaskStackSize() override {
return 7500;
}
BaseType_t getTaskCore() override { BaseType_t getTaskCore() override {
// https://github.com/h2zero/NimBLE-Arduino/issues/676 // https://github.com/h2zero/NimBLE-Arduino/issues/676
#if USE_BLE && defined(CONFIG_BT_NIMBLE_PINNED_TO_CORE) #if USE_BLE && defined(CONFIG_BT_NIMBLE_PINNED_TO_CORE)
@@ -132,8 +235,7 @@ protected:
this->yield(); this->yield();
#if USE_BLE #if USE_BLE
cleanBleInstances(); scanBleSensors();
pollingBleSensors();
this->yield(); this->yield();
#endif #endif
@@ -445,550 +547,72 @@ protected:
} }
#if USE_BLE #if USE_BLE
void cleanBleInstances() { void scanBleSensors() {
if (!NimBLEDevice::isInitialized()) {
return;
}
for (auto& [sensorId, pClient]: this->bleClients) {
if (pClient == nullptr) {
continue;
}
auto& sSensor = Sensors::settings[sensorId];
const auto sAddress = NimBLEAddress(sSensor.address, 0);
if (sAddress.isNull() || !sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', deleted unused client"),
sensorId, sSensor.name
);
NimBLEDevice::deleteClient(pClient);
pClient = nullptr;
}
}
}
void pollingBleSensors() {
if (!Sensors::getAmountByType(Sensors::Type::BLUETOOTH, true)) { if (!Sensors::getAmountByType(Sensors::Type::BLUETOOTH, true)) {
if (NimBLEDevice::isInitialized()) {
if (this->pBLEScan != nullptr) {
if (this->pBLEScan->isScanning()) {
this->pBLEScan->stop();
} else {
this->pBLEScan = nullptr;
}
}
if (this->pBLEScan == nullptr) {
if (NimBLEDevice::deinit(true)) {
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Deinitialized"));
} else {
Log.swarningln(FPSTR(L_SENSORS_BLE), F("Unable to deinitialize!"));
}
}
}
return; return;
} }
if (!NimBLEDevice::isInitialized() && millis() > 5000) { if (!NimBLEDevice::isInitialized() && millis() > 5000) {
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Initialized")); Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Initialized"));
BLEDevice::init(""); NimBLEDevice::init("");
NimBLEDevice::setPower(9);
#if defined(ESP_PWR_LVL_P20)
NimBLEDevice::setPower(ESP_PWR_LVL_P20);
#elif defined(ESP_PWR_LVL_P9)
NimBLEDevice::setPower(ESP_PWR_LVL_P9);
#endif
} }
for (uint8_t sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) { if (this->pBLEScan == nullptr) {
auto& sSensor = Sensors::settings[sensorId]; this->pBLEScan = NimBLEDevice::getScan();
auto& rSensor = Sensors::results[sensorId]; this->pBLEScan->setScanCallbacks(this->pBLEScanCallbacks);
#if MYNEWT_VAL(BLE_EXT_ADV)
this->pBLEScan->setPhy(NimBLEScan::Phy::SCAN_ALL);
#endif
this->pBLEScan->setDuplicateFilter(false);
this->pBLEScan->setMaxResults(0);
this->pBLEScan->setInterval(10000);
this->pBLEScan->setWindow(10000);
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) { Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Scanning initialized"));
continue;
} }
const auto address = NimBLEAddress(sSensor.address, 0); if (!this->pBLEScan->isScanning()) {
if (address.isNull()) { this->activeScanBle = !this->activeScanBle;
continue; this->pBLEScan->setActiveScan(this->activeScanBle);
}
auto pClient = this->getBleClient(sensorId); if (this->pBLEScan->start(30000, false, false)) {
if (pClient == nullptr) {
continue;
}
if (pClient->getPeerAddress() != address) {
if (pClient->isConnected()) {
if (!pClient->disconnect()) {
continue;
}
}
pClient->setPeerAddress(address);
}
if (!pClient->isConnected()) {
this->bleSubscribed[sensorId] = false;
this->bleLastSetDtTime[sensorId] = 0;
if (pClient->connect(false, true, true)) {
Log.sinfoln( Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': trying connecting to %s..."), FPSTR(L_SENSORS_BLE),
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str() F("%s scanning started"),
); this->activeScanBle ? "Active" : "Passive"
}
continue;
}
if (!this->bleSubscribed[sensorId]) {
if (this->subscribeToBleDevice(sensorId, pClient)) {
this->bleSubscribed[sensorId] = true;
} else {
this->bleSubscribed[sensorId] = false;
pClient->disconnect();
continue;
}
}
// Mark connected
Sensors::setConnectionStatusById(sensorId, true, true);
if (!this->bleLastSetDtTime[sensorId] || millis() - this->bleLastSetDtTime[sensorId] > this->bleSetDtInterval) {
struct tm ti;
if (getLocalTime(&ti)) {
if (this->setDateOnBleSensor(pClient, &ti)) {
Log.sinfoln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', successfully set date: %02d.%02d.%04d %02d:%02d:%02d"),
sensorId, sSensor.name,
ti.tm_mday, ti.tm_mon + 1, ti.tm_year + 1900, ti.tm_hour, ti.tm_min, ti.tm_sec
); );
} else { } else {
Log.swarningln( Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Unable to start scanning"));
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', failed set date: %02d.%02d.%04d %02d:%02d:%02d"),
sensorId, sSensor.name,
ti.tm_mday, ti.tm_mon + 1, ti.tm_year + 1900, ti.tm_hour, ti.tm_min, ti.tm_sec
);
}
this->bleLastSetDtTime[sensorId] = millis();
} }
} }
} }
}
NimBLEClient* getBleClient(const uint8_t sensorId) {
if (!NimBLEDevice::isInitialized()) {
return nullptr;
}
auto& sSensor = Sensors::settings[sensorId];
auto& rSensor = Sensors::results[sensorId];
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
return nullptr;
}
if (this->bleClients[sensorId] && this->bleClients[sensorId] != nullptr) {
return this->bleClients[sensorId];
}
auto pClient = NimBLEDevice::createClient();
if (pClient == nullptr) {
return nullptr;
}
//pClient->setConnectionParams(BLE_GAP_CONN_ITVL_MS(10), BLE_GAP_CONN_ITVL_MS(100), 10, 150);
pClient->setConnectTimeout(30000);
pClient->setSelfDelete(false, false);
pClient->setClientCallbacks(new BluetoothClientCallbacks(sensorId), true);
this->bleClients[sensorId] = pClient;
return pClient;
}
bool subscribeToBleDevice(const uint8_t sensorId, NimBLEClient* pClient) {
auto& sSensor = Sensors::settings[sensorId];
auto pAddress = pClient->getPeerAddress().toString();
NimBLERemoteService* pService = nullptr;
NimBLERemoteCharacteristic* pChar = nullptr;
// ENV Service (0x181A)
NimBLEUUID serviceUuid((uint16_t) 0x181AU);
pService = pClient->getService(serviceUuid);
if (!pService) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to find env service (%s) on device %s"),
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found env service (%s) on device %s"),
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
);
// 0x2A6E - Notify temperature x0.01C (pvvx)
bool tempNotifyCreated = false;
if (!tempNotifyCreated) {
NimBLEUUID charUuid((uint16_t) 0x2A6E);
pChar = pService->getCharacteristic(charUuid);
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found temp char (%s) in env service on device %s"),
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
);
pChar->unsubscribe();
tempNotifyCreated = pChar->subscribe(
pChar->canNotify(),
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
if (pChar == nullptr) {
return;
}
const NimBLERemoteService* pService = pChar->getRemoteService();
if (pService == nullptr) {
return;
}
NimBLEClient* pClient = pService->getClient();
if (pClient == nullptr) {
return;
}
auto& sSensor = Sensors::settings[sensorId];
if (length != 2) {
Log.swarningln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': invalid notification data at temp char (%s) on device %s"),
sensorId,
sSensor.name,
pChar->getUUID().toString().c_str(),
pClient->getPeerAddress().toString().c_str()
);
return;
}
float rawTemp = (pChar->getValue<int16_t>() * 0.01f);
Log.straceln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': received temp: %.2f"),
sensorId, sSensor.name, rawTemp
);
// set temp
Sensors::setValueById(sensorId, rawTemp, Sensors::ValueType::TEMPERATURE, true, true);
// update rssi
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
}
);
if (tempNotifyCreated) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to temp char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to temp char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
}
}
}
// 0x2A1F - Notify temperature x0.1C (atc1441/pvvx)
if (!tempNotifyCreated) {
NimBLEUUID charUuid((uint16_t) 0x2A1F);
pChar = pService->getCharacteristic(charUuid);
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found temp char (%s) in env service on device %s"),
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
);
pChar->unsubscribe();
tempNotifyCreated = pChar->subscribe(
pChar->canNotify(),
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
if (pChar == nullptr) {
return;
}
const NimBLERemoteService* pService = pChar->getRemoteService();
if (pService == nullptr) {
return;
}
NimBLEClient* pClient = pService->getClient();
if (pClient == nullptr) {
return;
}
auto& sSensor = Sensors::settings[sensorId];
if (length != 2) {
Log.swarningln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': invalid notification data at temp char (%s) on device %s"),
sensorId,
sSensor.name,
pChar->getUUID().toString().c_str(),
pClient->getPeerAddress().toString().c_str()
);
return;
}
float rawTemp = (pChar->getValue<int16_t>() * 0.1f);
Log.straceln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': received temp: %.2f"),
sensorId, sSensor.name, rawTemp
);
// set temp
Sensors::setValueById(sensorId, rawTemp, Sensors::ValueType::TEMPERATURE, true, true);
// update rssi
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
}
);
if (tempNotifyCreated) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to temp char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to temp char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
}
}
}
if (!tempNotifyCreated) {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported temp chars in env service on device %s"),
sensorId, sSensor.name, pAddress.c_str()
);
pClient->disconnect();
return false;
}
// 0x2A6F - Notify about humidity x0.01% (pvvx)
{
bool humidityNotifyCreated = false;
if (!humidityNotifyCreated) {
NimBLEUUID charUuid((uint16_t) 0x2A6F);
pChar = pService->getCharacteristic(charUuid);
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found humidity char (%s) in env service on device %s"),
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
);
pChar->unsubscribe();
humidityNotifyCreated = pChar->subscribe(
pChar->canNotify(),
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
if (pChar == nullptr) {
return;
}
const NimBLERemoteService* pService = pChar->getRemoteService();
if (pService == nullptr) {
return;
}
NimBLEClient* pClient = pService->getClient();
if (pClient == nullptr) {
return;
}
auto& sSensor = Sensors::settings[sensorId];
if (length != 2) {
Log.swarningln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': invalid notification data at humidity char (%s) on device %s"),
sensorId,
sSensor.name,
pChar->getUUID().toString().c_str(),
pClient->getPeerAddress().toString().c_str()
);
return;
}
float rawHumidity = (pChar->getValue<uint16_t>() * 0.01f);
Log.straceln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': received humidity: %.2f"),
sensorId, sSensor.name, rawHumidity
);
// set humidity
Sensors::setValueById(sensorId, rawHumidity, Sensors::ValueType::HUMIDITY, true, true);
// update rssi
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
}
);
if (humidityNotifyCreated) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to humidity char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to humidity char (%s) in env service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
}
}
}
if (!humidityNotifyCreated) {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported humidity chars in env service on device %s"),
sensorId, sSensor.name, pAddress.c_str()
);
}
}
}
// Battery Service (0x180F)
{
NimBLEUUID serviceUuid((uint16_t) 0x180F);
pService = pClient->getService(serviceUuid);
if (!pService) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to find battery service (%s) on device %s"),
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found battery service (%s) on device %s"),
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
);
// 0x2A19 - Notify the battery charge level 0..99% (pvvx)
bool batteryNotifyCreated = false;
if (!batteryNotifyCreated) {
NimBLEUUID charUuid((uint16_t) 0x2A19);
pChar = pService->getCharacteristic(charUuid);
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found battery char (%s) in battery service on device %s"),
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
);
pChar->unsubscribe();
batteryNotifyCreated = pChar->subscribe(
pChar->canNotify(),
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
if (pChar == nullptr) {
return;
}
const NimBLERemoteService* pService = pChar->getRemoteService();
if (pService == nullptr) {
return;
}
NimBLEClient* pClient = pService->getClient();
if (pClient == nullptr) {
return;
}
auto& sSensor = Sensors::settings[sensorId];
if (length != 1) {
Log.swarningln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': invalid notification data at battery char (%s) on device %s"),
sensorId,
sSensor.name,
pChar->getUUID().toString().c_str(),
pClient->getPeerAddress().toString().c_str()
);
return;
}
auto rawBattery = pChar->getValue<uint8_t>();
Log.straceln(
FPSTR(L_SENSORS_BLE),
F("Sensor #%hhu '%s': received battery: %hhu"),
sensorId, sSensor.name, rawBattery
);
// set battery
Sensors::setValueById(sensorId, rawBattery, Sensors::ValueType::BATTERY, true, true);
// update rssi
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
}
);
if (batteryNotifyCreated) {
Log.straceln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to battery char (%s) in battery service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
} else {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to battery char (%s) in battery service on device %s"),
sensorId, sSensor.name,
charUuid.toString().c_str(), pAddress.c_str()
);
}
}
}
if (!batteryNotifyCreated) {
Log.swarningln(
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported battery chars in battery service on device %s"),
sensorId, sSensor.name, pAddress.c_str()
);
}
}
}
return true;
}
bool setDateOnBleSensor(NimBLEClient* pClient, const struct tm *ptm) {
auto ts = mkgmtime(ptm);
uint8_t data[5] = {};
data[0] = 0x23;
data[1] = ts & 0xff;
data[2] = (ts >> 8) & 0xff;
data[3] = (ts >> 16) & 0xff;
data[4] = (ts >> 24) & 0xff;
return pClient->setValue(
NimBLEUUID((uint16_t) 0x1f10),
NimBLEUUID((uint16_t) 0x1f1f),
NimBLEAttValue(data, sizeof(data))
);
}
#endif #endif
void updateConnectionStatus() { void updateConnectionStatus() {
@@ -1005,16 +629,12 @@ protected:
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) { } else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
Sensors::setConnectionStatusById(sensorId, false, false); Sensors::setConnectionStatusById(sensorId, false, false);
} else if (rSensor.connected) { } else if (sSensor.type != Sensors::Type::MANUAL && rSensor.connected && (millis() - rSensor.activityTime) > this->disconnectedTimeout) {
if (sSensor.type == Sensors::Type::MANUAL || sSensor.type == Sensors::Type::BLUETOOTH) {
if ((millis() - rSensor.activityTime) > this->wirelessDisconnectTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false); Sensors::setConnectionStatusById(sensorId, false, false);
}
} else if ((millis() - rSensor.activityTime) > this->wiredDisconnectTimeout) { }/* else if (!rSensor.connected) {
Sensors::setConnectionStatusById(sensorId, false, false); rSensor.connected = true;
} }*/
}
} }
} }
+6 -34
View File
@@ -1,5 +1,3 @@
// NetworkSettings struct is append-only. The file is persisted across updates,
// and removing/modifying existing keys will lead to file corruption.
struct NetworkSettings { struct NetworkSettings {
char hostname[25] = DEFAULT_HOSTNAME; char hostname[25] = DEFAULT_HOSTNAME;
bool useDhcp = true; bool useDhcp = true;
@@ -22,22 +20,6 @@ struct NetworkSettings {
char password[65] = DEFAULT_STA_PASSWORD; char password[65] = DEFAULT_STA_PASSWORD;
uint8_t channel = 0; uint8_t channel = 0;
} sta; } 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; } networkSettings;
struct Settings { struct Settings {
@@ -96,8 +78,7 @@ struct Settings {
bool autoFaultReset = false; bool autoFaultReset = false;
bool autoDiagReset = false; bool autoDiagReset = false;
bool setDateAndTime = false; bool setDateAndTime = false;
bool alwaysSendIndoorTemp = true; bool nativeHeatingControl = false;
bool nativeOTC = false;
bool immergasFix = false; bool immergasFix = false;
} options; } options;
} opentherm; } opentherm;
@@ -122,25 +103,20 @@ struct Settings {
bool enabled = true; bool enabled = true;
bool turbo = false; bool turbo = false;
float target = DEFAULT_HEATING_TARGET_TEMP; float target = DEFAULT_HEATING_TARGET_TEMP;
float hysteresis = 0.5f;
float turboFactor = 7.5f; float turboFactor = 7.5f;
uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP; uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP;
uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP; uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP;
uint8_t maxModulation = 100; uint8_t maxModulation = 100;
struct {
bool enabled = true;
float value = 0.5f;
HysteresisAction action = HysteresisAction::DISABLE_HEATING;
} hysteresis;
struct { struct {
uint8_t highTemp = 95; uint8_t highTemp = 95;
uint8_t lowTemp = 90; uint8_t lowTemp = 90;
} overheatProtection; } overheatProtection;
struct { struct {
uint8_t highTemp = 15;
uint8_t lowTemp = 10; uint8_t lowTemp = 10;
unsigned short thresholdTime = 600;
} freezeProtection; } freezeProtection;
} heating; } heating;
@@ -178,10 +154,9 @@ struct Settings {
struct { struct {
bool enabled = false; bool enabled = false;
float slope = 0.7f; float n_factor = 0.7f;
float exponent = 1.3f; float k_factor = 3.0f;
float shift = 0.0f; float t_factor = 2.0f;
float targetDiffFactor = 2.0f;
} equitherm; } equitherm;
struct { struct {
@@ -290,7 +265,6 @@ struct Variables {
struct { struct {
bool connected = false; bool connected = false;
int8_t rssi = 0; int8_t rssi = 0;
NetworkUtils::NetworkMgr::Uplink connectionType = NetworkUtils::NetworkMgr::Uplink::None;
} network; } network;
struct { struct {
@@ -323,7 +297,6 @@ struct Variables {
bool enabled = false; bool enabled = false;
bool indoorTempControl = false; bool indoorTempControl = false;
bool overheat = false; bool overheat = false;
bool freezing = false;
float setpointTemp = 0.0f; float setpointTemp = 0.0f;
float targetTemp = 0.0f; float targetTemp = 0.0f;
float currentTemp = 0.0f; float currentTemp = 0.0f;
@@ -409,7 +382,6 @@ struct Variables {
uint16_t dhwBurnerStarts = 0; uint16_t dhwBurnerStarts = 0;
uint16_t heatingPumpStarts = 0; uint16_t heatingPumpStarts = 0;
uint16_t dhwPumpStarts = 0; uint16_t dhwPumpStarts = 0;
uint16_t coolingHours = 0;
uint16_t burnerHours = 0; uint16_t burnerHours = 0;
uint16_t dhwBurnerHours = 0; uint16_t dhwBurnerHours = 0;
uint16_t heatingPumpHours = 0; uint16_t heatingPumpHours = 0;
-43
View File
@@ -54,11 +54,6 @@
#define USE_BLE false #define USE_BLE false
#endif #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 #ifndef DEFAULT_HOSTNAME
#define DEFAULT_HOSTNAME "" #define DEFAULT_HOSTNAME ""
#endif #endif
@@ -87,34 +82,6 @@
#define DEFAULT_STATUS_LED_GPIO GPIO_IS_NOT_CONFIGURED #define DEFAULT_STATUS_LED_GPIO GPIO_IS_NOT_CONFIGURED
#endif #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 #ifndef DEFAULT_PORTAL_LOGIN
#define DEFAULT_PORTAL_LOGIN "" #define DEFAULT_PORTAL_LOGIN ""
#endif #endif
@@ -196,14 +163,4 @@ enum class UnitSystem : uint8_t {
IMPERIAL = 1 IMPERIAL = 1
}; };
enum class HysteresisAction : uint8_t {
DISABLE_HEATING = 0,
SET_ZERO_TARGET = 1
};
enum class EthernetImplementation : uint8_t {
NONE = 0,
W5500 = 1
};
char buffer[255]; char buffer[255];
+1 -19
View File
@@ -1,6 +1,3 @@
#define ARDUINOJSON_USE_DOUBLE 0
#define ARDUINOJSON_USE_LONG_LONG 0
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <FileData.h> #include <FileData.h>
@@ -84,9 +81,6 @@ void setup() {
// //
// Network settings // 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()) { switch (fsNetworkSettings.read()) {
case FD_FS_ERR: case FD_FS_ERR:
Log.swarningln(FPSTR(L_NETWORK_SETTINGS), F("Filesystem error, load default")); Log.swarningln(FPSTR(L_NETWORK_SETTINGS), F("Filesystem error, load default"));
@@ -157,18 +151,6 @@ void setup() {
break; 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 // generate mqtt prefix if it is empty
if (!strlen(settings.mqtt.prefix)) { if (!strlen(settings.mqtt.prefix)) {
strcpy(settings.mqtt.prefix, getChipId("otgateway_").c_str()); strcpy(settings.mqtt.prefix, getChipId("otgateway_").c_str());
@@ -231,7 +213,7 @@ void setup() {
tRegulator = new RegulatorTask(true, 10000); tRegulator = new RegulatorTask(true, 10000);
Scheduler.start(tRegulator); Scheduler.start(tRegulator);
tPortal = new PortalTask(true, 0); tPortal = new PortalTask(true, 10);
Scheduler.start(tPortal); Scheduler.start(tPortal);
tMain = new MainTask(true, 100); tMain = new MainTask(true, 100);
+5 -21
View File
@@ -34,7 +34,6 @@ const char L_CASCADE_OUTPUT[] PROGMEM = "CASCADE.OUTPUT";
const char L_EXTPUMP[] PROGMEM = "EXTPUMP"; const char L_EXTPUMP[] PROGMEM = "EXTPUMP";
const char S_ACTION[] PROGMEM = "action";
const char S_ACTIONS[] PROGMEM = "actions"; const char S_ACTIONS[] PROGMEM = "actions";
const char S_ACTIVE[] PROGMEM = "active"; const char S_ACTIVE[] PROGMEM = "active";
const char S_ADDRESS[] PROGMEM = "address"; const char S_ADDRESS[] PROGMEM = "address";
@@ -48,7 +47,6 @@ const char S_AUTO_FAULT_RESET[] PROGMEM = "autoFaultReset";
const char S_BACKTRACE[] PROGMEM = "backtrace"; const char S_BACKTRACE[] PROGMEM = "backtrace";
const char S_BATTERY[] PROGMEM = "battery"; const char S_BATTERY[] PROGMEM = "battery";
const char S_BAUDRATE[] PROGMEM = "baudrate"; const char S_BAUDRATE[] PROGMEM = "baudrate";
const char S_BLE[] PROGMEM = "ble";
const char S_BLOCKING[] PROGMEM = "blocking"; const char S_BLOCKING[] PROGMEM = "blocking";
const char S_BSSID[] PROGMEM = "bssid"; const char S_BSSID[] PROGMEM = "bssid";
const char S_BUILD[] PROGMEM = "build"; const char S_BUILD[] PROGMEM = "build";
@@ -56,18 +54,14 @@ const char S_CASCADE_CONTROL[] PROGMEM = "cascadeControl";
const char S_CHANNEL[] PROGMEM = "channel"; const char S_CHANNEL[] PROGMEM = "channel";
const char S_CH2_ALWAYS_ENABLED[] PROGMEM = "ch2AlwaysEnabled"; const char S_CH2_ALWAYS_ENABLED[] PROGMEM = "ch2AlwaysEnabled";
const char S_CHIP[] PROGMEM = "chip"; const char S_CHIP[] PROGMEM = "chip";
const char S_CLK[] PROGMEM = "clk";
const char S_CODE[] PROGMEM = "code"; const char S_CODE[] PROGMEM = "code";
const char S_CONNECTED[] PROGMEM = "connected"; 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_CONTINUES[] PROGMEM = "continues";
const char S_COOLING[] PROGMEM = "cooling"; const char S_COOLING[] PROGMEM = "cooling";
const char S_COOLING_SUPPORT[] PROGMEM = "coolingSupport"; const char S_COOLING_SUPPORT[] PROGMEM = "coolingSupport";
const char S_CORE[] PROGMEM = "core"; const char S_CORE[] PROGMEM = "core";
const char S_CORES[] PROGMEM = "cores"; const char S_CORES[] PROGMEM = "cores";
const char S_CRASH[] PROGMEM = "crash"; const char S_CRASH[] PROGMEM = "crash";
const char S_CS[] PROGMEM = "cs";
const char S_CURRENT_TEMP[] PROGMEM = "currentTemp"; const char S_CURRENT_TEMP[] PROGMEM = "currentTemp";
const char S_DATA[] PROGMEM = "data"; const char S_DATA[] PROGMEM = "data";
const char S_DATE[] PROGMEM = "date"; const char S_DATE[] PROGMEM = "date";
@@ -87,14 +81,10 @@ const char S_ENABLED[] PROGMEM = "enabled";
const char S_ENV[] PROGMEM = "env"; const char S_ENV[] PROGMEM = "env";
const char S_EPC[] PROGMEM = "epc"; const char S_EPC[] PROGMEM = "epc";
const char S_EQUITHERM[] PROGMEM = "equitherm"; 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_EXTERNAL_PUMP[] PROGMEM = "externalPump";
const char S_FACTOR[] PROGMEM = "factor"; const char S_FACTOR[] PROGMEM = "factor";
const char S_FAULT[] PROGMEM = "fault"; const char S_FAULT[] PROGMEM = "fault";
const char S_FEATURES[] PROGMEM = "features";
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection"; const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
const char S_FREEZING[] PROGMEM = "freezing";
const char S_FILTERING[] PROGMEM = "filtering"; const char S_FILTERING[] PROGMEM = "filtering";
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor"; const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
const char S_FLAGS[] PROGMEM = "flags"; const char S_FLAGS[] PROGMEM = "flags";
@@ -118,7 +108,6 @@ const char S_HYSTERESIS[] PROGMEM = "hysteresis";
const char S_ID[] PROGMEM = "id"; const char S_ID[] PROGMEM = "id";
const char S_IGNORE_DIAG_STATE[] PROGMEM = "ignoreDiagState"; const char S_IGNORE_DIAG_STATE[] PROGMEM = "ignoreDiagState";
const char S_IMMERGAS_FIX[] PROGMEM = "immergasFix"; 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[] PROGMEM = "indoorTemp";
const char S_INDOOR_TEMP_CONTROL[] PROGMEM = "indoorTempControl"; const char S_INDOOR_TEMP_CONTROL[] PROGMEM = "indoorTempControl";
const char S_IN_GPIO[] PROGMEM = "inGpio"; const char S_IN_GPIO[] PROGMEM = "inGpio";
@@ -126,9 +115,9 @@ const char S_INPUT[] PROGMEM = "input";
const char S_INTERVAL[] PROGMEM = "interval"; const char S_INTERVAL[] PROGMEM = "interval";
const char S_INVERT_STATE[] PROGMEM = "invertState"; const char S_INVERT_STATE[] PROGMEM = "invertState";
const char S_IP[] PROGMEM = "ip"; const char S_IP[] PROGMEM = "ip";
const char S_IRQ[] PROGMEM = "irq";
const char S_I_FACTOR[] PROGMEM = "i_factor"; const char S_I_FACTOR[] PROGMEM = "i_factor";
const char S_I_MULTIPLIER[] PROGMEM = "i_multiplier"; 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_LOGIN[] PROGMEM = "login";
const char S_LOG_LEVEL[] PROGMEM = "logLevel"; const char S_LOG_LEVEL[] PROGMEM = "logLevel";
const char S_LOW_TEMP[] PROGMEM = "lowTemp"; const char S_LOW_TEMP[] PROGMEM = "lowTemp";
@@ -147,15 +136,14 @@ const char S_MIN_FREE[] PROGMEM = "minFree";
const char S_MIN_MAX_FREE_BLOCK[] PROGMEM = "minMaxFreeBlock"; const char S_MIN_MAX_FREE_BLOCK[] PROGMEM = "minMaxFreeBlock";
const char S_MIN_POWER[] PROGMEM = "minPower"; const char S_MIN_POWER[] PROGMEM = "minPower";
const char S_MIN_TEMP[] PROGMEM = "minTemp"; const char S_MIN_TEMP[] PROGMEM = "minTemp";
const char S_MISO[] PROGMEM = "miso";
const char S_MODEL[] PROGMEM = "model"; const char S_MODEL[] PROGMEM = "model";
const char S_MOSI[] PROGMEM = "mosi";
const char S_MODULATION[] PROGMEM = "modulation"; const char S_MODULATION[] PROGMEM = "modulation";
const char S_MQTT[] PROGMEM = "mqtt"; const char S_MQTT[] PROGMEM = "mqtt";
const char S_NAME[] PROGMEM = "name"; 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_NETWORK[] PROGMEM = "network";
const char S_NTP[] PROGMEM = "ntp"; const char S_NTP[] PROGMEM = "ntp";
const char S_N_FACTOR[] PROGMEM = "n_factor";
const char S_OFFSET[] PROGMEM = "offset"; const char S_OFFSET[] PROGMEM = "offset";
const char S_ON_ENABLED_HEATING[] PROGMEM = "onEnabledHeating"; const char S_ON_ENABLED_HEATING[] PROGMEM = "onEnabledHeating";
const char S_ON_FAULT[] PROGMEM = "onFault"; const char S_ON_FAULT[] PROGMEM = "onFault";
@@ -170,13 +158,13 @@ const char S_OVERHEAT_PROTECTION[] PROGMEM = "overheatProtectio
const char S_PASSWORD[] PROGMEM = "password"; const char S_PASSWORD[] PROGMEM = "password";
const char S_PID[] PROGMEM = "pid"; const char S_PID[] PROGMEM = "pid";
const char S_PORT[] PROGMEM = "port"; const char S_PORT[] PROGMEM = "port";
const char S_PINS[] PROGMEM = "pins";
const char S_PORTAL[] PROGMEM = "portal"; const char S_PORTAL[] PROGMEM = "portal";
const char S_POST_CIRCULATION_TIME[] PROGMEM = "postCirculationTime"; const char S_POST_CIRCULATION_TIME[] PROGMEM = "postCirculationTime";
const char S_POWER[] PROGMEM = "power"; const char S_POWER[] PROGMEM = "power";
const char S_PREFIX[] PROGMEM = "prefix"; const char S_PREFIX[] PROGMEM = "prefix";
const char S_PROTOCOL_VERSION[] PROGMEM = "protocolVersion"; const char S_PROTOCOL_VERSION[] PROGMEM = "protocolVersion";
const char S_PURPOSE[] PROGMEM = "purpose"; const char S_PURPOSE[] PROGMEM = "purpose";
const char S_PSRAM[] PROGMEM = "psram";
const char S_P_FACTOR[] PROGMEM = "p_factor"; const char S_P_FACTOR[] PROGMEM = "p_factor";
const char S_P_MULTIPLIER[] PROGMEM = "p_multiplier"; const char S_P_MULTIPLIER[] PROGMEM = "p_multiplier";
const char S_REAL_SIZE[] PROGMEM = "realSize"; const char S_REAL_SIZE[] PROGMEM = "realSize";
@@ -188,7 +176,6 @@ const char S_RESTART[] PROGMEM = "restart";
const char S_RETURN_TEMP[] PROGMEM = "returnTemp"; const char S_RETURN_TEMP[] PROGMEM = "returnTemp";
const char S_REV[] PROGMEM = "rev"; const char S_REV[] PROGMEM = "rev";
const char S_RSSI[] PROGMEM = "rssi"; const char S_RSSI[] PROGMEM = "rssi";
const char S_RST[] PROGMEM = "rst";
const char S_RX_LED_GPIO[] PROGMEM = "rxLedGpio"; const char S_RX_LED_GPIO[] PROGMEM = "rxLedGpio";
const char S_SDK[] PROGMEM = "sdk"; const char S_SDK[] PROGMEM = "sdk";
const char S_SENSORS[] PROGMEM = "sensors"; 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_SERVER[] PROGMEM = "server";
const char S_SETTINGS[] PROGMEM = "settings"; const char S_SETTINGS[] PROGMEM = "settings";
const char S_SET_DATE_AND_TIME[] PROGMEM = "setDateAndTime"; 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_SIGNAL_QUALITY[] PROGMEM = "signalQuality";
const char S_SIZE[] PROGMEM = "size"; const char S_SIZE[] PROGMEM = "size";
const char S_SLAVE[] PROGMEM = "slave"; const char S_SLAVE[] PROGMEM = "slave";
const char S_SLOPE[] PROGMEM = "slope";
const char S_SSID[] PROGMEM = "ssid"; const char S_SSID[] PROGMEM = "ssid";
const char S_STARTED[] PROGMEM = "started";
const char S_STA[] PROGMEM = "sta"; const char S_STA[] PROGMEM = "sta";
const char S_STATE[] PROGMEM = "state"; const char S_STATE[] PROGMEM = "state";
const char S_STATIC_CONFIG[] PROGMEM = "staticConfig"; 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_SUMMER_WINTER_MODE[] PROGMEM = "summerWinterMode";
const char S_SYSTEM[] PROGMEM = "system"; const char S_SYSTEM[] PROGMEM = "system";
const char S_TARGET[] PROGMEM = "target"; const char S_TARGET[] PROGMEM = "target";
const char S_TARGET_DIFF_FACTOR[] PROGMEM = "targetDiffFactor";
const char S_TARGET_TEMP[] PROGMEM = "targetTemp"; const char S_TARGET_TEMP[] PROGMEM = "targetTemp";
const char S_TELNET[] PROGMEM = "telnet"; const char S_TELNET[] PROGMEM = "telnet";
const char S_TEMPERATURE[] PROGMEM = "temperature"; 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[] PROGMEM = "turbo";
const char S_TURBO_FACTOR[] PROGMEM = "turboFactor"; const char S_TURBO_FACTOR[] PROGMEM = "turboFactor";
const char S_TYPE[] PROGMEM = "type"; const char S_TYPE[] PROGMEM = "type";
const char S_T_FACTOR[] PROGMEM = "t_factor";
const char S_UNIT_SYSTEM[] PROGMEM = "unitSystem"; const char S_UNIT_SYSTEM[] PROGMEM = "unitSystem";
const char S_UPTIME[] PROGMEM = "uptime"; const char S_UPTIME[] PROGMEM = "uptime";
const char S_USE[] PROGMEM = "use"; const char S_USE[] PROGMEM = "use";
+52 -180
View File
@@ -296,24 +296,8 @@ void networkSettingsToJson(const NetworkSettings& src, JsonVariant dst) {
dst[FPSTR(S_STA)][FPSTR(S_SSID)] = src.sta.ssid; dst[FPSTR(S_STA)][FPSTR(S_SSID)] = src.sta.ssid;
dst[FPSTR(S_STA)][FPSTR(S_PASSWORD)] = src.sta.password; dst[FPSTR(S_STA)][FPSTR(S_PASSWORD)] = src.sta.password;
dst[FPSTR(S_STA)][FPSTR(S_CHANNEL)] = src.sta.channel; 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 jsonToNetworkSettings(const JsonVariantConst src, NetworkSettings& dst) {
bool changed = false; 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; 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_FAULT_RESET)] = src.opentherm.options.autoFaultReset;
otOptions[FPSTR(S_AUTO_DIAG_RESET)] = src.opentherm.options.autoDiagReset; otOptions[FPSTR(S_AUTO_DIAG_RESET)] = src.opentherm.options.autoDiagReset;
otOptions[FPSTR(S_SET_DATE_AND_TIME)] = src.opentherm.options.setDateAndTime; 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_HEATING_CONTROL)] = src.opentherm.options.nativeHeatingControl;
otOptions[FPSTR(S_NATIVE_OTC)] = src.opentherm.options.nativeOTC;
otOptions[FPSTR(S_IMMERGAS_FIX)] = src.opentherm.options.immergasFix; otOptions[FPSTR(S_IMMERGAS_FIX)] = src.opentherm.options.immergasFix;
auto mqtt = dst[FPSTR(S_MQTT)].to<JsonObject>(); auto mqtt = dst[FPSTR(S_MQTT)].to<JsonObject>();
mqtt[FPSTR(S_ENABLED)] = src.mqtt.enabled; mqtt[FPSTR(S_ENABLED)] = src.mqtt.enabled;
mqtt[FPSTR(S_SERVER)] = src.mqtt.server; mqtt[FPSTR(S_SERVER)] = src.mqtt.server;
@@ -521,9 +490,7 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
heating[FPSTR(S_ENABLED)] = src.heating.enabled; heating[FPSTR(S_ENABLED)] = src.heating.enabled;
heating[FPSTR(S_TURBO)] = src.heating.turbo; heating[FPSTR(S_TURBO)] = src.heating.turbo;
heating[FPSTR(S_TARGET)] = roundf(src.heating.target, 2); heating[FPSTR(S_TARGET)] = roundf(src.heating.target, 2);
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)] = src.heating.hysteresis.enabled; heating[FPSTR(S_HYSTERESIS)] = roundf(src.heating.hysteresis, 3);
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)] = roundf(src.heating.hysteresis.value, 3);
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)] = static_cast<uint8_t>(src.heating.hysteresis.action);
heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3); heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3);
heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp; heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp;
heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp; heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp;
@@ -534,8 +501,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp; heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp;
auto freezeProtection = heating[FPSTR(S_FREEZE_PROTECTION)].to<JsonObject>(); 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_LOW_TEMP)] = src.heating.freezeProtection.lowTemp;
freezeProtection[FPSTR(S_THRESHOLD_TIME)] = src.heating.freezeProtection.thresholdTime;
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>(); auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled; dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
@@ -550,10 +517,9 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
auto equitherm = dst[FPSTR(S_EQUITHERM)].to<JsonObject>(); auto equitherm = dst[FPSTR(S_EQUITHERM)].to<JsonObject>();
equitherm[FPSTR(S_ENABLED)] = src.equitherm.enabled; equitherm[FPSTR(S_ENABLED)] = src.equitherm.enabled;
equitherm[FPSTR(S_SLOPE)] = roundf(src.equitherm.slope, 3); equitherm[FPSTR(S_N_FACTOR)] = roundf(src.equitherm.n_factor, 3);
equitherm[FPSTR(S_EXPONENT)] = roundf(src.equitherm.exponent, 3); equitherm[FPSTR(S_K_FACTOR)] = roundf(src.equitherm.k_factor, 3);
equitherm[FPSTR(S_SHIFT)] = roundf(src.equitherm.shift, 2); equitherm[FPSTR(S_T_FACTOR)] = roundf(src.equitherm.t_factor, 3);
equitherm[FPSTR(S_TARGET_DIFF_FACTOR)] = roundf(src.equitherm.targetDiffFactor, 3);
auto pid = dst[FPSTR(S_PID)].to<JsonObject>(); auto pid = dst[FPSTR(S_PID)].to<JsonObject>();
pid[FPSTR(S_ENABLED)] = src.pid.enabled; pid[FPSTR(S_ENABLED)] = src.pid.enabled;
@@ -602,55 +568,6 @@ inline void safeSettingsToJson(const Settings& src, JsonVariant dst) {
settingsToJson(src, dst, true); 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 jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false) {
bool changed = false; bool changed = false;
@@ -775,6 +692,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
} }
} }
// portal // portal
if (src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].is<bool>()) { if (src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].is<bool>()) {
bool value = src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].as<bool>(); bool value = src[FPSTR(S_PORTAL)][FPSTR(S_AUTH)].as<bool>();
@@ -1082,20 +1000,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>()) { 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_ALWAYS_SEND_INDOOR_TEMP)].as<bool>(); bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_HEATING_CONTROL)].as<bool>();
if (value != dst.opentherm.options.alwaysSendIndoorTemp) { if (value != dst.opentherm.options.nativeHeatingControl) {
dst.opentherm.options.alwaysSendIndoorTemp = value; dst.opentherm.options.nativeHeatingControl = 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) { if (value) {
dst.equitherm.enabled = false; dst.equitherm.enabled = false;
@@ -1115,6 +1024,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
} }
} }
// mqtt // mqtt
if (src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].is<bool>()) { if (src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].as<bool>(); bool value = src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].as<bool>();
@@ -1205,7 +1115,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].is<bool>()) { if (src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].as<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) { if (value != dst.equitherm.enabled) {
dst.equitherm.enabled = value; dst.equitherm.enabled = value;
changed = true; changed = true;
@@ -1217,38 +1127,29 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
} }
} }
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_SLOPE)].isNull()) { if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_N_FACTOR)].isNull()) {
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_SLOPE)].as<float>(); 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) { if (value > 0 && value <= 10 && fabsf(value - dst.equitherm.n_factor) > 0.0001f) {
dst.equitherm.slope = roundf(value, 3); dst.equitherm.n_factor = roundf(value, 3);
changed = true; changed = true;
} }
} }
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_EXPONENT)].isNull()) { if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_K_FACTOR)].isNull()) {
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_EXPONENT)].as<float>(); 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) { if (value >= 0 && value <= 10 && fabsf(value - dst.equitherm.k_factor) > 0.0001f) {
dst.equitherm.exponent = roundf(value, 3); dst.equitherm.k_factor = roundf(value, 3);
changed = true; changed = true;
} }
} }
if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_SHIFT)].isNull()) { if (!src[FPSTR(S_EQUITHERM)][FPSTR(S_T_FACTOR)].isNull()) {
float value = src[FPSTR(S_EQUITHERM)][FPSTR(S_SHIFT)].as<float>(); 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) { if (value >= 0 && value <= 10 && fabsf(value - dst.equitherm.t_factor) > 0.0001f) {
dst.equitherm.shift = roundf(value, 2); dst.equitherm.t_factor = roundf(value, 3);
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);
changed = true; changed = true;
} }
} }
@@ -1258,7 +1159,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (src[FPSTR(S_PID)][FPSTR(S_ENABLED)].is<bool>()) { if (src[FPSTR(S_PID)][FPSTR(S_ENABLED)].is<bool>()) {
bool value = src[FPSTR(S_PID)][FPSTR(S_ENABLED)].as<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) { if (value != dst.pid.enabled) {
dst.pid.enabled = value; dst.pid.enabled = value;
changed = true; changed = true;
@@ -1403,41 +1304,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
} }
} }
if (src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].is<bool>()) { if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].isNull()) {
bool value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].as<bool>(); float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].as<float>();
if (value != dst.heating.hysteresis.enabled) { if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis) > 0.0001f) {
dst.heating.hysteresis.enabled = value; dst.heating.hysteresis = roundf(value, 2);
changed = true; changed = true;
} }
} }
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].isNull()) {
float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].as<float>();
if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis.value) > 0.0001f) {
dst.heating.hysteresis.value = roundf(value, 2);
changed = true;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].isNull()) {
uint8_t value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].as<uint8_t>();
switch (value) {
case static_cast<uint8_t>(HysteresisAction::DISABLE_HEATING):
case static_cast<uint8_t>(HysteresisAction::SET_ZERO_TARGET):
if (static_cast<uint8_t>(dst.heating.hysteresis.action) != value) {
dst.heating.hysteresis.action = static_cast<HysteresisAction>(value);
changed = true;
}
break;
default:
break;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].isNull()) { if (!src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].isNull()) {
float value = src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].as<float>(); float value = src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].as<float>();
@@ -1503,15 +1378,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
changed = true; 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()) { 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>(); unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].as<uint8_t>();
@@ -1521,10 +1387,16 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
} }
} }
if (dst.heating.freezeProtection.highTemp < dst.heating.freezeProtection.lowTemp) { if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].isNull()) {
dst.heating.freezeProtection.highTemp = dst.heating.freezeProtection.lowTemp; 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; changed = true;
} }
}
}
// dhw // dhw
@@ -1794,7 +1666,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
// force check emergency target // 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; 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( bool valid = isValidTemp(
value, value,
dst.system.unitSystem, dst.system.unitSystem,
@@ -1819,7 +1691,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
// force check heating target // 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 minTemp = indoorTempControl ? THERMOSTAT_INDOOR_MIN_TEMP : dst.heating.minTemp;
float maxTemp = indoorTempControl ? THERMOSTAT_INDOOR_MAX_TEMP : dst.heating.maxTemp; float maxTemp = indoorTempControl ? THERMOSTAT_INDOOR_MAX_TEMP : dst.heating.maxTemp;
@@ -2012,7 +1884,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_DHW_BURNER_HOURS):
case static_cast<uint8_t>(Sensors::Type::OT_HEATING_PUMP_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_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::NTC_10K_TEMP):
case static_cast<uint8_t>(Sensors::Type::DALLAS_TEMP): case static_cast<uint8_t>(Sensors::Type::DALLAS_TEMP):
@@ -2189,18 +2060,21 @@ bool jsonToSensorResult(const uint8_t sensorId, const JsonVariantConst src) {
return false; return false;
} }
auto& dst = Sensors::results[sensorId];
bool changed = false;
// value // value
if (!src[FPSTR(S_VALUE)].isNull()) { if (!src[FPSTR(S_VALUE)].isNull()) {
return Sensors::setValueById( float value = src[FPSTR(S_VALUE)].as<float>();
sensorId,
src[FPSTR(S_VALUE)].as<float>(), uint8_t vType = static_cast<uint8_t>(Sensors::ValueType::PRIMARY);
Sensors::ValueType::PRIMARY, if (fabsf(value - dst.values[vType]) > 0.0001f) {
true, dst.values[vType] = roundf(value, 2);
true changed = true;
); }
} }
return false; return changed;
} }
void varsToJson(const Variables& src, JsonVariant dst) { void varsToJson(const Variables& src, JsonVariant dst) {
@@ -2209,7 +2083,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
slave[FPSTR(S_FLAGS)] = src.slave.flags; slave[FPSTR(S_FLAGS)] = src.slave.flags;
slave[FPSTR(S_TYPE)] = src.slave.type; slave[FPSTR(S_TYPE)] = src.slave.type;
slave[FPSTR(S_APP_VERSION)] = src.slave.appVersion; 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_CONNECTED)] = src.slave.connected;
slave[FPSTR(S_FLAME)] = src.slave.flame; slave[FPSTR(S_FLAME)] = src.slave.flame;
@@ -2250,7 +2124,6 @@ void varsToJson(const Variables& src, JsonVariant dst) {
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking; mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl; mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat; 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_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2);
mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2); mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2); mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);
@@ -2271,7 +2144,6 @@ void varsToJson(const Variables& src, JsonVariant dst) {
master[FPSTR(S_NETWORK)][FPSTR(S_CONNECTED)] = src.network.connected; 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_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_MQTT)][FPSTR(S_CONNECTED)] = src.mqtt.connected;
master[FPSTR(S_EMERGENCY)][FPSTR(S_STATE)] = src.emergency.state; master[FPSTR(S_EMERGENCY)][FPSTR(S_STATE)] = src.emergency.state;
master[FPSTR(S_EXTERNAL_PUMP)][FPSTR(S_STATE)] = src.externalPump.state; master[FPSTR(S_EXTERNAL_PUMP)][FPSTR(S_STATE)] = src.externalPump.state;
+15 -68
View File
@@ -151,7 +151,6 @@
"section": { "section": {
"static": "静态设置", "static": "静态设置",
"ethernet": "以太网",
"availableNetworks": "可用网络", "availableNetworks": "可用网络",
"staSettings": "WiFi 设置", "staSettings": "WiFi 设置",
"apSettings": "AP 设置" "apSettings": "AP 设置"
@@ -159,20 +158,7 @@
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "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 接线"
}, },
"wifi": { "wifi": {
@@ -190,14 +176,7 @@
"ip": "IP", "ip": "IP",
"subnet": "子网掩码", "subnet": "子网掩码",
"gateway": "网关", "gateway": "网关",
"dns": "DNS 服务器", "dns": "DNS 服务器"
"connection": "连接",
"connectionType": {
"ethernet": "以太网",
"wifi": "WiFi",
"wifi-ap": "WiFi 接入点",
"none": "无"
}
}, },
"sta": { "sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)", "otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)", "otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)", "otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
"otCoolingHours": "OpenTherm, number of cooling hours",
"ntcTemp": "NTC 传感器", "ntcTemp": "NTC 传感器",
"dallasTemp": "DALLAS 传感器", "dallasTemp": "DALLAS 传感器",
@@ -341,15 +319,9 @@
}, },
"freezeProtection": { "freezeProtection": {
"title": "防冻保护", "title": "防冻保护",
"desc": "如果热载体或室内温度低于 <b>低温</b>,加热将被强制开启。", "desc": "当热媒或室内温度在<b>等待时间</b> 内降至<b>低温阈值</b>以下时,系统将强制启动加热功能。",
"highTemp": { "lowTemp": "低温阈值",
"title": "高温阈值", "thresholdTime": "等待时间<small>(秒)</small>"
"note": "防冻保护激活后系统恢复正常模式的阈值"
},
"lowTemp": {
"title": "低温阈值",
"note": "强制开启加热的阈值"
}
}, },
"portal": { "portal": {
@@ -384,16 +356,7 @@
}, },
"heating": { "heating": {
"hyst": { "hyst": "滞后值<small>(单位:度)</small>",
"title": "滞回",
"desc": "滞回有助于维持设定的室内温度(在使用«Equitherm»和/或«PID»时)。强制禁用加热当<code>current indoor > target + value</code>,启用加热当<code>current indoor < (target - value)</code>。",
"value": "值 <small>(以度为单位)</small>",
"action": {
"title": "行动",
"disableHeating": "禁用加热",
"set0target": "设置空目标"
}
},
"turboFactor": "Turbo 模式系数" "turboFactor": "Turbo 模式系数"
}, },
@@ -408,26 +371,11 @@
}, },
"equitherm": { "equitherm": {
"slope": { "n": "N 系数",
"title": "斜率", "k": "K 系数",
"note": "热损失补偿。主要调谐参数。" "t": {
}, "title": "T 系数",
"exponent": { "note": "启用PID时此参数无效"
"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": "室外温度"
} }
}, },
@@ -485,13 +433,12 @@
"autoFaultReset": "自动报警复位 <small>(不推荐!)</small>", "autoFaultReset": "自动报警复位 <small>(不推荐!)</small>",
"autoDiagReset": "自动诊断复位 <small>(不推荐!)</small>", "autoDiagReset": "自动诊断复位 <small>(不推荐!)</small>",
"setDateAndTime": "同步设置锅炉日期与时间", "setDateAndTime": "同步设置锅炉日期与时间",
"immergasFix": "针对Immergas锅炉的兼容性修复", "immergasFix": "针对Immergas锅炉的兼容性修复"
"alwaysSendIndoorTemp": "向锅炉发送当前室内温度"
}, },
"nativeOTC": { "nativeHeating": {
"title": "原生热载体温度计算模式", "title": "原生锅炉供暖控制",
"note": "仅在锅炉处于 OTC 模式时<u>才</u>工作:需要并接受目标室内温度,并基于内置曲线模式自行调节热载体温度。与 PID 和 Equitherm 不兼容。" "note": "<u>注意:</u> 仅适用于锅炉需接收目标室温并自主调节载热介质温度的场景,与固件中的PID及Equithermq气候补偿功能不兼容。"
} }
}, },
+14 -68
View File
@@ -119,7 +119,6 @@
"mHeatEnabled": "Heating enabled", "mHeatEnabled": "Heating enabled",
"mHeatBlocking": "Heating blocked", "mHeatBlocking": "Heating blocked",
"mHeatOverheat": "Heating overheat", "mHeatOverheat": "Heating overheat",
"mHeatFreezing": "Heating freezing",
"sHeatActive": "Heating active", "sHeatActive": "Heating active",
"mHeatSetpointTemp": "Heating setpoint temp", "mHeatSetpointTemp": "Heating setpoint temp",
"mHeatTargetTemp": "Heating target temp", "mHeatTargetTemp": "Heating target temp",
@@ -152,7 +151,6 @@
"section": { "section": {
"static": "Static settings", "static": "Static settings",
"ethernet": "Ethernet",
"availableNetworks": "Available networks", "availableNetworks": "Available networks",
"staSettings": "WiFi settings", "staSettings": "WiFi settings",
"apSettings": "AP settings" "apSettings": "AP settings"
@@ -160,20 +158,7 @@
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "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"
}, },
"wifi": { "wifi": {
@@ -191,14 +176,7 @@
"ip": "IP", "ip": "IP",
"subnet": "Subnet", "subnet": "Subnet",
"gateway": "Gateway", "gateway": "Gateway",
"dns": "DNS", "dns": "DNS"
"connection": "Connection",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "None"
}
}, },
"sta": { "sta": {
@@ -265,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)", "otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)", "otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)", "otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
"otCoolingHours": "OpenTherm, number of cooling hours",
"ntcTemp": "NTC sensor", "ntcTemp": "NTC sensor",
"dallasTemp": "DALLAS sensor", "dallasTemp": "DALLAS sensor",
@@ -342,15 +319,9 @@
}, },
"freezeProtection": { "freezeProtection": {
"title": "Freeze protection", "title": "Freeze protection",
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b>.", "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>.",
"highTemp": { "lowTemp": "Low temperature threshold",
"title": "High temperature threshold", "thresholdTime": "Waiting time <small>(sec)</small>"
"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"
}
}, },
"portal": { "portal": {
@@ -385,16 +356,7 @@
}, },
"heating": { "heating": {
"hyst": { "hyst": "Hysteresis <small>(in degrees)</small>",
"title": "Hysteresis",
"desc": "Hysteresis is useful for maintaining a set indoor temp (when using «Equitherm» and/or «PID»). Forces disable heating when <code>current indoor > target + value</code> and enable heating when <code>current indoor < (target - value)</code>.",
"value": "Value <small>(in degrees)</small>",
"action": {
"title": "Action",
"disableHeating": "Disable heating",
"set0target": "Set null target"
}
},
"turboFactor": "Turbo mode coeff." "turboFactor": "Turbo mode coeff."
}, },
@@ -409,26 +371,11 @@
}, },
"equitherm": { "equitherm": {
"slope": { "n": "N factor",
"title": "Slope", "k": "K factor",
"note": "Heat loss compensation. Main tuning parameter." "t": {
},
"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": {
"title": "T factor", "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>." "note": "Not used if PID is enabled"
},
"chart": {
"targetTemp": "Target indoor temperature",
"setpointTemp": "Heat carrier temperature",
"outdoorTemp": "Outdoor temperature"
} }
}, },
@@ -486,13 +433,12 @@
"autoFaultReset": "Auto fault reset <small>(not recommended!)</small>", "autoFaultReset": "Auto fault reset <small>(not recommended!)</small>",
"autoDiagReset": "Auto diag reset <small>(not recommended!)</small>", "autoDiagReset": "Auto diag reset <small>(not recommended!)</small>",
"setDateAndTime": "Set date & time on boiler", "setDateAndTime": "Set date & time on boiler",
"immergasFix": "Fix for Immergas boilers", "immergasFix": "Fix for Immergas boilers"
"alwaysSendIndoorTemp": "Send current indoor temp to boiler"
}, },
"nativeOTC": { "nativeHeating": {
"title": "Native OTC mode", "title": "Native heating control (boiler)",
"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." "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."
} }
}, },
+14 -67
View File
@@ -151,7 +151,6 @@
"section": { "section": {
"static": "Impostazioni statico", "static": "Impostazioni statico",
"ethernet": "Ethernet",
"availableNetworks": "Reti disponibili", "availableNetworks": "Reti disponibili",
"staSettings": "Impostazioni WiFi", "staSettings": "Impostazioni WiFi",
"apSettings": "Impostazioni AP" "apSettings": "Impostazioni AP"
@@ -159,20 +158,7 @@
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "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"
}, },
"wifi": { "wifi": {
@@ -190,14 +176,7 @@
"ip": "IP", "ip": "IP",
"subnet": "Subnet", "subnet": "Subnet",
"gateway": "Gateway", "gateway": "Gateway",
"dns": "DNS", "dns": "DNS"
"connection": "Connessione",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Nessuno"
}
}, },
"sta": { "sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, numero di ore di funzionamento del bruciatore (ACS)", "otDhwBurnerHours": "OpenTherm, numero di ore di funzionamento del bruciatore (ACS)",
"otHeatingPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (riscaldamento)", "otHeatingPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (riscaldamento)",
"otDhwPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (ACS)", "otDhwPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (ACS)",
"otCoolingHours": "OpenTherm, numero di ore di funzionamento della cooling",
"ntcTemp": "Sensore NTC", "ntcTemp": "Sensore NTC",
"dallasTemp": "Sensore DALLAS", "dallasTemp": "Sensore DALLAS",
@@ -341,15 +319,9 @@
}, },
"freezeProtection": { "freezeProtection": {
"title": "Protezione antigelo", "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>.", "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>.",
"highTemp": { "lowTemp": "Soglia di temperatura minima",
"title": "Soglia di temperatura alta", "thresholdTime": "Tempo di attesa <small>(sec)</small>"
"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"
}
}, },
"portal": { "portal": {
@@ -384,16 +356,7 @@
}, },
"heating": { "heating": {
"hyst": { "hyst": "Isteresi <small>(in gradi)</small>",
"title": "Isteresi",
"desc": "L'isteresi è utile per mantenere una temperatura interna impostata (quando si utilizza «Equitherm» e/o «PID»). Forza la disabilitazione del riscaldamento quando <code>current indoor > target + value</code> e abilita il riscaldamento quando <code>current indoor < (target - value)</code>.",
"value": "Valore <small>(in gradi)</small>",
"action": {
"title": "Azione",
"disableHeating": "Disabilita riscaldamento",
"set0target": "Imposta target nullo"
}
},
"turboFactor": "Turbo mode coeff." "turboFactor": "Turbo mode coeff."
}, },
@@ -408,26 +371,11 @@
}, },
"equitherm": { "equitherm": {
"slope": { "n": "Fattore N",
"title": "Pendenza", "k": "Fattore K",
"note": "Compensazione della perdita di calore. Parametro di regolazione principale." "t": {
},
"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": {
"title": "Fattore 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>." "note": "Non usato se PID è attivato"
},
"chart": {
"targetTemp": "Temperatura interna target",
"setpointTemp": "Temperatura del vettore termico",
"outdoorTemp": "Temperatura esterna"
} }
}, },
@@ -485,13 +433,12 @@
"autoFaultReset": "Ripristino automatico degli errori <small>(sconsigliato!)</small>", "autoFaultReset": "Ripristino automatico degli errori <small>(sconsigliato!)</small>",
"autoDiagReset": "Ripristino diagnostico automatica <small>(sconsigliato!)</small>", "autoDiagReset": "Ripristino diagnostico automatica <small>(sconsigliato!)</small>",
"setDateAndTime": "Imposta data e ora sulla caldaia", "setDateAndTime": "Imposta data e ora sulla caldaia",
"immergasFix": "Fix per caldiaie Immergas", "immergasFix": "Fix per caldiaie Immergas"
"alwaysSendIndoorTemp": "Invia la temp attuale interna alla caldaia"
}, },
"nativeOTC": { "nativeHeating": {
"title": "Modalità nativa di calcolo della temperatura del vettore termico", "title": "Controllo del riscaldamento nativo (caldaia)",
"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." "note": "Lavora <u>SOLO</u> se la caldaia richiede la temperatura ambiente desiderata e regola autonomamente la temperatura del fluido. Non compatiblile con regolazioni PID e Equitherm del sistema."
} }
}, },
+16 -72
View File
@@ -136,27 +136,13 @@
"name": "Netwerkinstellingen", "name": "Netwerkinstellingen",
"section": { "section": {
"static": "Statische instellingen", "static": "Statische instellingen",
"ethernet": "Ethernet",
"availableNetworks": "Beschikbare netwerken", "availableNetworks": "Beschikbare netwerken",
"staSettings": "WiFi-instellingen", "staSettings": "WiFi-instellingen",
"apSettings": "AP-instellingen" "apSettings": "AP-instellingen"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "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"
}, },
"wifi": { "wifi": {
"ssid": "SSID", "ssid": "SSID",
@@ -172,14 +158,7 @@
"ip": "IP", "ip": "IP",
"subnet": "Subnet", "subnet": "Subnet",
"gateway": "Gateway", "gateway": "Gateway",
"dns": "DNS", "dns": "DNS"
"connection": "Verbinding",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Geen"
}
}, },
"sta": { "sta": {
"channel.note": "zet op 0 voor automatische selectie" "channel.note": "zet op 0 voor automatische selectie"
@@ -243,8 +222,6 @@
"otDhwBurnerHours": "OpenTherm, aantal branderuren (warm water)", "otDhwBurnerHours": "OpenTherm, aantal branderuren (warm water)",
"otHeatingPumpHours": "OpenTherm, aantal pompuren (verwarming)", "otHeatingPumpHours": "OpenTherm, aantal pompuren (verwarming)",
"otDhwPumpHours": "OpenTherm, aantal pompuren (warm water)", "otDhwPumpHours": "OpenTherm, aantal pompuren (warm water)",
"otCoolingHours": "OpenTherm, aantal cooling",
"ntcTemp": "NTC-sensor", "ntcTemp": "NTC-sensor",
"dallasTemp": "DALLAS-sensor", "dallasTemp": "DALLAS-sensor",
"bluetooth": "BLE-sensor", "bluetooth": "BLE-sensor",
@@ -315,18 +292,11 @@
} }
}, },
"freezeProtection": { "freezeProtection": {
"title": "Vorbeveiliging", "title": "Vorstbeveiliging",
"desc": "Verwarming zal geforceerd worden ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur daalt onder de <b>Lage temperatuurdrempel</b>.", "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>.",
"highTemp": { "lowTemp": "Drempelwaarde lage temperatuur",
"title": "Hoge temperatuurdrempel", "thresholdTime": "Wachttijd <small>(sec)</small>"
"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"
}
},
"portal": { "portal": {
"login": "Gebruikersnaam", "login": "Gebruikersnaam",
"password": "Wachtwoord", "password": "Wachtwoord",
@@ -357,16 +327,7 @@
} }
}, },
"heating": { "heating": {
"hyst": { "hyst": "Hysterese <small>(in graden)</small>",
"title": "Hysterese",
"desc": "Hysterese is nuttig voor het handhaven van een ingestelde binnentemperatuur (bij gebruik van «Equitherm» en/of «PID»). Forceert uitschakelen van verwarming wanneer <code>current indoor > target + value</code> en inschakelen van verwarming wanneer <code>current indoor < (target - value)</code>.",
"value": "Waarde <small>(in graden)</small>",
"action": {
"title": "Actie",
"disableHeating": "Verwarming uitschakelen",
"set0target": "Stel null target in"
}
},
"turboFactor": "Turbomodus coëff." "turboFactor": "Turbomodus coëff."
}, },
"emergency": { "emergency": {
@@ -378,26 +339,11 @@
"treshold": "Drempeltijd <small>(sec)</small>" "treshold": "Drempeltijd <small>(sec)</small>"
}, },
"equitherm": { "equitherm": {
"slope": { "n": "N-factor",
"title": "Helling", "k": "K-factor",
"note": "Compensatie voor warmteverlies. Hoofdafstelparameter." "t": {
}, "title": "T-factor",
"exponent": { "note": "Niet gebruikt als PID is ingeschakeld"
"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"
} }
}, },
"pid": { "pid": {
@@ -452,13 +398,11 @@
"autoFaultReset": "Automatische storingsreset <small>(niet aanbevolen!)</small>", "autoFaultReset": "Automatische storingsreset <small>(niet aanbevolen!)</small>",
"autoDiagReset": "Automatische diagnosereset <small>(niet aanbevolen!)</small>", "autoDiagReset": "Automatische diagnosereset <small>(niet aanbevolen!)</small>",
"setDateAndTime": "Stel datum & tijd in op ketel", "setDateAndTime": "Stel datum & tijd in op ketel",
"immergasFix": "Fix voor Immergas-ketels", "immergasFix": "Fix voor Immergas-ketels"
"alwaysSendIndoorTemp": "Stuur huidige binnentemp naar ketel"
}, },
"nativeHeating": {
"nativeOTC": { "title": "Natuurlijke verwarmingsregeling (ketel)",
"title": "Native warmtedrager temperatuur berekeningsmodus", "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."
"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."
} }
}, },
"mqtt": { "mqtt": {
+14 -67
View File
@@ -151,7 +151,6 @@
"section": { "section": {
"static": "Статические параметры", "static": "Статические параметры",
"ethernet": "Ethernet",
"availableNetworks": "Доступные сети", "availableNetworks": "Доступные сети",
"staSettings": "Настройки подключения", "staSettings": "Настройки подключения",
"apSettings": "Настройки точки доступа" "apSettings": "Настройки точки доступа"
@@ -159,20 +158,7 @@
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Инфо", "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"
}, },
"wifi": { "wifi": {
@@ -190,14 +176,7 @@
"ip": "IP адрес", "ip": "IP адрес",
"subnet": "Адрес подсети", "subnet": "Адрес подсети",
"gateway": "Адрес шлюза", "gateway": "Адрес шлюза",
"dns": "DNS адрес", "dns": "DNS адрес"
"connection": "Подключение",
"connectionType": {
"ethernet": "Ethernet",
"wifi": "WiFi",
"wifi-ap": "WiFi AP",
"none": "Нет"
}
}, },
"sta": { "sta": {
@@ -264,7 +243,6 @@
"otDhwBurnerHours": "OpenTherm, кол-во часов работы горелки (ГВС)", "otDhwBurnerHours": "OpenTherm, кол-во часов работы горелки (ГВС)",
"otHeatingPumpHours": "OpenTherm, кол-во часов работы насоса (отопление)", "otHeatingPumpHours": "OpenTherm, кол-во часов работы насоса (отопление)",
"otDhwPumpHours": "OpenTherm, кол-во часов работы насоса (ГВС)", "otDhwPumpHours": "OpenTherm, кол-во часов работы насоса (ГВС)",
"otCoolingHours": "OpenTherm, кол-во часов работы охлаждения",
"ntcTemp": "NTC датчик", "ntcTemp": "NTC датчик",
"dallasTemp": "DALLAS датчик", "dallasTemp": "DALLAS датчик",
@@ -341,15 +319,9 @@
}, },
"freezeProtection": { "freezeProtection": {
"title": "Защита от замерзания", "title": "Защита от замерзания",
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b>.", "desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b> в течение <b>времени ожидания</b>.",
"highTemp": { "lowTemp": "Нижний порог температуры",
"title": "Верхний порог температуры", "thresholdTime": "Время ожидания <small>(сек)</small>"
"note": "Порог, при котором система вернется в нормальное состояние после активации защиты от замерзания"
},
"lowTemp": {
"title": "Нижний порог температуры",
"note": "Порог, при котором отопление будет принудительно включено"
}
}, },
"portal": { "portal": {
@@ -384,16 +356,7 @@
}, },
"heating": { "heating": {
"hyst": { "hyst": "Гистерезис <small>(в градусах)</small>",
"title": "Гистерезис",
"desc": "Гистерезис полезен для поддержания заданной внутр. темп. (при использовании «ПЗА» и/или «ПИД»). Принудительно откл. отопление, когда <code>current indoor > target + value</code>, и вкл. отопление, когда <code>current indoor < (target - value)</code>.",
"value": "Значение <small>(в градусах)</small>",
"action": {
"title": "Действие",
"disableHeating": "Отключить отопление",
"set0target": "Установить 0 в качестве целевой темп."
}
},
"turboFactor": "Коэфф. турбо режима" "turboFactor": "Коэфф. турбо режима"
}, },
@@ -408,26 +371,11 @@
}, },
"equitherm": { "equitherm": {
"slope": { "n": "Коэффициент N",
"title": "Наклон", "k": "Коэффициент K",
"note": "Компенсация теплопотерь. Основной параметр настройки." "t": {
},
"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", "title": "Коэффициент T",
"note": "Не используется, если ПИД включен. Добавляет разницу между целевой и текущей температурой в помещении: <code>setpoint = setpoint + ((target - indoor) * T)</code>." "note": "Не используется, если ПИД включен"
},
"chart": {
"targetTemp": "Целевая внутренняя температура",
"setpointTemp": "Температура теплоносителя",
"outdoorTemp": "Наружная температура"
} }
}, },
@@ -485,13 +433,12 @@
"autoFaultReset": "Автоматический сброс ошибок <small>(не рекомендуется!)</small>", "autoFaultReset": "Автоматический сброс ошибок <small>(не рекомендуется!)</small>",
"autoDiagReset": "Автоматический сброс диагностики <small>(не рекомендуется!)</small>", "autoDiagReset": "Автоматический сброс диагностики <small>(не рекомендуется!)</small>",
"setDateAndTime": "Устанавливать время и дату на котле", "setDateAndTime": "Устанавливать время и дату на котле",
"immergasFix": "Фикс для котлов Immergas", "immergasFix": "Фикс для котлов Immergas"
"alwaysSendIndoorTemp": "Передавать текущую темп. в помещении котлу"
}, },
"nativeOTC": { "nativeHeating": {
"title": "Нативный режим OTC (расчёт температуры теплоносителя)", "title": "Передать управление отоплением котлу",
"note": "Работает <u>ТОЛЬКО</u> если котел в режиме OTC: требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА." "note": "Работает <u>ТОЛЬКО</u> если котел требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
} }
}, },
+1 -10
View File
@@ -195,10 +195,6 @@
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th> <th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
<td><i class="mHeatOverheat"></i></td> <td><i class="mHeatOverheat"></i></td>
</tr> </tr>
<tr>
<th scope="row" data-i18n>dashboard.states.mHeatFreezing</th>
<td><i class="mHeatFreezing"></i></td>
</tr>
<tr> <tr>
<th scope="row" data-i18n>dashboard.states.sHeatActive</th> <th scope="row" data-i18n>dashboard.states.sHeatActive</th>
<td><i class="sHeatActive"></i></td> <td><i class="sHeatActive"></i></td>
@@ -324,7 +320,7 @@
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); lang.build();
let actionTimer = null; let actionTimer = null;
let actionLongPress = false; let actionLongPress = false;
@@ -637,11 +633,6 @@
result.master.heating.overheat ? "success" : "error", result.master.heating.overheat ? "success" : "error",
result.master.heating.overheat ? "red" : "green" 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('.mHeatSetpointTemp', result.master.heating.setpointTemp);
setValue('.mHeatTargetTemp', result.master.heating.targetTemp); setValue('.mHeatTargetTemp', result.master.heating.targetTemp);
setValue('.mHeatCurrTemp', result.master.heating.currentTemp); setValue('.mHeatCurrTemp', result.master.heating.currentTemp);
+3 -16
View File
@@ -50,19 +50,15 @@
<th scope="row" data-i18n>network.params.mac</th> <th scope="row" data-i18n>network.params.mac</th>
<td><b id="network-mac"></b></td> <td><b id="network-mac"></b></td>
</tr> </tr>
<tr>
<th scope="row" data-i18n>network.params.connection</th>
<td><b id="network-connection"></b></td>
</tr>
<tr> <tr>
<th scope="row" data-i18n>network.wifi.connected</th> <th scope="row" data-i18n>network.wifi.connected</th>
<td><i id="network-connected"></i></td> <td><i id="network-connected"></i></td>
</tr> </tr>
<tr id="network-ssid-row"> <tr>
<th scope="row" data-i18n>network.wifi.ssid</th> <th scope="row" data-i18n>network.wifi.ssid</th>
<td><b id="network-ssid"></b></td> <td><b id="network-ssid"></b></td>
</tr> </tr>
<tr id="network-signal-row"> <tr>
<th scope="row" data-i18n>network.wifi.signal</th> <th scope="row" data-i18n>network.wifi.signal</th>
<td><b id="network-signal"></b> %</td> <td><b id="network-signal"></b> %</td>
</tr> </tr>
@@ -173,7 +169,7 @@
<script> <script>
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); lang.build();
setTimeout(async function onLoadPage() { setTimeout(async function onLoadPage() {
try { try {
@@ -196,7 +192,6 @@
setValue('#network-hostname', result.network.hostname); setValue('#network-hostname', result.network.hostname);
setValue('#network-mac', result.network.mac); setValue('#network-mac', result.network.mac);
setValue('#network-connection', i18n(`network.params.connectionType.${result.network.connectionType}`));
setStatus( setStatus(
'#network-connected', '#network-connected',
result.network.connected ? "success" : "error", result.network.connected ? "success" : "error",
@@ -204,14 +199,6 @@
); );
setValue('#network-ssid', result.network.ssid); setValue('#network-ssid', result.network.ssid);
setValue('#network-signal', result.network.signalQuality); 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-ip', result.network.ip);
setValue('#network-subnet', result.network.subnet); setValue('#network-subnet', result.network.subnet);
setValue('#network-gateway', result.network.gateway); setValue('#network-gateway', result.network.gateway);
+4 -113
View File
@@ -79,7 +79,6 @@
</div> </div>
</article> </article>
<article> <article>
<div> <div>
<hgroup> <hgroup>
@@ -101,7 +100,6 @@
</table> </table>
</div> </div>
<p id="scan-unavailable" class="hidden" data-i18n>network.scan.unavailable</p>
<button type="submit" data-i18n>button.refresh</button> <button type="submit" data-i18n>button.refresh</button>
</form> </form>
@@ -164,62 +162,6 @@
</form> </form>
</div> </div>
</article> </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> </main>
<footer class="container"> <footer class="container">
@@ -237,7 +179,7 @@
<script> <script>
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); lang.build();
const fillData = (data) => { const fillData = (data) => {
setInputValue("[name='hostname']", data.hostname); setInputValue("[name='hostname']", data.hostname);
@@ -248,29 +190,6 @@
setInputValue("[name='staticConfig[dns]']", data.staticConfig.dns); setInputValue("[name='staticConfig[dns]']", data.staticConfig.dns);
setBusy('#network-settings-busy', '#network-settings', false); 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[ssid]']", data.sta.ssid);
setInputValue("[name='sta[password]']", data.sta.password); setInputValue("[name='sta[password]']", data.sta.password);
setInputValue("[name='sta[channel]']", data.sta.channel); setInputValue("[name='sta[channel]']", data.sta.channel);
@@ -282,49 +201,21 @@
setBusy('#ap-settings-busy', '#ap-settings', false); 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 { try {
const [response, infoResponse] = await Promise.all([ const response = await fetch("/api/network/settings", {
fetch("/api/network/settings", {
cache: "no-cache", cache: "no-cache",
credentials: "include" credentials: "include"
}), });
fetch("/api/info", {
cache: "no-cache",
credentials: "include"
})
]);
if (!response.ok) { if (!response.ok) {
throw new Error('Response not valid'); throw new Error('Response not valid');
} }
const info = infoResponse.ok ? await infoResponse.json() : null;
const ethernetSupported = applyCapabilities(info);
const result = await response.json(); const result = await response.json();
fillData(result); fillData(result);
setupForm('#network-settings', fillData, ['hostname']); setupForm('#network-settings', fillData, ['hostname']);
setupNetworkScanForm('#network-scan', '#networks');
// 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);
}
setupForm('#sta-settings', fillData, ['sta.ssid', 'sta.password']); setupForm('#sta-settings', fillData, ['sta.ssid', 'sta.password']);
setupForm('#ap-settings', fillData, ['ap.ssid', 'ap.password']); setupForm('#ap-settings', fillData, ['ap.ssid', 'ap.password']);
+4 -37
View File
@@ -38,8 +38,6 @@
<p></p> <p></p>
</hgroup> </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"> <details id="template" class="sensor hidden" data-id="" data-preloaded="0">
<summary><b>#<span class="pos"></span>: <span class="name"></span></b></summary> <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="24" data-i18n>sensors.types.otDhwBurnerHours</option>
<option value="25" data-i18n>sensors.types.otHeatingPumpHours</option> <option value="25" data-i18n>sensors.types.otHeatingPumpHours</option>
<option value="26" data-i18n>sensors.types.otDhwPumpHours</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="50" data-i18n>sensors.types.ntcTemp</option>
<option value="51" data-i18n>sensors.types.dallasTemp</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="253" data-i18n>sensors.types.heatSetpointTemp</option>
<option value="254" data-i18n>sensors.types.manual</option> <option value="254" data-i18n>sensors.types.manual</option>
<option value="255" data-i18n>sensors.types.notConfigured</option> <option value="255" data-i18n>sensors.types.notConfigured</option>
@@ -203,43 +200,21 @@
<script> <script>
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", async () => {
const lang = new Lang(document.getElementById("lang")); const lang = new Lang(document.getElementById("lang"));
await lang.build(); lang.build();
const container = document.querySelector("article"); const container = document.querySelector("article");
const templateNode = container.querySelector("#template"); 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 { try {
const [response, infoResponse] = await Promise.all([ const response = await fetch("/api/sensors", {
fetch("/api/sensors", {
cache: "no-cache", cache: "no-cache",
credentials: "include" credentials: "include"
}), });
fetch("/api/info", {
cache: "no-cache",
credentials: "include"
})
]);
if (!response.ok) { if (!response.ok) {
throw new Error("Response not valid"); throw new Error("Response not valid");
} }
const info = infoResponse.ok ? await infoResponse.json() : null;
applyCapabilities(info, templateNode);
const result = await response.json(); const result = await response.json();
for (const sensorId in result) { for (const sensorId in result) {
const sensorNode = templateNode.cloneNode(true); const sensorNode = templateNode.cloneNode(true);
@@ -266,9 +241,7 @@
setCheckboxValue("[name='filtering']", data.filtering, sensorForm); setCheckboxValue("[name='filtering']", data.filtering, sensorForm);
setInputValue("[name='filteringFactor']", data.filteringFactor, {}, sensorForm); setInputValue("[name='filteringFactor']", data.filteringFactor, {}, sensorForm);
setTimeout(() => {
sensorForm.querySelector("[name='type']").dispatchEvent(new Event("change")); sensorForm.querySelector("[name='type']").dispatchEvent(new Event("change"));
}, 10);
setBusy(".form-busy", "form", false, sensorNode); setBusy(".form-busy", "form", false, sensorNode);
}; };
@@ -311,12 +284,6 @@
// ble // ble
case 52: case 52:
if (!bleSupported) {
parentGpio.classList.add("hidden");
parentAddress.classList.add("hidden");
break;
}
parentGpio.classList.add("hidden"); parentGpio.classList.add("hidden");
parentAddress.classList.remove("hidden"); parentAddress.classList.remove("hidden");
address.setAttribute("pattern", "([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}"); address.setAttribute("pattern", "([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}");
+28 -313
View File
@@ -193,48 +193,21 @@
</div> </div>
<div class="grid"> <div class="grid">
<label>
<span data-i18n>settings.heating.hyst</span>
<input type="number" inputmode="decimal" name="heating[hysteresis]" min="0" max="5" step="0.05" required>
</label>
<label> <label>
<span data-i18n>settings.heating.turboFactor</span> <span data-i18n>settings.heating.turboFactor</span>
<input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required> <input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required>
</label> </label>
</div>
<label> <label>
<span data-i18n>settings.maxModulation</span> <span data-i18n>settings.maxModulation</span>
<input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required> <input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required>
</label> </label>
</div>
<hr />
<details>
<summary><b data-i18n>settings.heating.hyst.title</b></summary>
<div>
<fieldset>
<label>
<input type="checkbox" name="heating[hysteresis][enabled]" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.heating.hyst.value</span>
<input type="number" inputmode="decimal" name="heating[hysteresis][value]" min="0" max="5" step="0.05" required>
</label>
<label>
<span data-i18n>settings.heating.hyst.action.title</span>
<select name="heating[hysteresis][action]">
<option value="0" data-i18n>settings.heating.hyst.action.disableHeating</option>
<option value="1" data-i18n>settings.heating.hyst.action.set0target</option>
</select>
</label>
</div>
</div>
<small data-i18n>settings.heating.hyst.desc</small>
</details>
<hr /> <hr />
@@ -265,15 +238,13 @@
<div class="grid"> <div class="grid">
<label> <label>
<span data-i18n>settings.freezeProtection.highTemp.title</span> <span data-i18n>settings.freezeProtection.lowTemp</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][highTemp]" min="0" max="0" step="1" required> <input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
<small data-i18n>settings.freezeProtection.highTemp.note</small>
</label> </label>
<label> <label>
<span data-i18n>settings.freezeProtection.lowTemp.title</span> <span data-i18n>settings.freezeProtection.thresholdTime</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required> <input type="number" inputmode="numeric" name="heating[freezeProtection][thresholdTime]" min="30" max="1800" step="1" required>
<small data-i18n>settings.freezeProtection.lowTemp.note</small>
</label> </label>
</div> </div>
@@ -383,44 +354,21 @@
</label> </label>
</fieldset> </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"> <div class="grid">
<label> <label>
<span data-i18n>settings.equitherm.slope.title</span> <span data-i18n>settings.equitherm.n</span>
<input type="number" inputmode="decimal" name="equitherm[slope]" min="0.001" max="10" step="0.001" required> <input type="number" inputmode="decimal" name="equitherm[n_factor]" min="0.001" max="10" step="0.001" required>
<small data-i18n>settings.equitherm.slope.note</small>
</label> </label>
<label> <label>
<span data-i18n>settings.equitherm.exponent.title</span> <span data-i18n>settings.equitherm.k</span>
<input type="number" inputmode="decimal" name="equitherm[exponent]" min="0.1" max="2" step="0.001" required> <input type="number" inputmode="decimal" name="equitherm[k_factor]" min="0" max="10" step="0.01" 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>
</label> </label>
<label> <label>
<span data-i18n>settings.equitherm.targetDiffFactor.title</span> <span data-i18n>settings.equitherm.t.title</span>
<input type="number" inputmode="decimal" name="equitherm[targetDiffFactor]" min="0" max="10" step="0.01" required> <input type="number" inputmode="decimal" name="equitherm[t_factor]" min="0" max="10" step="0.01" required>
<small data-i18n>settings.equitherm.targetDiffFactor.note</small> <small data-i18n>settings.equitherm.t.note</small>
</label> </label>
</div> </div>
@@ -694,17 +642,12 @@
<span data-i18n>settings.ot.options.immergasFix</span> <span data-i18n>settings.ot.options.immergasFix</span>
</label> </label>
<label>
<input type="checkbox" name="opentherm[options][alwaysSendIndoorTemp]" value="true">
<span data-i18n>settings.ot.options.alwaysSendIndoorTemp</span>
</label>
<hr /> <hr />
<label> <label>
<input type="checkbox" name="opentherm[options][nativeOTC]" value="true"> <input type="checkbox" name="opentherm[options][nativeHeatingControl]" value="true">
<span data-i18n>settings.ot.nativeOTC.title</span><br /> <span data-i18n>settings.ot.nativeHeating.title</span><br />
<small data-i18n>settings.ot.nativeOTC.note</small> <small data-i18n>settings.ot.nativeHeating.note</small>
</label> </label>
</fieldset> </fieldset>
</div> </div>
@@ -923,162 +866,10 @@
</footer> </footer>
<script src="/static/app.js?{BUILD_TIME}"></script> <script src="/static/app.js?{BUILD_TIME}"></script>
<script src="/static/chart.js?{BUILD_TIME}"></script>
<script> <script>
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); 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);
}
const fillData = (data) => { const fillData = (data) => {
// System // System
@@ -1124,9 +915,8 @@
setCheckboxValue("[name='opentherm[options][autoFaultReset]']", data.opentherm.options.autoFaultReset); setCheckboxValue("[name='opentherm[options][autoFaultReset]']", data.opentherm.options.autoFaultReset);
setCheckboxValue("[name='opentherm[options][autoDiagReset]']", data.opentherm.options.autoDiagReset); setCheckboxValue("[name='opentherm[options][autoDiagReset]']", data.opentherm.options.autoDiagReset);
setCheckboxValue("[name='opentherm[options][setDateAndTime]']", data.opentherm.options.setDateAndTime); 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][immergasFix]']", data.opentherm.options.immergasFix);
setCheckboxValue("[name='opentherm[options][alwaysSendIndoorTemp]']", data.opentherm.options.alwaysSendIndoorTemp);
setBusy('#ot-settings-busy', '#ot-settings', false); setBusy('#ot-settings-busy', '#ot-settings', false);
// MQTT // MQTT
@@ -1173,9 +963,7 @@
"min": data.system.unitSystem == 0 ? 1 : 33, "min": data.system.unitSystem == 0 ? 1 : 33,
"max": data.system.unitSystem == 0 ? 100 : 212 "max": data.system.unitSystem == 0 ? 100 : 212
}); });
setCheckboxValue("[name='heating[hysteresis][enabled]']", data.heating.hysteresis.enabled); setInputValue("[name='heating[hysteresis]']", data.heating.hysteresis);
setInputValue("[name='heating[hysteresis][value]']", data.heating.hysteresis.value);
setSelectValue("[name='heating[hysteresis][action]']", data.heating.hysteresis.action);
setInputValue("[name='heating[turboFactor]']", data.heating.turboFactor); setInputValue("[name='heating[turboFactor]']", data.heating.turboFactor);
setInputValue("[name='heating[maxModulation]']", data.heating.maxModulation); setInputValue("[name='heating[maxModulation]']", data.heating.maxModulation);
setInputValue("[name='heating[overheatProtection][highTemp]']", data.heating.overheatProtection.highTemp, { setInputValue("[name='heating[overheatProtection][highTemp]']", data.heating.overheatProtection.highTemp, {
@@ -1186,14 +974,11 @@
"min": 0, "min": 0,
"max": data.system.unitSystem == 0 ? 99 : 211 "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, { setInputValue("[name='heating[freezeProtection][lowTemp]']", data.heating.freezeProtection.lowTemp, {
"min": data.system.unitSystem == 0 ? 1 : 34, "min": data.system.unitSystem == 0 ? 1 : 34,
"max": data.system.unitSystem == 0 ? 30 : 86 "max": data.system.unitSystem == 0 ? 30 : 86
}); });
setInputValue("[name='heating[freezeProtection][thresholdTime]']", data.heating.freezeProtection.thresholdTime);
setBusy('#heating-settings-busy', '#heating-settings', false); setBusy('#heating-settings-busy', '#heating-settings', false);
// DHW // DHW
@@ -1217,7 +1002,7 @@
setBusy('#dhw-settings-busy', '#dhw-settings', false); setBusy('#dhw-settings-busy', '#dhw-settings', false);
// Emergency mode // Emergency mode
if (data.opentherm.options.nativeOTC) { if (data.opentherm.options.nativeHeatingControl) {
setInputValue("[name='emergency[target]']", data.emergency.target, { setInputValue("[name='emergency[target]']", data.emergency.target, {
"min": data.system.unitSystem == 0 ? 5 : 41, "min": data.system.unitSystem == 0 ? 5 : 41,
"max": data.system.unitSystem == 0 ? 40 : 104 "max": data.system.unitSystem == 0 ? 40 : 104
@@ -1234,10 +1019,9 @@
// Equitherm // Equitherm
setCheckboxValue("[name='equitherm[enabled]']", data.equitherm.enabled); setCheckboxValue("[name='equitherm[enabled]']", data.equitherm.enabled);
setInputValue("[name='equitherm[slope]']", data.equitherm.slope); setInputValue("[name='equitherm[n_factor]']", data.equitherm.n_factor);
setInputValue("[name='equitherm[exponent]']", data.equitherm.exponent); setInputValue("[name='equitherm[k_factor]']", data.equitherm.k_factor);
setInputValue("[name='equitherm[shift]']", data.equitherm.shift); setInputValue("[name='equitherm[t_factor]']", data.equitherm.t_factor);
setInputValue("[name='equitherm[targetDiffFactor]']", data.equitherm.targetDiffFactor);
setBusy('#equitherm-settings-busy', '#equitherm-settings', false); setBusy('#equitherm-settings-busy', '#equitherm-settings', false);
// PID // PID
@@ -1261,24 +1045,6 @@
setInputValue("[name='pid[deadband][thresholdHigh]']", data.pid.deadband.thresholdHigh); setInputValue("[name='pid[deadband][thresholdHigh]']", data.pid.deadband.thresholdHigh);
setInputValue("[name='pid[deadband][thresholdLow]']", data.pid.deadband.thresholdLow); setInputValue("[name='pid[deadband][thresholdLow]']", data.pid.deadband.thresholdLow);
setBusy('#pid-settings-busy', '#pid-settings', false); 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 { try {
@@ -1331,57 +1097,6 @@
} catch (error) { } catch (error) {
console.log(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> </script>
</body> </body>
+126 -8
View File
@@ -62,19 +62,19 @@
<form action="/api/upgrade" id="upgrade"> <form action="/api/upgrade" id="upgrade">
<fieldset class="primary"> <fieldset class="primary">
<label for="firmware-file"> <label>
<span data-i18n>upgrade.fw</span>: <span data-i18n>upgrade.fw</span>:
<div class="grid"> <div class="grid">
<input type="file" name="firmware" id="firmware-file" accept=".bin"> <input type="file" name="fw[file]" accept=".bin">
<button type="button" class="upgrade-firmware-result hidden" disabled></button> <button type="button" class="fwResult hidden" disabled></button>
</div> </div>
</label> </label>
<label for="filesystem-file"> <label>
<span data-i18n>upgrade.fs</span>: <span data-i18n>upgrade.fs</span>:
<div class="grid"> <div class="grid">
<input type="file" name="filesystem" id="filesystem-file" accept=".bin"> <input type="file" name="fs[file]" accept=".bin">
<button type="button" class="upgrade-filesystem-result hidden" disabled></button> <button type="button" class="fsResult hidden" disabled></button>
</div> </div>
</label> </label>
</fieldset> </fieldset>
@@ -105,10 +105,128 @@
<script> <script>
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); lang.build();
setupRestoreBackupForm('#restore'); setupRestoreBackupForm('#restore');
setupUpgradeForm('#upgrade');
const upgradeForm = document.querySelector('#upgrade');
if (upgradeForm) {
upgradeForm.reset();
const statusToText = (status) => {
switch (status) {
case 0:
return "None";
case 1:
return "No file";
case 2:
return "Success";
case 3:
return "Prohibited";
case 4:
return "Size mismatch";
case 5:
return "Error on start";
case 6:
return "Error on write";
case 7:
return "Error on finish";
default:
return "Unknown";
}
};
upgradeForm.addEventListener('submit', async (event) => {
event.preventDefault();
hide('.fwResult');
hide('.fsResult');
let button = upgradeForm.querySelector('button[type="submit"]');
button.textContent = i18n('button.uploading');
button.setAttribute('disabled', true);
button.setAttribute('aria-busy', true);
try {
let fd = new FormData();
const fw = upgradeForm.querySelector("[name='fw[file]']").files;
if (fw.length > 0) {
fd.append("fw[name]", fw[0].name);
fd.append("fw[size]", fw[0].size);
fd.append("fw[file]", fw[0]);
}
const fs = upgradeForm.querySelector("[name='fs[file]']").files;
if (fs.length > 0) {
fd.append("fs[name]", fs[0].name);
fd.append("fs[size]", fs[0].size);
fd.append("fs[file]", fs[0]);
}
let response = await fetch(upgradeForm.action, {
method: "POST",
cache: "no-cache",
credentials: "include",
body: fd
});
if (response.status != 202 && response.status != 406) {
throw new Error('Response not valid');
}
const result = await response.json();
let resItem = upgradeForm.querySelector('.fwResult');
if (resItem && result.firmware.status > 1) {
resItem.textContent = statusToText(result.firmware.status);
resItem.classList.remove('hidden');
if (result.firmware.status == 2) {
resItem.classList.remove('failed');
resItem.classList.add('success');
} else {
resItem.classList.remove('success');
resItem.classList.add('failed');
if (result.firmware.error != "") {
resItem.textContent += `: ${result.firmware.error}`;
}
}
}
resItem = upgradeForm.querySelector('.fsResult');
if (resItem && result.filesystem.status > 1) {
resItem.textContent = statusToText(result.filesystem.status);
resItem.classList.remove('hidden');
if (result.filesystem.status == 2) {
resItem.classList.remove('failed');
resItem.classList.add('success');
} else {
resItem.classList.remove('success');
resItem.classList.add('failed');
if (result.filesystem.error != "") {
resItem.textContent += `: ${result.filesystem.error}`;
}
}
}
} catch (err) {
console.log(err);
button.textContent = i18n('button.error');
button.classList.add('failed');
} finally {
setTimeout(() => {
button.removeAttribute('aria-busy');
button.removeAttribute('disabled');
button.classList.remove('success', 'failed');
button.textContent = i18n(button.dataset.i18n);
upgradeForm.reset();
}, 10000);
}
});
}
}); });
</script> </script>
</body> </body>
-14
View File
@@ -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
+6 -36
View File
@@ -5,13 +5,8 @@ const setupForm = (formSelector, onResultCallback = null, noCastItems = []) => {
} }
form.querySelectorAll('input').forEach(item => { form.querySelectorAll('input').forEach(item => {
item.addEventListener('change', (event) => { item.addEventListener('change', (e) => {
if (!event.target.checkValidity()) { e.target.setAttribute('aria-invalid', !e.target.checkValidity());
event.target.setAttribute('aria-invalid', true);
} else if (event.target.hasAttribute('aria-invalid')) {
event.target.removeAttribute('aria-invalid');
}
}) })
}); });
@@ -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); const form = document.querySelector(formSelector);
if (!form) { if (!form) {
console.error("form not found"); console.error("form not found");
@@ -253,9 +248,7 @@ const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
}; };
form.addEventListener('submit', onSubmitFn); form.addEventListener('submit', onSubmitFn);
if (autorun) {
onSubmitFn(); onSubmitFn();
}
} }
const setupRestoreBackupForm = (formSelector) => { const setupRestoreBackupForm = (formSelector) => {
@@ -637,10 +630,6 @@ const setCheckboxValue = (selector, value, parent = undefined) => {
} }
item.checked = value; item.checked = value;
setTimeout(() => {
item.dispatchEvent(new Event("change"));
}, 10);
} }
const setRadioValue = (selector, value, parent = undefined) => { const setRadioValue = (selector, value, parent = undefined) => {
@@ -654,14 +643,7 @@ const setRadioValue = (selector, value, parent = undefined) => {
} }
for (let item of items) { for (let item of items) {
const checked = item.value == value; item.checked = item.value == value;
if (item.checked != checked) {
item.checked = checked;
setTimeout(() => {
item.dispatchEvent(new Event("change"));
}, 10);
}
} }
} }
@@ -676,17 +658,13 @@ const setInputValue = (selector, value, attrs = {}, parent = undefined) => {
} }
for (let item of items) { for (let item of items) {
item.value = value;
if (attrs instanceof Object) { if (attrs instanceof Object) {
for (let attrKey of Object.keys(attrs)) { for (let attrKey of Object.keys(attrs)) {
item.setAttribute(attrKey, attrs[attrKey]); 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) { function constrain(amt, low, high) {
return ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))); return ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)));
} }
function c2f(value) {
return (9 / 5) * value + 32;
}
function f2c(value) {
return (value - 32) * (5 / 9);
}