HowTo: ESPEasy – Execute commands and actions via HTTP, MQTT, UDP and directly

One thing that makes ESPEasy so practical and universal is the ability to read and control various sensors and actuators via commands. This opens up an incredible number of possibilities, especially in combination with appropriate rules.

There are several options for testing individual commands and/or generally executing them.

These are described in the following article.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
Before you start with this article, you should have programmed the ESPEasy firmware on the ESP8266 you are using. You can find information about this in the following article.
ESPEasy – flash firmware and configure WLAN access data

Required tool:
-no-

Required material:

In the following list you will find all the tools you need to implement this article.


Available Commands

You can use commands from various “sources” to control your ESPEasy device. On the one hand, there are system commands that come from the “ESPEasy operating system” itself. With these you can control general functions such as setting the WLAN login data. You can find a list of these possible system commands at the following link: https://www.letscontrolit.com/wiki/index.php/ESPEasy_Command_Reference

In addition, each plugin can provide additional commands. There is no central overview for these commands. However, they should be provided by the developer of the plugin.

For plugins from Nerdiy.de you can always find this information on the respective plugin page on Nerdiy.de. You can find all available ESPEasy plugins at https://www.nerdiy.de/tag/ESPEasy-Plugin/


Execute commands via the serial port

If you are still connected locally - i.e. via USB - to your ESPEasy device, you can use the serial interface to execute commands quickly and easily. To do this, open the serial monitor of your Arduino IDE or another terminal program. You can find tips on this in the article Ardunio – Use the serial port.

If you have opened the “Serial Monitor” you can send commands to your ESPEasy device as shown. It is important that you have set the “line break character (CR)”.

Execute commands from the web menu

Another way to issue commands is via the web menu of your ESPEasy device. To do this, go to the web menu and then to the Tools tab.

There you will be offered an input field in the upper area that you can use to issue commands. To send the command, simply click on “Submit”.

Execute commands via a URL call

Commands can also be executed via an attached URL call. To do this, the command is simply called in combination with the IP address/domain name of the ESPEasy device.

If your ESPEasy device has the IP address 192.168.0.15 and you want to execute the command “testcommand,1,2,3”, this call would look like this:

http:// 192.168.0.15/tools?cmd=testcommand,1,2,3
This is another example of how you can execute a command via URL call.

Execute commands over UDP

This function can (so far) only be used to send commands from one ESPEasy device to another. All you have to do is execute the following command on the sending ESPEasy device.

SendTo,COMMAND,

Execute commands via rules

Almost all commands can also be used within Rules. I will describe this and general information about Rules in a separate article.


Execute commands via MQTT

Commands can also be posted over an existing MQTT connection and executed from the connected ESPEasy device.

To do this, you need to configure an MQTT controller on the ESPEasy device. This must also be in the first “slot” of the controller. The OpenHAB MQTT controller should also be used. Unfortunately, command execution does not work with the others (as far as we know).

To do this, configure your MQTT controller as shown. Of course, you also have to adapt the controller host name to your server and, if necessary, also specify the user name and password.

It is also important that the following is entered under “Controller Subscribe”:

/%sysname%/#

%sysname% stands for the name of your ESPEasy device. For example, if your ESPEasy device has the name “pxlBlckWohnzimmer”, this combination causes the MQTT controller to subscribe to all topics from “/pxlBlckWohnzimmer/”. This means that the controller also receives messages via “/pxlBlckWohnzimmer/cmd” which can be used to execute the desired commands.

In summary: If your ESPEasy device is called “pxlBlckWohnzimmer” it is enough to send the desired command to the topic “/pxlBlckWohnzimmer/cmd”.


Further information

https://www.letscontrolit.com/wiki/index.php/ESPEasy_Command_Reference


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

6 comments

  1. HI,
    thank you very much for your description!
    I tinker more on the hardware side and don't use any automation software a la open Hab or IO Broker. So my question is this, is it possible to send a device flashed with Tasmota UDP data to a specific IP? I bought a smart socket with energy meter. I want to send this energy data via UDP to another ESP server.
    Can you help me with this, so on the side of Tasmota 😉 🙂 .

    Many thanks and greetings
    MAT

    1. Hi Mat,
      as far as I know, this cannot be done with UDP. Does it have to be UDP?
      It should actually work via MQTT 🙂 .
      Best regards
      Fabian

  2. Hi, thanks a lot for this article. It is very helpfull because there is a very poor documentation for espeasy on the web. Thanks to you I was able to send my commands via MQTT to Espeasy. It was write nowhere that we have to use the OpenHAB controller for sendig command via MQTT....

    1. Hi kankrola,
      you are welcome. Had the same problem when I tried to fix it and tought it's worth documenting it. I guess the guys behind ESPEasy are already pretty busy at maintaining the development so I'm happy to fill the documentation gap with this a bit. 🙂
      Best regards
      Fab

    1. Hi Simon,
      Have you seen the section “Executing commands via MQTT”?
      What isn't working for you? 🙂
      Best regards
      Fabian

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.