Hi,
I’m trying to use Multirelay usermod in my WLED project however I encountered a problem. I’d like to use preset with JSON API commands. There is a command to turn particular relay on and off but I cannot find any command to TOGGLE a relay. There are toggle commands in HTTP API and in MQTT. Is it somehow included in JSON API? I tried several ideas but no success…
This is an example i tested a long time ago
curl -X POST "http://10.0.6.17/json/state" -d {"MultiRelay":{"relay":0,"on":true}} -H "Content-Type: application/json"
curl -X POST "http://10.0.6.17/json/state" -d {"MultiRelay":{"relay":0,"on":false}} -H "Content-Type: application/json"
Please try with {"on":"t"}
if that works for you as I no longer have the usermod nor i use it but was just testing it with another user
Works like a charm, thanks a lot!
I wouldn’t think about that syntax
Good , Might help the next guy if you could show the outcome of your toggle api but not mandatory just to pay it foreword
Hi ALDIY,
I wish I could but multirelay usermod behaves in a strange way.
Generally let’s say that I have 2 presets. They are triggered by 2 physical pushbuttons. Each of them shall (apart of other things) switch state of one of lines defined by multirelay. This works fine. There is also a third preset used to switch WLED on and off (just like power icon in top left corner. Preset needs to be defined as {"on":"t"}
- it triggers “built-in” relay functionality but it also triggers both multirelays which spoils all the logic.
Have I messed up my configuration or this is how multirelay add-on works that main power button affects it too?
I did not test buttons thoroughly and do not have any wired with wled but in the usermod there is “external” option might be try to change and test . If you face more issues then make sure you are on latest 15.0.B6 or B7 and then provide the configuration and presets you have and I will try to replicate your setup and see the interaction with button , of/off …etc
As said also I do not use a physical relay with wled but only test the behavior and response from mqtt but could also test with a physical relay if needed the same way you did
Hi.
My hardware setup is as following:
Two LED stripes connected to GPIO26 and GPIO27.
Two pushbuttons connected to GPIO13 and GPIO12.
(temporarly) Build in relay output connected to GPIO15 to control PSU enable input.
(temporarly) 4 LEDs as multirelay outputs co1. nnected between GND and GPIOs: 16, 17, 18, 19.
- Settings:
- Short button press of Button 1 triggers Preset 1 , double triggers Preset 3
Short button press of Button 2 triggers Preset 2 , double triggers Preset 3
Multirelay 0 and 1 have no delay, multirelay 2 and 3 have 5s of delay
Presets:
1:
{"seg":[{"id":0,"on":"t"}],"MultiRelay":[{"relay":0,"on":"t"},{"relay":2,"on":"t"}]}
2:
{"MultiRelay":[{"relay":1,"on":"t"},{"relay":3,"on":"t"}],"seg":[{"id":1,"on":"t"}]}
3:
{"on":"t"}
WLED was compiled from github latest source version but I can see it is 0.14.4, not the one you mention.
As I am playing with WLED while writing that, I noticed that physical buttons are not necessary. What happens is:
I begin with “standby state”, meaning WLED is off (meaning power icon is not highlided, PSU controlled by relay is off, multirelay LEDs are off).
I run Preset 3 or click Power icon, PSU turns on but at the same time, relay-0 and relay-2 turn on, 5 seconds later relay-1 and relay-3 turn on. This is not what I was expecting as there was no command to turn them on.
When I run Preset 3 again, PUS turns off, as well as relay-0 and 2, 5s later the same happens with relay-1 and 3.
Now, never mind if PSU is on or off, I try to run i.e. Preset 1 (Preset 2 behaves in the same way): when I run it, both relay-0 and relay-2 turn on or off at the same time. There is no delay as intended…
In general, what I’d like to achieve?
My setup is as below: 2 led stripes with 2 buttons to control them separately and PSU controlled from ESP32
I don’t like t o perform any specific action to control PSU (like my Preset 3 just to turn it on and off). If any of stripes should be turned on, PSU shall be turned on too, if none of them is lit, PSU shall turn off. That simple. I was advised to use multirelay and a piece of hardware like OR gate and set everything up so multirelay state shows if stripe is on or off.
In the usermod there is “external” option which i tested now and it will solve the issue you listed earlier as if you check that then wled ui power button will not trigger the relay . try that first .
Info on that is here WLED/usermods/multi_relay at 0_15 · Aircoookie/WLED · GitHub
Also 15.0.B6 source is here GitHub - Aircoookie/WLED at 0_15
Bins are here Releases · Aircoookie/WLED · GitHub
And the last CI run bins are here Merge pull request #4231 from Aircoookie/b7 · Aircoookie/WLED@af34da4 · GitHub
Thanks, I changed settings to ‘external’, works better but still there is no delay, which is also important for me. While switching off I have ‘fade off’ effect so triggering Preset 1 or 2 starts fading but without delay it would instantly switch PSU (this is why am using 2 outputs for stripe - the one without delay is to turn PSU immediatelly and with delay is to allow fade out to finish).
Is it corrected in latest version, please?
Possibly a bug , i have now also used a relay and when I set the " delay-s" in the usermod I do not see any change and it will still trigger without a delay when the api is used from MQTT .
Try to to test on B7 and if you still face an issue then file a bug in github here
This might be related to the same issue
I tried to compile B7 from source GitHub - Aircoookie/WLED at 0_15 on my machine but no go, the compilator complains about missing files: wled00/wled_server.cpp:3:21: fatal error: html_ui.h: No such file or directory
…
B7 is already on the release page but the delay-s is also ignored in that build .
You might want to start compiling on github , use this helper tool WLED Compile helper or if you must use local vsc then update it