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. Especially in combination with appropriate rules, this results in a tremendous number of possibilities.

To test individual commands and / or to be able to execute them in general, there are several possibilities.

These are described in the following article.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/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 shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further 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. Information can be found in the following article.
ESPEasy – Flash firmware and configure WLAN access data

Required tools:
-none-

Required material:

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


Available commands

To control your ESPEasy device you can use commands from different “sources”. On 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. A list of these possible system commands can be found at the following link: https://www.letscontrolit.com/wiki/index.php/ESPEasy_Command_Reference

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

With plugins of Nerdiy.de you find this information always on the respective Plugin side on Nerdiy.de. All available ESPEasy plugins can be found at https://www.nerdiy.de/tag/ESPEasy-Plugin/


Execute commands via the serial interface

If you are still connected locally – ie via USB – to your ESPEasy-device, you can use the serial interface to execute commands quickly and easily. Open the serial monitor of your Arduino-IDE or another terminal program. Tips can be found in the article Ardunio – Using the serial interface.

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

Execute commands via the web menu

Another way to set commands you have over the web menu your ESPEasy-devices. Go to the web menu and then Tools tab.

There you will be offered an input field in the upper area, where you can place commands. To submit the command click on “Submit”.

Execute commands via a URL call

Commands can also be executed via an appended URL call. 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
Dies ist ein weiteres Beispiel wie Ihr einen Befehl per URL-Aufruf ausführen könnt.

Befehle über UDP ausführen

Diese Funktion lässt sich wohl (bisher) nur zum versenden von Befehlen von einem ESPEasy-Gerät zu einem anderen nutzen. Dazu reicht es auf dem sendenden ESPEasy-Gerät folgenden Befehl auszuführen.

SendTo , 

Befehle über Rules ausführen

Fast alle Befehle lassen sich auch innerhalb von Rules nutzen. Dies und generell Infos zum Thema Rules werde ich in einem extra Artikel beschreiben.


Befehle über MQTT ausführen

Befehle lassen sich auch über eine bestehende MQTT-Verbindung posten und vom verbundenen ESPEasy-Gerät ausführen.

Dazu müsst Ihr auf dem ESPEasy-Gerät einen MQTT-Controller konfigurieren. Dieser muss auch auf dem ersten “Slot” der Controller liegen. Außerdem sollte der OpenHAB MQTT-Controller genutzt werden. Mit den anderen klappt die Befehlsausführung (soweit bekannt) leider nicht.

Konfiguriert dazu Euren MQTT-Controller wie abgebildet. Natürlich müsst Ihr den Controller Hostnamen dazu noch an Euren Server anpassen und ggf. auch Benutzername und Passwort angeben.

Wichtig ist hierbei auch, dass unter “Controller Subscribe” folgendes Eingetragen ist:

/%sysname%/#

%sysname% steht dabei für den Namen Eures ESPEasy-Geräts. Wenn Euer ESPEasy-Gerät z.B. den Namen “pxlBlckWohnzimmer” trägt bewirkt diese Kombination also, dass der MQTT-Controller alle Topics ab “/pxlBlckWohnzimmer/” aboniert. Damit empfängt der Controller also auch Nachrichten über “/pxlBlckWohnzimmer/cmd” welches sich nutzen lässt um die gewünschten Befehle auszuführen.

Zusammengefasst: Wenn Euer ESPEasy-Gerät also “pxlBlckWohnzimmer” heißt reicht es den gewünschten Befehl an das Topic “/pxlBlckWohnzimmer/cmd” zu senden.


Additional information

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


I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. 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 appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

2 comments

  1. HI,
    vielen Dank für Deine Beschreibung!
    Ich bastle mehr Hardwareseitig und benutze nooooch keine Automatisierungssoftware a la open Hab oder IO Broker. Meine Frage ist also die, ist es möglich ein Gerät mit Tasmota geflasht UDP Daten an eine bestimmte IP zu senden? Ich habe mir eine smart Steckdose gekauft mit Energiezähler. Diese Energiedaten möchte ich per UDP an einen anderen ESP-Server schicken.
    Kannst Du mir dabei weiter helfen, also auf Seiten von Tasmota? 😉 🙂

    Vielen Dank und Grüße
    MAT

    1. Hi Mat,
      soweit ich weiß lässt sich das mit UDP leider nicht erledigen. Muss es denn UDP sein?
      Über MQTT müsste es eigentlich klappen. 🙂
      Beste Grüße
      Fabian

Leave a Reply

Your email address will not be published. Required fields are marked *