Seemed easy, but my relais on a D1 mini (over GPIO5) do not switch with function code on a ESP Easy flashed device. Switching via http works perfect. Using Mqtt and Node Red, just a simple flow
inject node - function - mqtt --> the fuctionnode has the code:
var gpio_pin = 5; // = represents "D1" on a wemos d1 mini var espeasy_device_name = "ESP_Easy" var gpio_state = msg.payload; msg.topic = String(espeasy_device_name) + "/cmd"; msg.payload = "gpio," + String(gpio_pin) + "," + (gpio_state ? "1" : "0"); return msg;
With command inside the browser http://192.168.178.xxx/control?cmd=gpio,5,1 the relais is switching fine. Transfer to mqtt is also working, but no switch will released with this code. My question is, how should the function code be modified to gain a switching event. Alternatively my
second question, how to create a command for ESPEasy just to call an event, witch is f.e. declaired inside a rule. My rule declaration is:
On relaisein do GPIO,5,1 //Relais D1 On endon On relaisaus do GPIO,5,0 // Relais D1 Off endon
Help would be great, tried several things, without success.