【Domoticz】【ESP】通过Domoticz控制esp的http命令格式——ESPEasy System Variables

本文详细介绍了 ESPEasy 平台上的各种控制指令,包括内部命令、规则引擎命令和插件命令等。这些命令可用于直接控制硬件设备,如 GPIO、LCD 显示屏等,并可通过 HTTP、MQTT 或串口等方式触发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文在这里

使用Domoticz平台时,控制ESPEasy节点的IO口,可使用http命令控制,这里贴官网的详细介绍以便查询,日后再整理。


ESP Easy offers a set of commands to control hardware devices and provide some basic local control using rules. There are several ways to launch commands on ESP Easy:

  • Using HTTP: syntax http://<ESP IP>/control?cmd=<command>
  • Using MQTT: send the <command> to topic <MQTT subscribe template>/cmd
  • Using Serial port: just type the <command>
  • Using UDP between ESP units: SendTo <unit nr>, <command> (Setup UDP peer-2-peer first!)
  • Using the Rule engine: just enter the <command> within an event block or conditional block.

Commands are divided into several classes: Internal, Rules engine, plugins. The internal commands can only be used from Serial or Rules engine. If you want to use internal commands using HTTP/MQTT, setup an event within the rules section and remotely launch the "event" command.

CommandClassPurposeSyntax
DebugInternalChange Serial port debug levelDebug <1-4>
DelayRulesDelay rule processingDelay <delay in milliSeconds>
EventRulesCreate an eventevent <event>
GPIOPluginDirect control of output pinsSee:GPIO
IPInternalChange IP addressIP <IP address>
LCDPluginWrite text messages to LCD screenSee:LCDDisplay
LCDCMDPluginControl LCD screenSee:LCDDisplay
LongPulsePluginDirect pulse control of output pinsSee:GPIO
MCPGPIOPluginControl MCP23017 output pinsSee:MCP23017
MCPPulsePluginPulse control on MCP23017 output pinsSee:MCP23017
MCPLongPulsePluginLong pulse control on MCP23017 output pinsSee:MCP23017
OLEDPluginWrite text messages to OLED screenSee:OLEDDisplay
OLEDCMDPluginControl OLED screenSee:OLEDDisplay
PCAPWMPluginControl PCA9685 pwm pinsSee:PCA9685
PCFGPIOPluginControl PCF8574 output pinsSee:PCF8574
PCFPulsePluginPulse control on PCF8574 output pinsSee:PCF8574
PCFLongPulsePluginLong pulse control on PCF8574 output pinsSee:PCF8574
PulsePluginDirect pulse control of output pinsSee:GPIO
PublishRulesSend command using MQTT broker servicePublish <topic>, <value>
PWMPluginDirect PWM control of output pinsSee:GPIO
RebootInternalReboot the ESPReboot
ResetInternalReset config to factory defaultReset
SaveInternalSave config to persistent flash memorySave
SendToRulesSend command to other ESP (using UDP)SendTo <unit nr>, <command>
SendToHTTPRulesSend command to other network device using HTTPSendToHTTP <IP address>, <Portnumber>, <command>
SendToUDPRulesSend command to other network device using UDPSendToUDP <IP address>, <Portnumber>, <command>
ServoPluginDirect control of servo motorsSee:GPIO
SettingsInternalShow settings on serial terminalSettings
StatusPluginShow status on previously controlled pinsStatus <device>, <pin>
TimerSetRulesStart a timed eventTimerSet <timernr>,
WifiAPKeyInternalChange AP WPA keyWifiAPKey <WPA key>
WifiConnectInternalConnect to configured wireless networkWifiConnect
WifiDisconnectInternalDisconnect from wireless networkWifiDisconnect
WifiKeyInternalChange WPA keyWifiKey <Wifi WPA key>
WifiScanInternalScan Wireless networksWifiScan
WifiSSIDInternalChange SSIDWifiSSID <SSID>
ESPEasy System Variables

Generic: These can be used in templates for HTTP, MQTT, OLED and LCD displays and within rules:

%sysname%   - Name as configured through the webgui
%systime%       - Current time if NTP is enabled
%uptime%        - Uptime in minutes
%ip%            - Current IP address
%vcc%           - VCC value, this needs a custom compiled firmware! (#define FEATURE_ADC_VCC true)

Rules engine specific:

%eventvalue%       - substitutes the event value (everything that comes after the '=' sign)

Sample rules section:

on remoteTimerControl do
  timerSet 1,%eventvalue%
endon

Now send this command to the ESP:

http://<your esp ip>/control?cmd=event,remoteTimerControl=5
and it will set rules timer nr 1 to 5 seconds. Using this technique you can parse a value from an event to the rule engine. (note that 'timerSet' is a rule command and cannot be run directly from a remote command)


### ESP32 STA Mode Asynchronous Operation Example and Issues In the context of ESP32 operating as a Station (STA), asynchronous operations are crucial for maintaining non-blocking behavior while connecting to Wi-Fi networks or handling network traffic. The following sections provide an overview, code examples, and common issues encountered. #### Establishing Asynchronous Connection in STA Mode The `esp_wifi` library supports asynchronous connection attempts when configured properly. By setting up event handlers using the Event Loop system provided by Espressif's IDF framework, one can manage WiFi events without blocking the main program flow[^1]. ```c #include "esp_event.h" #include "esp_log.h" #include "nvs_flash.h" static const char *TAG = "wifi station"; void wifi_init_sta(void) { esp_netif_create_default_wifi_sta(); wifi_config_t cfg = { .sta = { .ssid = CONFIG_ESP_WIFI_SSID, .password = CONFIG_ESP_WIFI_PASSWORD, }, }; // Initialize NVS — it is used to store PHY init data. esp_err_t ret = nvs_flash_init(); if (ret != ESP_OK) { ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &cfg)); /* Register our event handler */ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL)); ESP_LOGI(TAG, "Starting async WiFi connect..."); esp_wifi_start(); // Do not wait here! Let other tasks run... } ``` This setup ensures that once initiated, the WiFi connection process runs asynchronously with respect to the rest of the application logic. Events such as successful connections (`IP_EVENT_STA_GOT_IP`) trigger callbacks where further actions like notifying completion via LEDs or starting HTTP servers could be implemented. #### Common Issues Encountered During Async Operations Several challenges may arise during implementation: - **Event Handler Conflicts**: Multiple components registering their own handlers might lead to conflicts unless carefully managed through unique identifiers or prioritization schemes. - **Resource Management**: Ensuring proper allocation/deallocation of resources within callback functions prevents memory leaks especially under error conditions. - **Timeout Handling**: Implementing timeouts on certain stages helps avoid indefinite waiting states which otherwise would cause deadlocks or unresponsive systems. - **Thread Safety Concerns**: Since these operations occur outside the primary task execution path, thread safety becomes paramount particularly around shared variables accessed both inside and outside interrupt contexts. --related questions-- 1. How does one implement reconnection strategies upon losing connectivity? 2. What mechanisms exist for securely storing credentials required for establishing wireless links? 3. Can multiple SSIDs be scanned concurrently while attempting association with another AP simultaneously? 4. Is there support available for implementing custom encryption algorithms beyond those predefined in the SDK? 5. Are there any best practices regarding power management techniques applicable specifically towards optimizing battery life during prolonged periods of standby?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值