Hi there, I did not find a proper tutorial for this yet:
I have an IR sensor that gives this json via MQTT:
zigbee2mqtt/IrSensor : msg.payload : string[104]
"{"battery":100,"illuminance":26,"illuminance_lux":26,"linkquality":102,"occupancy":false,"voltage":3035}"
depending on occupacy I want to send a telegram message, but I always get the "Alarm over" no matter how occupacy is set. I guess I use the if incorrectly. Function content:
let occupancy = msg.payload.occupancy;
let payload = {
"chatId":390475709,
"type":"message",
"content":"init"
};
if (occupancy === true) {
payload.content = "IR Alarm aktiv"
} else {
payload.content = "IR Alarm over"
}
return {payload};
How to do it right? And why? And where to learn this?