mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
is_system fixes
This commit is contained in:
@@ -160,8 +160,10 @@ void TemperatureSensor::loop() {
|
|||||||
}
|
}
|
||||||
// add new sensor. this will create the id string, empty name and offset
|
// add new sensor. this will create the id string, empty name and offset
|
||||||
if (!found && (sensors_.size() < (MAX_SENSORS - 1))) {
|
if (!found && (sensors_.size() < (MAX_SENSORS - 1))) {
|
||||||
|
LOG_DEBUG("Adding new sensor for %s", Sensor(addr).id().c_str());
|
||||||
sensors_.emplace_back(addr);
|
sensors_.emplace_back(addr);
|
||||||
sensors_.back().read = true;
|
sensors_.back().read = true;
|
||||||
|
sensors_.back().set_is_system(false);
|
||||||
changed_ = true;
|
changed_ = true;
|
||||||
// look in the customization service for an optional alias or offset for that particular sensor
|
// look in the customization service for an optional alias or offset for that particular sensor
|
||||||
sensors_.back().apply_customization();
|
sensors_.back().apply_customization();
|
||||||
@@ -189,7 +191,6 @@ void TemperatureSensor::loop() {
|
|||||||
bus_.depower();
|
bus_.depower();
|
||||||
}
|
}
|
||||||
// check for missing sensors after some samples
|
// check for missing sensors after some samples
|
||||||
// but don't do this if running in test mode where we simulate sensors
|
|
||||||
if (++scancnt_ > SCAN_MAX) {
|
if (++scancnt_ > SCAN_MAX) {
|
||||||
for (auto & sensor : sensors_) {
|
for (auto & sensor : sensors_) {
|
||||||
if (!sensor.read) {
|
if (!sensor.read) {
|
||||||
@@ -329,6 +330,7 @@ bool TemperatureSensor::update(const std::string & id, const std::string & name,
|
|||||||
|
|
||||||
sensor.set_name(name);
|
sensor.set_name(name);
|
||||||
sensor.set_offset(offset);
|
sensor.set_offset(offset);
|
||||||
|
sensor.set_is_system(is_system);
|
||||||
|
|
||||||
// store the new name and offset in our configuration
|
// store the new name and offset in our configuration
|
||||||
EMSESP::webCustomizationService.update([&id, &name, &offset, &is_system, &sensor](WebCustomization & settings) {
|
EMSESP::webCustomizationService.update([&id, &name, &offset, &is_system, &sensor](WebCustomization & settings) {
|
||||||
@@ -425,6 +427,7 @@ void TemperatureSensor::get_value_json(JsonObject output, const Sensor & sensor)
|
|||||||
output["readable"] = true;
|
output["readable"] = true;
|
||||||
output["writeable"] = false;
|
output["writeable"] = false;
|
||||||
output["visible"] = true;
|
output["visible"] = true;
|
||||||
|
output["is_system"] = sensor.is_system();
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish a single sensor to MQTT
|
// publish a single sensor to MQTT
|
||||||
@@ -610,6 +613,7 @@ bool TemperatureSensor::Sensor::apply_customization() {
|
|||||||
LOG_DEBUG("Loading customization for temperature sensor %s", sensor.id.c_str());
|
LOG_DEBUG("Loading customization for temperature sensor %s", sensor.id.c_str());
|
||||||
set_name(sensor.name);
|
set_name(sensor.name);
|
||||||
set_offset(sensor.offset);
|
set_offset(sensor.offset);
|
||||||
|
set_is_system(sensor.is_system);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user