Hi,
what I am trying to do:
I want to have a UI-Switch for activating or deactivating the sending of messages via Telegram.
Scenario:
Switch is deactivated: Someone turns the light on or off = I dont receive a message
Switch is activated: Someone turns the light on or off = I recieve a message via Telefgram with the message "Light is on" or "Light is off"
What I have done / what I have
- TelegramBot Bothfather
- Dashboard UI switch
- Philips Hue Light node
Debug:
Philips Hue Light
On
msg.payload : Object
object
on: true
brightness: 100
brightnessLevel: 254
reachable: true
updated: "2021-03-19T08:59:04+00:00"
Off
msg.payload : Object
object
on: false
brightness: 100
brightnessLevel: 254
reachable: true
updated: "2021-03-19T08:59:54+00:00"
Function-Node
if (msg.payload.on == true && msg.payload == on) {
msg.payload.chatId = private
msg.payload.type = "message"
msg.payload.content = "Light is on";
}
else if (msg.payload.on == false && msg.payload == on) {
msg.payload.chatId = private
msg.payload.type = "message"
msg.payload.content = "Light is off";
}
return msg;
Debug of the function-Node
If I set UI-Switch to "on"
function : (error)
"ReferenceError: on is not defined (line 2, col 46)"
and "off"
function : (error)
"ReferenceError: on is not defined (line 7, col 52)"