Hi.
I've bought a Sonoff NSPanel and successfully flashed it with Tasmota.
I'm trying to understand how the interface works.
I edited the
nspanel.be to understand how it works, and changed the first widget group to "Lamp". I want to link that widget on the NSPanel to a lamp in my lounge on a Sonoff S20 running Tasmota (topic cmnd/basica/POWER). So, when I toggle the widget on the panel, the lamp toggles.
When I toggle the widget on the NSPanel I get :
23:51:22.811 MQT: tele/nspanel/RESULT = {"NSPanel":{"ctype":"group","id":"1","params":{"switch":"on","switches":[{"switch":"on","outlet":0}]}}}
23:51:44.011 MQT: tele/nspanel/RESULT = {"NSPanel":{"ctype":"group","id":"1","params":{"switch":"off","switches":[{"switch":"off","outlet":0}]}}}
What is the best way to link this to the lamp via MQTT? I assume two options; a berry script on the NSPanel or a flow in NodeRed?
How do I easily decode the "RESULT" message in NodeRed? Is the best way to write a function?
This works, but I dont think its the right way?
nsp = msg.payload["NSPanel"]
p = msg.payload["NSPanel"].params
node.warn(nsp);
node.warn(p);
if(nsp.ctype=="group"){
if(
nsp.id==1){
node.warn("G1");
msg.topic="cmnd/basica/POWER"
node.warn(p.switch)
if(p.switch=="on"){
msg.payload="ON"
}
if(p.switch=="off"){
msg.payload="OFF"
}
}
}
return msg;
Any pointers gratefully received.
Thanks
Jon.