This commit is contained in:
MichaelDvP
2024-06-28 07:27:20 +02:00
9 changed files with 6066 additions and 6220 deletions

View File

@@ -89,7 +89,6 @@
"**/ArduinoJson/**" "**/ArduinoJson/**"
], ],
"cSpell.enableFiletypes": [ "cSpell.enableFiletypes": [
"!cpp",
"!typescript" "!typescript"
], ],
"typescript.preferences.preferTypeOnlyAutoImports": true "typescript.preferences.preferTypeOnlyAutoImports": true

View File

@@ -30,7 +30,7 @@
"@mui/material": "^5.15.20", "@mui/material": "^5.15.20",
"@table-library/react-table-library": "4.1.7", "@table-library/react-table-library": "4.1.7",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.8", "@types/node": "^20.14.9",
"@types/react": "^18.3.3", "@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",

View File

@@ -1761,12 +1761,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.14.8": "@types/node@npm:^20.14.9":
version: 20.14.8 version: 20.14.9
resolution: "@types/node@npm:20.14.8" resolution: "@types/node@npm:20.14.9"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~5.26.4"
checksum: 10c0/06d4643fa3b179b41fe19f9c75c240278ca1f7a313b3b837bc36ea119499c7ad77f06bbe72694ac04aa91ec77fe747baa09b889f4c435450c1724a26bd55f160 checksum: 10c0/911ffa444dc032897f4a23ed580c67903bd38ea1c5ec99b1d00fa10b83537a3adddef8e1f29710cbdd8e556a61407ed008e06537d834e48caf449ce59f87d387
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1997,7 +1997,7 @@ __metadata:
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0" "@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
"@types/babel__core": "npm:^7" "@types/babel__core": "npm:^7"
"@types/lodash-es": "npm:^4.17.12" "@types/lodash-es": "npm:^4.17.12"
"@types/node": "npm:^20.14.8" "@types/node": "npm:^20.14.9"
"@types/react": "npm:^18.3.3" "@types/react": "npm:^18.3.3"
"@types/react-dom": "npm:^18.3.0" "@types/react-dom": "npm:^18.3.0"
"@types/react-router-dom": "npm:^5.3.3" "@types/react-router-dom": "npm:^5.3.3"

View File

@@ -372,9 +372,9 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
case ARDUINO_EVENT_ETH_GOT_IP6: case ARDUINO_EVENT_ETH_GOT_IP6:
#if !TASMOTA_SDK && ESP_IDF_VERSION_MAJOR < 5 #if !TASMOTA_SDK && ESP_IDF_VERSION_MAJOR < 5
if (emsesp::EMSESP::system_.ethernet_connected()) { if (emsesp::EMSESP::system_.ethernet_connected()) {
emsesp::EMSESP::logger().info("LocalIPv6=%s", ETH.localIPv6().toString().c_str()); emsesp::EMSESP::logger().info("LocalIPv6 (ETH)=%s", ETH.localIPv6().toString().c_str());
} else { } else {
emsesp::EMSESP::logger().info("LocalIPv6=%s", WiFi.localIPv6().toString().c_str()); emsesp::EMSESP::logger().info("LocalIPv6 (WiFI)=%s", WiFi.localIPv6().toString().c_str());
} }
#else #else
emsesp::EMSESP::logger().info("IPv6=%s", IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString().c_str()); emsesp::EMSESP::logger().info("IPv6=%s", IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString().c_str());

File diff suppressed because it is too large Load Diff

View File

