mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 19:24:59 +00:00
auto-formatting
This commit is contained in:
@@ -13,11 +13,7 @@ import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
|
|||||||
import type { SvgIconProps } from '@mui/material';
|
import type { SvgIconProps } from '@mui/material';
|
||||||
|
|
||||||
export type OptionType =
|
export type OptionType =
|
||||||
| 'deleted'
|
'deleted' | 'readonly' | 'web_exclude' | 'api_mqtt_exclude' | 'favorite';
|
||||||
| 'readonly'
|
|
||||||
| 'web_exclude'
|
|
||||||
| 'api_mqtt_exclude'
|
|
||||||
| 'favorite';
|
|
||||||
|
|
||||||
type IconPair = [
|
type IconPair = [
|
||||||
React.ComponentType<SvgIconProps>,
|
React.ComponentType<SvgIconProps>,
|
||||||
|
|||||||
@@ -207,12 +207,12 @@ class AnalogSensor {
|
|||||||
uint32_t sensorreads_ = 0;
|
uint32_t sensorreads_ = 0;
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
static void IRAM_ATTR freqIrq0();
|
static void IRAM_ATTR freqIrq0();
|
||||||
static void IRAM_ATTR freqIrq1();
|
static void IRAM_ATTR freqIrq1();
|
||||||
static void IRAM_ATTR freqIrq2();
|
static void IRAM_ATTR freqIrq2();
|
||||||
static volatile unsigned long edge[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
|
static volatile unsigned long edge[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
|
||||||
static volatile unsigned long edgecnt[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
|
static volatile unsigned long edgecnt[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
|
||||||
unsigned long lastedge[3] = {0, 0, 0};
|
unsigned long lastedge[3] = {0, 0, 0};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ uint8_t Command::call(const uint8_t device_type, const char * command, const cha
|
|||||||
// for the Commands device, calling a named command executes it (using its stored value)
|
// for the Commands device, calling a named command executes it (using its stored value)
|
||||||
// rather than returning its definition, so skip the value-info lookup and fall through
|
// rather than returning its definition, so skip the value-info lookup and fall through
|
||||||
// to the registered command function. The list keywords above are still handled.
|
// to the registered command function. The list keywords above are still handled.
|
||||||
bool is_named_command = (device_type == EMSdevice::DeviceType::COMMAND) && strcmp(cmd, F_(info)) && strcmp(cmd, F_(values))
|
bool is_named_command = (device_type == EMSdevice::DeviceType::COMMAND) && strcmp(cmd, F_(info)) && strcmp(cmd, F_(values)) && strcmp(cmd, F_(entities))
|
||||||
&& strcmp(cmd, F_(entities)) && strcmp(cmd, F_(metrics));
|
&& strcmp(cmd, F_(metrics));
|
||||||
if (!is_named_command && EMSESP::get_device_value_info(output, cmd, id, device_type)) { // entity = cmd
|
if (!is_named_command && EMSESP::get_device_value_info(output, cmd, id, device_type)) { // entity = cmd
|
||||||
LOG_DEBUG("Fetched device entity/attributes for %s/%s (id=%d)", dname, cmd, id);
|
LOG_DEBUG("Fetched device entity/attributes for %s/%s (id=%d)", dname, cmd, id);
|
||||||
return CommandRet::OK;
|
return CommandRet::OK;
|
||||||
|
|||||||
+6
-3
@@ -59,7 +59,7 @@ using cmd_function_p = std::function<bool(const char * data, const int8_t id, Js
|
|||||||
class Command {
|
class Command {
|
||||||
public:
|
public:
|
||||||
struct CmdFunction {
|
struct CmdFunction {
|
||||||
uint8_t device_type_; // DeviceType::
|
uint8_t device_type_; // DeviceType::
|
||||||
uint8_t device_id_;
|
uint8_t device_id_;
|
||||||
uint8_t flags_; // mqtt flags for command subscriptions
|
uint8_t flags_; // mqtt flags for command subscriptions
|
||||||
bool has_json_output_; // true if the command writes JSON output; such commands bypass the readonly check
|
bool has_json_output_; // true if the command writes JSON output; such commands bypass the readonly check
|
||||||
@@ -116,8 +116,11 @@ class Command {
|
|||||||
static void
|
static void
|
||||||
add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * const * description, uint8_t flags = CommandFlag::CMD_FLAG_DEFAULT);
|
add(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * const * description, uint8_t flags = CommandFlag::CMD_FLAG_DEFAULT);
|
||||||
// command that writes a JSON object as its output; bypasses the readonly check
|
// command that writes a JSON object as its output; bypasses the readonly check
|
||||||
static void
|
static void add_json(const uint8_t device_type,
|
||||||
add_json(const uint8_t device_type, const char * cmd, const cmd_function_p cb, const char * const * description, uint8_t flags = CommandFlag::CMD_FLAG_DEFAULT);
|
const char * cmd,
|
||||||
|
const cmd_function_p cb,
|
||||||
|
const char * const * description,
|
||||||
|
uint8_t flags = CommandFlag::CMD_FLAG_DEFAULT);
|
||||||
|
|
||||||
static void reserve(size_t num) {
|
static void reserve(size_t num) {
|
||||||
cmdfunctions_.reserve(num);
|
cmdfunctions_.reserve(num);
|
||||||
|
|||||||
@@ -351,10 +351,10 @@ bool DeviceValue::get_min_max(int16_t & dv_set_min, uint32_t & dv_set_max) {
|
|||||||
|
|
||||||
// extract custom min from custom_fullname
|
// extract custom min from custom_fullname
|
||||||
bool DeviceValue::get_custom_min(int16_t & val) {
|
bool DeviceValue::get_custom_min(int16_t & val) {
|
||||||
const auto & cf = custom_fullname();
|
const auto & cf = custom_fullname();
|
||||||
auto min_pos = cf.find('>');
|
auto min_pos = cf.find('>');
|
||||||
bool has_min = (min_pos != std::string::npos);
|
bool has_min = (min_pos != std::string::npos);
|
||||||
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
||||||
if (has_min) {
|
if (has_min) {
|
||||||
int32_t v = Helpers::atoint(cf.substr(min_pos + 1).c_str());
|
int32_t v = Helpers::atoint(cf.substr(min_pos + 1).c_str());
|
||||||
if (fahrenheit) {
|
if (fahrenheit) {
|
||||||
@@ -370,10 +370,10 @@ bool DeviceValue::get_custom_min(int16_t & val) {
|
|||||||
|
|
||||||
// extract custom max from custom_fullname
|
// extract custom max from custom_fullname
|
||||||
bool DeviceValue::get_custom_max(uint32_t & val) {
|
bool DeviceValue::get_custom_max(uint32_t & val) {
|
||||||
const auto & cf = custom_fullname();
|
const auto & cf = custom_fullname();
|
||||||
auto max_pos = cf.find('<');
|
auto max_pos = cf.find('<');
|
||||||
bool has_max = (max_pos != std::string::npos);
|
bool has_max = (max_pos != std::string::npos);
|
||||||
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
||||||
if (has_max) {
|
if (has_max) {
|
||||||
int32_t v = Helpers::atoint(cf.substr(max_pos + 1).c_str());
|
int32_t v = Helpers::atoint(cf.substr(max_pos + 1).c_str());
|
||||||
if (fahrenheit) {
|
if (fahrenheit) {
|
||||||
|
|||||||
+10
-10
@@ -1884,16 +1884,16 @@ void EMSESP::loop() {
|
|||||||
if (EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_PENDING_UPLOAD
|
if (EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_PENDING_UPLOAD
|
||||||
&& EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_UPLOADING) {
|
&& EMSESP::system_.systemStatus() != SYSTEM_STATUS::SYSTEM_STATUS_UPLOADING) {
|
||||||
// loop through the services
|
// loop through the services
|
||||||
webStatusService.loop(); // periodic refresh of cached versions.json
|
webStatusService.loop(); // periodic refresh of cached versions.json
|
||||||
rxservice_.loop(); // process any incoming Rx telegrams
|
rxservice_.loop(); // process any incoming Rx telegrams
|
||||||
shower_.loop(); // check for shower on/off
|
shower_.loop(); // check for shower on/off
|
||||||
temperaturesensor_.loop(); // read sensor temperatures
|
temperaturesensor_.loop(); // read sensor temperatures
|
||||||
analogsensor_.loop(); // read analog sensor values
|
analogsensor_.loop(); // read analog sensor values
|
||||||
publish_all_loop(); // with HA messages in parts to avoid flooding the MQTT queue
|
publish_all_loop(); // with HA messages in parts to avoid flooding the MQTT queue
|
||||||
mqtt_.loop(); // sends out anything in the MQTT queue
|
mqtt_.loop(); // sends out anything in the MQTT queue
|
||||||
webModulesService.loop(); // loop through the external library modules
|
webModulesService.loop(); // loop through the external library modules
|
||||||
webSchedulerService.loop(); // scheduler timing logic; command execution is offloaded to WebCommandService's worker task
|
webSchedulerService.loop(); // scheduler timing logic; command execution is offloaded to WebCommandService's worker task
|
||||||
scheduled_fetch_values(); // force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
scheduled_fetch_values(); // force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
||||||
compact_entities_if_stable(); // reclaim over-reserved entity vector capacity once device discovery settles
|
compact_entities_if_stable(); // reclaim over-reserved entity vector capacity once device discovery settles
|
||||||
}
|
}
|
||||||
// check for GPIO Errors - this is called once when booting
|
// check for GPIO Errors - this is called once when booting
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ class WebCommandService : public StatefulService<WebCommands> {
|
|||||||
bool queueCommand(const char * name, const char * value = nullptr);
|
bool queueCommand(const char * name, const char * value = nullptr);
|
||||||
bool dispatchCommand(const char * name, const char * value = nullptr);
|
bool dispatchCommand(const char * name, const char * value = nullptr);
|
||||||
|
|
||||||
static bool isUrlCommand(const std::string & command); // true if the command definition is a HTTP/URL command
|
static bool isUrlCommand(const std::string & command); // true if the command definition is a HTTP/URL command
|
||||||
static bool valueContainsUrl(const std::string & value); // true if a value embeds a {"url":...} compute() will fetch
|
static bool valueContainsUrl(const std::string & value); // true if a value embeds a {"url":...} compute() will fetch
|
||||||
|
|
||||||
const CommandItem * find(const char * name);
|
const CommandItem * find(const char * name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user