Albert3
(Albert)
1
I have a NodeRed flow for all my doors/windows so if one is open and we are not home, a message is pushed to out iPhones.
This is what I have:
{
"title": "Security",
"message": "A door was opened",
"data": {
"subtitle": "Doors",
"push": {
"sound": "alarm.caf"
}
}
}
I know that the msg includes the specific door/window:
object
topic: "binary_sensor.s_kitchen_2nd_door_contact"
payload: "on"
How can I include the specific door? “kitchen_2nd” in the message?
Thanks,
Hellis81
(Hellis81)
2
{
"title": "Security",
"message": msg.topic & " was opened",
"data": {
"subtitle": "Doors",
"push": {
"sound": "alarm.caf"
}
}
}
or perhaps a bit nicer:
{
"title": "Security",
"message": msg.topic.replace("binary_sensor.", "").replace("_contact", "") & " was opened",
"data": {
"subtitle": "Doors",
"push": {
"sound": "alarm.caf"
}
}
}
Which should return s_kitchen_2nd_door was opened
.
But perhaps this does not work with your naming convention?
Albert3
(Albert)
3
Thank you! it works great!!! I only had to add a $ before the replace.