Hi,
I'm trying to build up a logic to control my ventilator.
Only one of the four switches can be active at one time. So I'm trying to send the message to activate/deactivate the relays with a function.
var L1_on = msg.payload.On === true;
var L1_off = {payload:"stufe1"};
var L2_on = {payload:"stufe2"};
var L2_off = {payload:"stufe2"};
var L3_on = {payload:"stufe3"};
var L3_off = {payload:"stufe3"};
var L4_on = {payload:"stufe4"};
var L4_off = {payload:"stufe4"};
var topic=msg.topic;
if (topic=="stufe1"){
if(msg.payload.On == true){
return L1_on;
}
} else if (topic=="stufe2"){
if(msg.payload.On == true){
return L2_on;
}
} else if (topic=="stufe3"){
if(msg.payload.On == true){
return L3_on;
}
} else if (topic=="stufe4"){
if(msg.payload.On == true){
return L4_on;
}
}
It would help a lot, if the vars contain the corresponding messages so I can send them as bulk.
I.e.
return [L1_on, L2_off, L3_off, L4_off]
if button 1 is pressed or
return [L1_off, L2_on, L3_off, L4_off]
if button 2 is pressed and so on.
How can I assign the variables a bool message as objects?
I attached a picture of the message I want to store in var L1_on.
I tried var L1_on = msg.payload.On === true;
but this ends up in an error (Function tried to send a message of type boolean).
Thank you very much!