mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-15 12:26:33 +03:00
remove unused variables
This commit is contained in:
@@ -178,21 +178,6 @@ void EMSESP::clear_all_devices() {
|
|||||||
// emsdevices.clear(); // remove entries, but doesn't delete actual devices
|
// emsdevices.clear(); // remove entries, but doesn't delete actual devices
|
||||||
}
|
}
|
||||||
|
|
||||||
// return number of devices of a known type
|
|
||||||
uint8_t EMSESP::count_devices(const uint8_t device_type) {
|
|
||||||
if (emsdevices.empty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t count = 0;
|
|
||||||
for (const auto & emsdevice : emsdevices) {
|
|
||||||
if (emsdevice && emsdevice->device_type() == device_type) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return total number of devices excluding the Controller
|
// return total number of devices excluding the Controller
|
||||||
uint8_t EMSESP::count_devices() {
|
uint8_t EMSESP::count_devices() {
|
||||||
if (emsdevices.empty()) {
|
if (emsdevices.empty()) {
|
||||||
@@ -208,27 +193,6 @@ uint8_t EMSESP::count_devices() {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the index of a device if there are more of the same type
|
|
||||||
// or 0 if there is only one or none
|
|
||||||
uint8_t EMSESP::device_index(const uint8_t device_type, const uint8_t unique_id) {
|
|
||||||
uint8_t count = 0;
|
|
||||||
uint8_t index = 0;
|
|
||||||
uint8_t current_index = 1;
|
|
||||||
|
|
||||||
for (const auto & emsdevice : emsdevices) {
|
|
||||||
if (emsdevice->device_type() == device_type) {
|
|
||||||
count++;
|
|
||||||
if (emsdevice->unique_id() == unique_id) {
|
|
||||||
index = current_index;
|
|
||||||
}
|
|
||||||
current_index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return 0 if only one device exists or not found
|
|
||||||
return (count <= 1) ? 0 : index;
|
|
||||||
}
|
|
||||||
|
|
||||||
// scans for new devices
|
// scans for new devices
|
||||||
void EMSESP::scan_devices() {
|
void EMSESP::scan_devices() {
|
||||||
EMSESP::clear_all_devices();
|
EMSESP::clear_all_devices();
|
||||||
|
|||||||
@@ -138,9 +138,7 @@ class EMSESP {
|
|||||||
static void device_active(const uint8_t device_id, const bool active);
|
static void device_active(const uint8_t device_id, const bool active);
|
||||||
static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id);
|
static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id);
|
||||||
static uint8_t device_id_from_cmd(const uint8_t device_type, const char * cmd, const int8_t id);
|
static uint8_t device_id_from_cmd(const uint8_t device_type, const char * cmd, const int8_t id);
|
||||||
static uint8_t count_devices(const uint8_t device_type);
|
|
||||||
static uint8_t count_devices();
|
static uint8_t count_devices();
|
||||||
static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id);
|
|
||||||
static bool get_device_value_info(JsonObject root, const char * cmd, const int8_t id, const uint8_t devicetype);
|
static bool get_device_value_info(JsonObject root, const char * cmd, const int8_t id, const uint8_t devicetype);
|
||||||
|
|
||||||
static void show_device_values(uuid::console::Shell & shell);
|
static void show_device_values(uuid::console::Shell & shell);
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ std::vector<Mqtt::MQTTSubFunction, AllocatorPSRAM<Mqtt::MQTTSubFunction>> Mqtt::
|
|||||||
uint32_t Mqtt::mqtt_publish_fails_ = 0;
|
uint32_t Mqtt::mqtt_publish_fails_ = 0;
|
||||||
bool Mqtt::connecting_ = false;
|
bool Mqtt::connecting_ = false;
|
||||||
bool Mqtt::initialized_ = false;
|
bool Mqtt::initialized_ = false;
|
||||||
bool Mqtt::ha_climate_reset_ = false;
|
|
||||||
uint16_t Mqtt::queuecount_ = 0;
|
uint16_t Mqtt::queuecount_ = 0;
|
||||||
uint8_t Mqtt::connectcount_ = 0;
|
uint8_t Mqtt::connectcount_ = 0;
|
||||||
uint32_t Mqtt::mqtt_message_id_ = 0;
|
uint32_t Mqtt::mqtt_message_id_ = 0;
|
||||||
@@ -493,7 +492,6 @@ void Mqtt::on_connect() {
|
|||||||
queue_unsubscribe_message(discovery_prefix_ + "/+/" + Mqtt::basename() + "/#");
|
queue_unsubscribe_message(discovery_prefix_ + "/+/" + Mqtt::basename() + "/#");
|
||||||
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
|
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
|
||||||
ha_status(); // create the EMS-ESP device in HA, which is MQTT retained
|
ha_status(); // create the EMS-ESP device in HA, which is MQTT retained
|
||||||
ha_climate_reset(true);
|
|
||||||
} else {
|
} else {
|
||||||
// with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs.
|
// with disabled HA we subscribe and the broker sends all stored HA-emsesp-configs.
|
||||||
// Around line 272 they are removed (search for "// remove HA topics if we don't use discover")
|
// Around line 272 they are removed (search for "// remove HA topics if we don't use discover")
|
||||||
|
|||||||
@@ -138,10 +138,6 @@ class Mqtt {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static MqttClient * client() {
|
|
||||||
return mqttClient_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool enabled() {
|
static bool enabled() {
|
||||||
return mqtt_enabled_;
|
return mqtt_enabled_;
|
||||||
}
|
}
|
||||||
@@ -231,14 +227,6 @@ class Mqtt {
|
|||||||
ha_enabled_ = ha_enabled;
|
ha_enabled_ = ha_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ha_climate_reset() {
|
|
||||||
return ha_climate_reset_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ha_climate_reset(bool reset) {
|
|
||||||
ha_climate_reset_ = reset;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string get_response() {
|
static std::string get_response() {
|
||||||
return lastresponse_;
|
return lastresponse_;
|
||||||
}
|
}
|
||||||
@@ -317,7 +305,6 @@ class Mqtt {
|
|||||||
static uint32_t mqtt_publish_fails_;
|
static uint32_t mqtt_publish_fails_;
|
||||||
static uint16_t queuecount_;
|
static uint16_t queuecount_;
|
||||||
static uint8_t connectcount_;
|
static uint8_t connectcount_;
|
||||||
static bool ha_climate_reset_;
|
|
||||||
|
|
||||||
static std::string lastresponse_;
|
static std::string lastresponse_;
|
||||||
|
|
||||||
|
|||||||
@@ -663,18 +663,11 @@ void System::modbus_init() {
|
|||||||
|
|
||||||
// read specific major system settings to store locally for faster access
|
// read specific major system settings to store locally for faster access
|
||||||
void System::store_settings(WebSettings & settings) {
|
void System::store_settings(WebSettings & settings) {
|
||||||
version_ = settings.version;
|
|
||||||
|
|
||||||
rx_gpio_ = settings.rx_gpio;
|
rx_gpio_ = settings.rx_gpio;
|
||||||
tx_gpio_ = settings.tx_gpio;
|
tx_gpio_ = settings.tx_gpio;
|
||||||
pbutton_gpio_ = settings.pbutton_gpio;
|
pbutton_gpio_ = settings.pbutton_gpio;
|
||||||
dallas_gpio_ = settings.dallas_gpio;
|
|
||||||
led_gpio_ = settings.led_gpio;
|
|
||||||
|
|
||||||
analog_enabled_ = settings.analog_enabled;
|
|
||||||
low_clock_ = settings.low_clock;
|
low_clock_ = settings.low_clock;
|
||||||
hide_led_ = settings.hide_led;
|
|
||||||
led_type_ = settings.led_type;
|
|
||||||
board_profile_ = settings.board_profile;
|
board_profile_ = settings.board_profile;
|
||||||
telnet_enabled_ = settings.telnet_enabled;
|
telnet_enabled_ = settings.telnet_enabled;
|
||||||
|
|
||||||
@@ -1786,14 +1779,12 @@ bool System::command_service(const char * cmd, const char * value) {
|
|||||||
settings.hide_led = b;
|
settings.hide_led = b;
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
});
|
});
|
||||||
EMSESP::system_.hide_led(b);
|
|
||||||
ok = true;
|
ok = true;
|
||||||
} else if (!strcmp(cmd, "settings/analogenabled")) {
|
} else if (!strcmp(cmd, "settings/analogenabled")) {
|
||||||
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
||||||
settings.analog_enabled = b;
|
settings.analog_enabled = b;
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
});
|
});
|
||||||
EMSESP::system_.analog_enabled(b);
|
|
||||||
ok = true;
|
ok = true;
|
||||||
} else if (!strcmp(cmd, "mqtt/enabled")) {
|
} else if (!strcmp(cmd, "mqtt/enabled")) {
|
||||||
EMSESP::esp32React.getMqttSettingsService()->update([&](MqttSettings & Settings) {
|
EMSESP::esp32React.getMqttSettingsService()->update([&](MqttSettings & Settings) {
|
||||||
|
|||||||
@@ -163,10 +163,6 @@ class System {
|
|||||||
|
|
||||||
static String get_ip_or_hostname();
|
static String get_ip_or_hostname();
|
||||||
|
|
||||||
void dallas_gpio(uint8_t gpio) {
|
|
||||||
dallas_gpio_ = gpio;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool telnet_enabled() {
|
bool telnet_enabled() {
|
||||||
return telnet_enabled_;
|
return telnet_enabled_;
|
||||||
}
|
}
|
||||||
@@ -187,18 +183,6 @@ class System {
|
|||||||
return modbus_timeout_;
|
return modbus_timeout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool analog_enabled() {
|
|
||||||
return analog_enabled_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void analog_enabled(bool b) {
|
|
||||||
analog_enabled_ = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hide_led(bool b) {
|
|
||||||
hide_led_ = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool readonly_mode() {
|
bool readonly_mode() {
|
||||||
return readonly_mode_;
|
return readonly_mode_;
|
||||||
}
|
}
|
||||||
@@ -415,17 +399,12 @@ class System {
|
|||||||
// EMS-ESP settings
|
// EMS-ESP settings
|
||||||
std::string hostname_;
|
std::string hostname_;
|
||||||
String locale_;
|
String locale_;
|
||||||
bool hide_led_;
|
|
||||||
uint8_t led_type_;
|
|
||||||
uint8_t led_gpio_;
|
|
||||||
bool analog_enabled_;
|
|
||||||
bool low_clock_;
|
bool low_clock_;
|
||||||
String board_profile_;
|
String board_profile_;
|
||||||
uint8_t pbutton_gpio_;
|
uint8_t pbutton_gpio_;
|
||||||
uint8_t rx_gpio_;
|
uint8_t rx_gpio_;
|
||||||
uint8_t tx_gpio_;
|
uint8_t tx_gpio_;
|
||||||
uint8_t tx_mode_;
|
uint8_t tx_mode_;
|
||||||
uint8_t dallas_gpio_;
|
|
||||||
bool telnet_enabled_;
|
bool telnet_enabled_;
|
||||||
bool syslog_enabled_;
|
bool syslog_enabled_;
|
||||||
int8_t syslog_level_;
|
int8_t syslog_level_;
|
||||||
@@ -437,7 +416,6 @@ class System {
|
|||||||
uint8_t bool_format_;
|
uint8_t bool_format_;
|
||||||
uint8_t enum_format_;
|
uint8_t enum_format_;
|
||||||
bool readonly_mode_;
|
bool readonly_mode_;
|
||||||
String version_;
|
|
||||||
bool modbus_enabled_;
|
bool modbus_enabled_;
|
||||||
uint16_t modbus_port_;
|
uint16_t modbus_port_;
|
||||||
uint8_t modbus_max_clients_;
|
uint8_t modbus_max_clients_;
|
||||||
|
|||||||
@@ -47,13 +47,10 @@ void TemperatureSensor::start(const bool factory_settings) {
|
|||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
void TemperatureSensor::reload() {
|
void TemperatureSensor::reload() {
|
||||||
// load the service settings
|
|
||||||
EMSESP::system_.dallas_gpio(0); // reset in system to check valid sensor
|
|
||||||
EMSESP::webSettingsService.read([&](WebSettings const & settings) {
|
EMSESP::webSettingsService.read([&](WebSettings const & settings) {
|
||||||
dallas_gpio_ = settings.dallas_gpio;
|
dallas_gpio_ = settings.dallas_gpio;
|
||||||
parasite_ = settings.dallas_parasite;
|
parasite_ = settings.dallas_parasite;
|
||||||
});
|
});
|
||||||
EMSESP::system_.dallas_gpio(dallas_gpio_); // set to system for checks
|
|
||||||
|
|
||||||
for (auto & sensor : sensors_) {
|
for (auto & sensor : sensors_) {
|
||||||
remove_ha_topic(sensor.id());
|
remove_ha_topic(sensor.id());
|
||||||
|
|||||||
Reference in New Issue
Block a user