@@ -57,10 +57,12 @@ void AnalogSensor::reload(bool get_nvs) {
remove_ha_topic(sensor.type(), sensor.gpio()); remove_ha_topic(sensor.type(), sensor.gpio());
sensor.ha_registered = false; sensor.ha_registered = false;
} }
if (!analog_enabled_) { if (!analog_enabled_) {
sensors_.clear(); sensors_.clear();
return; return;
} }
// load the list of analog sensors from the customization service // load the list of analog sensors from the customization service
// and store them locally and then activate them // and store them locally and then activate them
EMSESP::webCustomizationService.read([&](WebCustomization & settings) { EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
@@ -68,8 +70,8 @@ void AnalogSensor::reload(bool get_nvs) {
for (auto & sensor_ : sensors_) { for (auto & sensor_ : sensors_) {
// update existing sensors // update existing sensors
bool found = false; bool found = false;
for (const auto & sensor : settings.analogCustomizations) { //search customlist for (const auto & sensor : settings.analogCustomizations) { // search customlist
if (System::is_valid_gpio(sensor.gpio) && sensor_.gpio() == sensor.gpio) { if (sensor_.gpio() == sensor.gpio) {
// for output sensors set value to new start-value // for output sensors set value to new start-value
if ((sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) if ((sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT)
&& (sensor_.type() != sensor.type || sensor_.offset() != sensor.offset || sensor_.factor() != sensor.factor)) { && (sensor_.type() != sensor.type || sensor_.offset() != sensor.offset || sensor_.factor() != sensor.factor)) {
@@ -94,14 +96,14 @@ void AnalogSensor::reload(bool get_nvs) {
for (const auto & sensor : settings.analogCustomizations) { for (const auto & sensor : settings.analogCustomizations) {
bool found = false; bool found = false;
for (const auto & sensor_ : sensors_) { for (const auto & sensor_ : sensors_) {
if (System::is_valid_gpio(sensor.gpio) && sensor_.gpio() == sensor.gpio) { if (sensor_.gpio() == sensor.gpio) {
found = true; found = true;
} }
} }
if (!found) { if (!found) {
if (!System::is_valid_gpio(sensor.gpio)) { // if (!System::is_valid_gpio(sensor.gpio)) {
continue; // continue;
} // }
sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, sensor.type); sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, sensor.type);
sensors_.back().ha_registered = false; // this will trigger recreate of the HA config sensors_.back().ha_registered = false; // this will trigger recreate of the HA config
if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) { if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) {
@@ -130,6 +132,14 @@ void AnalogSensor::reload(bool get_nvs) {
// activate each sensor // activate each sensor
for (auto & sensor : sensors_) { for (auto & sensor : sensors_) {
sensor.ha_registered = false; // force HA configs to be re-created sensor.ha_registered = false; // force HA configs to be re-created
// first check if the GPIO is valid. If not, force set it to disabled
if (!System::is_valid_gpio(sensor.gpio())) {
LOG_WARNING("Bad GPIO %d for Sensor %s", sensor.gpio(), sensor.name().c_str());
sensor.set_type(AnalogType::NOTUSED);
continue;
}
if (sensor.type() == AnalogType::ADC) { if (sensor.type() == AnalogType::ADC) {
LOG_DEBUG("ADC Sensor on GPIO %02d", sensor.gpio()); LOG_DEBUG("ADC Sensor on GPIO %02d", sensor.gpio());
// analogSetPinAttenuation does not work with analogReadMilliVolts // analogSetPinAttenuation does not work with analogReadMilliVolts
@@ -261,6 +271,7 @@ void AnalogSensor::measure() {
} }
} }
} }
// poll digital io every time with debounce // poll digital io every time with debounce
// go through the list of digital sensors // go through the list of digital sensors
for (auto & sensor : sensors_) { for (auto & sensor : sensors_) {

View File

@@ -101,7 +101,7 @@ class AnalogSensor {
double factor_; double factor_;
uint8_t uom_; uint8_t uom_;
double value_; // double because of the factor is a double double value_; // double because of the factor is a double
int8_t type_; int8_t type_; // one of the AnalogType enum
}; };
AnalogSensor() = default; AnalogSensor() = default;

View File

@@ -266,7 +266,7 @@ MAKE_ENUM_FIXED(list_syslog_level, "off", "emerg", "alert", "crit", "error", "wa
// sensors // sensors
MAKE_ENUM_FIXED(counter, "counter") MAKE_ENUM_FIXED(counter, "counter")
MAKE_ENUM_FIXED(digital_out, "digital_out") MAKE_ENUM_FIXED(digital_out, "digital_out")
MAKE_ENUM_FIXED(list_sensortype, "none", "digital in", "counter", "adc", "timer", "rate", "digital out", "pwm 0", "pwm 1", "pwm 2") MAKE_ENUM_FIXED(list_sensortype, "disabled", "digital in", "counter", "adc", "timer", "rate", "digital out", "pwm 0", "pwm 1", "pwm 2")
// watch // watch
MAKE_ENUM_FIXED(list_watch, "off", "on", "raw", "unknown") MAKE_ENUM_FIXED(list_watch, "off", "on", "raw", "unknown")

View File

@@ -440,6 +440,11 @@ bool System::is_valid_gpio(uint8_t pin, bool has_psram) {
#endif #endif
return false; // bad pin return false; // bad pin
} }
// extra check for pins 21 and 22 (I2C) when ethernet is enabled
if ((EMSESP::system_.ethernet_connected()) && (pin >= 21 && pin <= 22)) {
return false; // bad pin
}
return true; return true;
} }