MQTT subscribed - how to execute cmds on esp8266?
Moderators: grovkillen, Stuntteam, TD-er
MQTT subscribed - how to execute cmds on esp8266?
Hi,
i am faszinated by EasyESP, it has all i ever thought of.
i recently have flashed a ESP01, it running fine, it sends to my mosquitto broker and on the serial-console i saw, it subscribed itself to all /<name> messages, like mine: /Esp01/#
i did not find a lot doku, so my question: What messages can i send, to let the EasyESP on my ESP01 execute (switch-)cmds on the GPIOs ?
i found some pieces in the domoticz-mqtt code, but im not that experienced in programming. can anybody enlighten me?
great thanks,
ozett
i am faszinated by EasyESP, it has all i ever thought of.
i recently have flashed a ESP01, it running fine, it sends to my mosquitto broker and on the serial-console i saw, it subscribed itself to all /<name> messages, like mine: /Esp01/#
i did not find a lot doku, so my question: What messages can i send, to let the EasyESP on my ESP01 execute (switch-)cmds on the GPIOs ?
i found some pieces in the domoticz-mqtt code, but im not that experienced in programming. can anybody enlighten me?
great thanks,
ozett
Re: MQTT subscribed - how to execute cmds on esp8266?
The commands to control output directly were mainly build for a generic http interface. And have mainly been tested through http only.
So using MQTT could bring limitations for output control or could just not work yet. There's some guidance in this tutorial:
http://www.esp8266.nu/index.php/Tutorial_OpenHAB_Switch
I think in your case you could send a message to /Esp01/gpio/2 with value '1' to turn on GPIO-2
So using MQTT could bring limitations for output control or could just not work yet. There's some guidance in this tutorial:
http://www.esp8266.nu/index.php/Tutorial_OpenHAB_Switch
I think in your case you could send a message to /Esp01/gpio/2 with value '1' to turn on GPIO-2
Re: MQTT subscribed - how to execute cmds on esp8266?
Thanks for the quick reply.
i tested it without devices connected to gpio, i must do this later with a led, for example.
but i would have been helpful (at leat to me), if the output of "mosquitto_sub -t /Esp01/#" would show up on the serial console...
there is only some other debug-info running, i may look in the source, if mqtt-messages 'should' show up on the console...
but again, thanks for the quick reply...
(i will investigate, if other cmds beside "on/off" could be send via mqtt...)
i tested it without devices connected to gpio, i must do this later with a led, for example.
but i would have been helpful (at leat to me), if the output of "mosquitto_sub -t /Esp01/#" would show up on the serial console...
there is only some other debug-info running, i may look in the source, if mqtt-messages 'should' show up on the console...
Code: Select all
NIT : Booting Build nr:48
WIFI : Connecting...
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Connected to broker
Subscribed to: /Esp01/#
INIT : Boot OK
INIT : Normal boot
WD : Uptime 0 ConnectFailures 0 FreeMem 27600
WD : Uptime 1 ConnectFailures 0 FreeMem 27568
WD : Uptime 1 ConnectFailures 0 FreeMem 27360
WD : Uptime 2 ConnectFailures 0 FreeMem 27344
(i will investigate, if other cmds beside "on/off" could be send via mqtt...)
Re: MQTT subscribed - how to execute cmds on esp8266?
You should see logged MQTT topics if you increase serial log level to 3 or 4.
Re: MQTT subscribed - how to execute cmds on esp8266?
thanks, i found it in the EaspEasy Webinterface unter Tools/Advanced and set Log-level for serial to 4.
if i send
i can see the manual-entered topic on the serial-console: (how do i validate, if the topic resembles a valid template on ESpEasy?)
The message/cmd (=on/off, 1/0) will not show up there. would be helpful for debugging..
and i found some lines in the source (https://github.com/ESP8266nu/ESPEasy/bl ... /_C005.ino) for
"#define CPLUGIN_NAME_005 "OpenHAB MQTT"
where the receiving-part ends with calling another plugin like:
Does this mean, that i can send everything meaningful (pwm-value 512, on/off) to every GPIO ?
-------
somebody came also to this point: http://www.esp8266.nu/forum/viewtopic.p ... =202#p1424,
but not further...
if i send
Code: Select all
mosquitto_pub -t /Esp01/gpio/2 -m on
Code: Select all
FLASH: Settings saved
WD : Uptime 23 ConnectFailures 0 FreeMem 25824
MQTT : Topic /Esp01/gpio/2
WD : Uptime 24 ConnectFailures 0 FreeMem 25824
FLASH: Settings saved
MQTT : Topic /Esp01/gpio/2
WD : Uptime 24 ConnectFailures 0 FreeMem 25808
and i found some lines in the source (https://github.com/ESP8266nu/ESPEasy/bl ... /_C005.ino) for
"#define CPLUGIN_NAME_005 "OpenHAB MQTT"
where the receiving-part ends with calling another plugin like:
Code: Select all
String cmd = topicSplit[1];
struct EventStruct TempEvent;
TempEvent.Par1 = topicSplit[2].toInt();
TempEvent.Par2 = event->String2.toFloat();
PluginCall(PLUGIN_WRITE, &TempEvent, cmd);
break;
-------
somebody came also to this point: http://www.esp8266.nu/forum/viewtopic.p ... =202#p1424,
but not further...
Re: MQTT subscribed - how to execute cmds on esp8266?
I am using Openhab and v.147 of ESP Easy.
How I can switch the LCD on or off using MQTT?
I tested
without any result.
Same comands (lcdcmd)thru http works fine.
Thanks for help.
How I can switch the LCD on or off using MQTT?
I tested
Code: Select all
mosquitto_pub -m 'off' -t /ESP1/cmd/LCDCMD
mosquitto_pub -m 'off' -t /ESP1/LCDCMD
mosquitto_pub -m 'off' -t /ESP1/LCD/lcdcmd
mosquitto_pub -m 'off' -t /ESP1/lcdcmd
Same comands (lcdcmd)thru http works fine.
Thanks for help.
Re: MQTT subscribed - how to execute cmds on esp8266?
i am not sure, if mqtt works generally as input to espeasy.
maybe only in a plugin, where it is coded in.
somebody said try this:
viewtopic.php?f=2&t=2147&hilit=mqtt+cmd&start=40#p12219
in this plugin it goes like this:
may the hints could help you..?
maybe only in a plugin, where it is coded in.
somebody said try this:
somebody else said, you need the mqtt import plugin.papperone wrote:Did you try to send MQTT command to the topic "/<%sysname%>/cmd"; it shoudl work...
but everything discussed for the wifi-candle plugin:paulymorph wrote:Next, MQTT... I also compiled and loaded the MQTT Import plugin (and Extra Utilities) which appear to have successfully installed. Now, i'm trying to figure out how to publish (externally) to an MQTT topic such as /node2/candle/Brightness and have WiFi Candle brightness be adjusted accordingly without having to go through the UI of the ESP.
viewtopic.php?f=2&t=2147&hilit=mqtt+cmd&start=40#p12219
in this plugin it goes like this:
Code: Select all
// MQTT : mosquitto_pub -d -t sensors/espeasy/ESP_Candle/cmd -m "CANDLE_OFF"
may the hints could help you..?
Re: MQTT subscribed - how to execute cmds on esp8266?
Thanks tozett!
Finally I found how to conrtol LCD:
Finally I found how to conrtol LCD:
Code: Select all
mosquitto_pub -t /ESP1/cmd -m 'lcdcmd,on'
mosquitto_pub -t /ESP1/cmd -m 'lcdcmd,off'
Who is online
Users browsing this forum: No registered users and 28 guests