Page 1 of 1

Controll a relay using cmd and gpio from Node Red

Posted: 14 Jul 2021, 20:22
by ulfh2018
I have configured EspEasy on a generic ESP8266 card, and want to use Node Red and MQTT to switch a relay of an on.

I have set up the following in EspEasy:

Unit Name: Realy_Meaco
Unit Number 1

Controller Domoticz MQTT

Controller Subscribe: Relay_Meaco_1/#
Controller Publsih: Relay_Meaco_in

Devices: Input Switch at GPIO 12

Running GPIO,12,1 and GPIO,12,0 from the command line in EspEasy turns the swithc of an on, and sends information about this back to Node Red via RalayMeaco/in

In Node red I use Mqtt in and Mqtt out to comunicate with EspEasy:

Mqtt in: Topic: Relay_Meaco_1/in

Mqtt out: Topic: Relay_Meaco_1/cmd

I have two injection nodes trying to send the following: gpio,12,1 and gpio,12,0 to Mqtt out, but nothing happens. If I manually run the commands from the comman consoll in EspEasy, Mqtt in will report back the result.

I am sure there is something I have missed, because I had this up and running two weeks ago, but I blew the Esp8266, so I am no using another, and I cannot remember exactly how I didi it.

All the best from

Ulf

Re: Controll a relay using cmd and gpio from Node Red

Posted: 14 Jul 2021, 23:27
by TD-er
Domoticz MQTT + switch...
So my Pavlov reply is to link to this part of the documentation: https://espeasy.readthedocs.io/en/lates ... #p029-page

Have you followed those steps?

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 01:06
by ulfh2018
Thank you so much for the suggestion, but this is not the way I made it work a few weeks ago, and the solution you provide is much more complicated. I did not use rules, I just sent the command GPIO,12,1 but there must be something wrong with my syntax, since nothing happens.

Best regards

Ulf

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 11:02
by TD-er
Are you sure you used the Domoticz MQTT controller?
When using the "cmd" syntax in topics, I think you used the OpenHAB controller.

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 12:05
by ulfh2018
Yes, absolutely sure. Recon there is something wrong with the settings on the ESP8266, since I had no problems making it work using Tasmota, but I would rather use EspEasy

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 12:29
by TD-er
The Domoticz MQTT controller does not look at the topic ending with "cmd"
That's the OpenHAB MQTT controller.

If you don't use Domoticz, I guess using the OpenHAB MQTT controller is a bit more flexible as it does allow for some more (not very elaborate though) commands via MQTT.

What is configured in Node Red to publish to that topic?
Maybe depending on the syntax of the exact message we can determine which controller you probably used and also if you're missing something.

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 16:17
by ulfh2018
I think we might be talking past each other.

My MQTT broker is Mosquitto, running on a Raspberry pi, and I am chosing Domoticz Mosquitto on ESPEasy. I will try to use one of the other options, and see if that changes the result.

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 16:43
by ulfh2018
I owe TD-er a beer! Changed to OpenHAB, and worked stright out of the box!

Thank you so much!

All the best from

Ulf

Re: Controll a relay using cmd and gpio from Node Red

Posted: 15 Jul 2021, 21:55
by TD-er
Cheers! ;)