Use IR control to control usermod

I’d like to set IR controller to enable and disable PIR sensor.

But I don’t know how to deal with variables from usermod_PIR_sensor_switch.h, maybe I’m too noob for this.

Thank you for your attention!

I know that it supports JSON, I tested on terminal

curl -d "{"PIRenabled":"false"}" -H "Content-Type: application/json" -X POST http://webserverip/json/state

so I tried different ways to write the JSON post on ir.cpp:

void decodeIR24(uint32_t code)
switch (code) {
case IR24_ON : bri = briLast; server.on("/json/state", HTTP_GET, [](AsyncWebServerRequest *request){request->send(200, "application/json", "{\"PIRenabled\":\"false\"}");}); break;

but I couldn’t figure out the right way.

Are you trying to get WLED to send itself a JSON message, then act on it?

Yeah, exactly, I’m trying to make the IR receiver send a JSON message.

I supposed that’s a work-around.

I think you have to send it to an IP address. I do not know the server.on() parameters, but if the [] is where the remote host is supposed to go, you can try (local host echo which is may not be supported), or the actual IP of the device itself.

Inside the usermod, there is a call back, something like “setup after wifi is connected”, where you can get the IP address of that WLED device. Look through the wled source for the variable / array which has the current IP address.

Yeah… I tried a bunch of options, but I didn’t get anything.

Also tried a more direct approach:

#include "usermod_PIR_sensor_switch.h"
case IR24_ON : bri = briLast; m_PIRenabled = false; break;

but I got stuck in this error:

wled00\ir.cpp: In function 'void decodeIR24(uint32_t)':
wled00\ir.cpp:197:51: error: 'm_PIRenabled' was not declared in this scope

Now, I’m trying another way of usermod_PIR_sensor_switch.h listen to IR changes, including UDP notifications.