How to command ESPEASY GPIO thru MQTT Mosquitto

Moderators: rtenklooster, Voyager, BertB, Stuntteam

Post Reply
Message
Author
xmenne
Normal user
Posts: 6
Joined: 17 Jul 2019, 17:38
Location: Saint Ouen sur Loire France

How to command ESPEASY GPIO thru MQTT Mosquitto

#1 Post by xmenne » 05 Mar 2020, 12:08

I have a mosquitto broker and Domoticz installed on Pi.
I have a ESPEasy R120 installed on ESP8266 WemosD1 Mini.
All installed recently end of 2019.

I am successfull to have one switch working via Domoticz Http .
http://192.168.1.24/control?cmd=GPIO,15,1 is working fine.

What I want to do is the same thing but thru MQTT.

I have tried several flavor of this configuration without success
ESP03 subscribe Template is >> ESP03/#
Then I Publish on MQTT >> mosquitto_pub -t ESP03/cmd -m gpio,15,1
Therefore I see that on MQTT >> ESP03/cmd gpio,15,1
as expected

The issue is that with several flavor of this command and subscribe template i have no effect on mys ESP and switch.

I have two question for any one who may have a similar configuration :

Where can I see some detailed log in ESPEasy ?
Where am i wrong in the way i write my command ?

Thks
Signed XMenne from France

User avatar
grovkillen
Core team member
Posts: 3584
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to command ESPEASY GPIO thru MQTT Mosquitto

#2 Post by grovkillen » 05 Mar 2020, 16:18

You can use the web log or the serial log to see what's going on.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TD-er
Core team member
Posts: 2645
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: How to command ESPEASY GPIO thru MQTT Mosquitto

#3 Post by TD-er » 05 Mar 2020, 16:51

Also the R120 build is quite old, so not all current features may be present.

xmenne
Normal user
Posts: 6
Joined: 17 Jul 2019, 17:38
Location: Saint Ouen sur Loire France

Re: How to command ESPEASY GPIO thru MQTT Mosquitto

#4 Post by xmenne » 06 Mar 2020, 12:57

Hello Thanks,
I uploaded latest version ESP EASY mega.
This is a big change and i will need time to discover the field of possible with this version.
May be i will find a way to avoid HTTP command to adress the GPIO with this Mega version
Need time as this is not my first activity :)
Thanks again
Signed XMenne from France

User avatar
dynamicdave
Normal user
Posts: 214
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: How to command ESPEASY GPIO thru MQTT Mosquitto

#5 Post by dynamicdave » 06 Mar 2020, 15:12

What I do in Node-RED is to use a MQTT-Out node (running Mosquitto) which is set-up with the IP address of your server
then set-up the topic in the MQTT-Out.

Something like... nodeXX/gpio/14
Where nodeXX is the 'Unit Name' as used in the ESP-Easy Config tab.

14 relates to the GPIO pin, which in this case is D5.

Pin mappings are...
D8 GPIO-15
D7 GPIO-13
D6 GPIO-12
D5 GPIO-14

I have about 40 Wemos D1 Mini devices and each one has a fixed IP address, like 192.168.1.41
So I name the Wemos D1 Mini with 'node41' and stick a label on the botton of the breadboard.
This means it's easy to workout the IP address when I pick-up a breadboard.

The Controller Subscribe setting in ESP-Easy looks like this... %sysname%/#
This means the Wemos named 'node41' will subscribe to... node41/#

To test it out (using Node-RED) you could connect an Inject node to the MQTT-Out node.
Set the Inject node to output a payload of a numeric value - either a 1 or 0 to operate the GPIO pin.

Hope this works for you.

xmenne
Normal user
Posts: 6
Joined: 17 Jul 2019, 17:38
Location: Saint Ouen sur Loire France

Re: How to command ESPEASY GPIO thru MQTT Mosquitto

#6 Post by xmenne » 10 Mar 2020, 19:19

Hello
Many thanks, you open my mind to new path to solution and it works now

What I did for the record

I updated ESP with ESPEasy Mega version
I discovered the new function MQTT Import
I create a new Device Generic MQTT import
Name = Task Name >> RelaisChevret
MQTT Topic1 >> domoticz/out/ESP11_Relai1
andValue Name >> Relai1

When you publish on your Broker
mosquitto_pub -t domoticz/out/ESP11_Relai1 m 1

Then your Device Value Relai1 is 1

After that I created Rules (also new for me)
On RelaisChevret#Relai1=1 do
GPIO,12,1
end on

and it works and this close this post I suppose.
I now have to work on Domoticz but it is another story.

Many thanks to you all , this forum is very helpful.
Hope i can help some one one day in return .
Signed XMenne from France

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests