mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 09:19:51 +03:00
cleanup and formatting
This commit is contained in:
@@ -47,7 +47,6 @@ void AnalogSensor::start() {
|
||||
CommandFlag::HIDDEN); // this command is hidden
|
||||
Command::add(
|
||||
EMSdevice::DeviceType::ANALOGSENSOR,
|
||||
0,
|
||||
F_(setvalue),
|
||||
[&](const char * value, const int8_t id) { return command_setvalue(value, id); },
|
||||
FL_(setiovalue_cmd),
|
||||
@@ -121,7 +120,6 @@ void AnalogSensor::reload() {
|
||||
if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) {
|
||||
Command::add(
|
||||
EMSdevice::DeviceType::ANALOGSENSOR,
|
||||
0,
|
||||
sensor.name.c_str(),
|
||||
[&](const char * value, const int8_t id) { return command_setvalue(value, sensor.gpio); },
|
||||
sensor.type == AnalogType::COUNTER ? FL_(counter)
|
||||
|
||||
@@ -336,6 +336,11 @@ void Command::add(const uint8_t device_type, const uint8_t device_id, const char
|
||||
cmdfunctions_.emplace_back(device_type, device_id, flags, cmd, cb, nullptr, description); // callback for json is nullptr
|
||||
}
|
||||
|
||||
// same for system/dallas/analog devices with device_id 0
|
||||
void Command::add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * const * description, uint8_t flags) {
|
||||
add(device_type, 0, cmd, cb, description, flags);
|
||||
}
|
||||
|
||||
// add a command to the list, which does return a json object as output
|
||||
void Command::add(const uint8_t device_type, const char * cmd, const cmd_json_function_p cb, const char * const * description, uint8_t flags) {
|
||||
// if the command already exists for that device type don't add it
|
||||
|
||||
@@ -107,6 +107,13 @@ class Command {
|
||||
const char * const * description,
|
||||
uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT);
|
||||
|
||||
// same for system/dallas/analog devices
|
||||
static void add(const uint8_t device_type,
|
||||
const char * cmd,
|
||||
const cmd_function_p cb,
|
||||
const char * const * description,
|
||||
uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT);
|
||||
|
||||
// callback function taking value, id and a json object for its output
|
||||
static void add(const uint8_t device_type,
|
||||
const char * cmd,
|
||||
|
||||
@@ -214,7 +214,9 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(const ui
|
||||
return heating_circuit;
|
||||
}
|
||||
}
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG("Heating circuit not fond on device 0x%02X", device_id());
|
||||
#endif
|
||||
return nullptr; // not found
|
||||
}
|
||||
|
||||
@@ -3244,7 +3246,9 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
|
||||
return true;
|
||||
}
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG("temperature mode %d not found", mode);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1019,7 +1019,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) {
|
||||
name = "converter"; // generic
|
||||
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) {
|
||||
name = "clock"; // generic
|
||||
name = "clock"; // generic
|
||||
device_type = DeviceType::CONTROLLER;
|
||||
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONTROLLER) {
|
||||
name = "generic controller";
|
||||
|
||||
@@ -253,7 +253,7 @@ void System::syslog_init() {
|
||||
syslog_.hostname(hostname().c_str());
|
||||
|
||||
// register the command
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(syslog), System::command_syslog_level, FL_(changeloglevel_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, FL_(changeloglevel_cmd), CommandFlag::ADMIN_ONLY);
|
||||
|
||||
} else if (was_enabled) {
|
||||
// in case service is still running, this flushes the queue
|
||||
@@ -730,13 +730,13 @@ void System::system_check() {
|
||||
|
||||
// commands - takes static function pointers
|
||||
void System::commands_init() {
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(send), System::command_send, FL_(send_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(fetch), System::command_fetch, FL_(fetch_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(watch), System::command_watch, FL_(watch_cmd));
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, FL_(send_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, FL_(fetch_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
|
||||
|
||||
if (Mqtt::enabled()) {
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, F_(publish), System::command_publish, FL_(publish_cmd));
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, FL_(publish_cmd));
|
||||
}
|
||||
|
||||
// these commands will return data in JSON format
|
||||
@@ -744,7 +744,7 @@ void System::commands_init() {
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, FL_(commands_cmd));
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, 0, ("test"), System::command_test, FL_(test_cmd));
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
|
||||
#endif
|
||||
|
||||
// MQTT subscribe "ems-esp/system/#"
|
||||
|
||||
@@ -215,8 +215,12 @@ void WebCustomizationService::device_entities(AsyncWebServerRequest * request, J
|
||||
JsonArray output = response->getRoot();
|
||||
emsdevice->generate_values_web_customization(output);
|
||||
#endif
|
||||
#if defined(EMSESP_DEBUG)
|
||||
size_t length = response->setLength();
|
||||
EMSESP::logger().debug("Customization buffer used: %d", length);
|
||||
#else
|
||||
response->setLength();
|
||||
#endif
|
||||
request->send(response);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,12 @@ void WebDataService::device_data(AsyncWebServerRequest * request, JsonVariant &
|
||||
// #endif
|
||||
// #endif
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
size_t length = response->setLength();
|
||||
EMSESP::logger().debug("Dashboard buffer used: %d", length);
|
||||
#else
|
||||
response->setLength();
|
||||
#endif
|
||||
request->send(response);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user