I am building a simple automation with some Aqara water leakage sensors. I would want to be noticed on my phone if there is a water leakage.
Enough easy… I deployed one events: state node for each water sensor connected to a call service node which calls the ios notify service.
I would like now use just one call service node which receives a message to use in the data field.
So I thought to use a chain like this:
Sorry, that example was using the latest version of node-red-contrib-home-assistant-websocket. I would recommend updating that to that but if you choose not to you can use a template node before the call-service node.
In the end I did what I was looking for like this (which is exactly as you suggested):
var message = "The next bin collection is" + context.global.daysbin + context.global.nextbin + " and is the " + context.global.bin
msg.payload = {
"data": {message}
}
return msg
I then pass it to the JSON node then on to the Alexa tts. Works a treat.
Basically I have a dummy switch in HA that I toggle via an Alexa routine “What bin collection is it this week”. I have a node listening to the mqtt in Node Red that then triggers the TTS and iOS notification, so I get a response like “The next bin collection is tomorrow, Friday 28th December and is the black bin - landfill”
Just trying now to work out if I can get Alexa to answer from the device I asked the routine from, rather than broadcast the response all over the house.
I can’t remember who but I helped someone the other day who was using a script to get the name of the last Alexa device used and passing that to the call-service node basically the same thing that you’re trying to achieve.
Thanks, this suggestion worked great for me. I’m not using temples, I just went into the JSON data section of the call service and added the json below. In the code payload.process represents the process that is not responding.
{
"data": {
"badge": 5,
"push": null
},
"message": "{{payload.process}} is down, please investigate",
"title": "Node Red System Alert"
}