MwC-Trexx
(Mw C Trexx)
October 17, 2018, 8:33pm
1
So I am trying to do the following:
Have 3 binary_door sensors monitored and when a door is opened or closed send a TTS to Google Say to say “The <friendly_name> was opened/closed”.
I am trying to use a data_template node to create the payload as follows:
{ “data_template”: {
“message”:“The {{trigger.to_state.attributes.friendly_name}} was opened” }
}
When I debug the template output, the {{trigger.to…}} either isn’t being evaluated or is returning a blank value.
I know I can do it more brute force method, but this seems a lot cleaner if I can get it working.
Kermit
October 18, 2018, 12:18am
2
I basically use the exact same flow as you for the same purpose but use a function node instead of a template node.
Here’s my function code
const friendlyName = msg.data.new_state.attributes.friendly_name;
node.status({text: friendlyName});
return {
"payload": {
"data": {
"message": friendlyName + " opened"
}
}
};
Not saying you have to use a function node but try the same path in your template node
data.new_state.attributes.friendly_name
Edit:
That location is based off my node-red fork . If you’re using the original try payload.data.new_state.attributes.friendly_name
2 Likes
MwC-Trexx
(Mw C Trexx)
October 18, 2018, 2:09pm
3
Thanks - This worked perfectly. Now my 2 year old has no chance of sneaking out without us knowing during the day
MwC-Trexx
(Mw C Trexx)
October 18, 2018, 2:13pm
4
Here is the final Function node-red code for those interested:
const friendlyName = msg.data.new_state.attributes.friendly_name;
node.status({text: friendlyName});
return {
"payload": {
"data": {
"message": "The " + friendlyName + " was opened"
}
}
};
5 Likes
How is the “TTS Google Play” set up? I would like to adapt for Alexa
MwC-Trexx
(Mw C Trexx)
October 21, 2018, 10:24pm
6
Not sure what you mean how is it setup??
Google is enabled via HA Cloud. I have 3 different Google Home Mini’s in the house.
I just have it using the Call Service node to the TTS domain, and then the google_say service.
Eddie1974
(Eddie)
November 25, 2018, 9:00am
7
hey,
Whats the syntax you used for google tts?
oakbrad
(Oakbrad)
November 25, 2018, 5:56pm
8
Here is how I do this with a (node-red not HA) template node, for a notification if something goes offline:
🏠⚠ {{data.new_state.attributes.friendly_name}} was turned {{payload}}
In a template you refer to the values without the msg. on the front
I just set the payload since I have a function that processes notifications to some other criteria, but you can change which property in the node options. ie msg.payload.data.message
Eddie1974
(Eddie)
November 27, 2018, 9:06am
9
I use node red too.
Do you mind posting your flow and json please?
I’m trying to announce the weather, what tvshows or movies has been downloaded etc.
MwC-Trexx
(Mw C Trexx)
December 20, 2018, 3:22pm
10
I just use the following:
google_say
And payload is the text.
@MwC-Trexx thanks this helped me tonight!
Vayain
(Vayain)
October 22, 2019, 6:38pm
12
Thanks a lot! Searched for exactly this notification, thanks mate
I’m using it to monitor different lights in the house, added the state, to which the light switched.
const friendlyName = msg.data.new_state.attributes.friendly_name;
const state = msg.payload
node.status({text: friendlyName});
return {
"payload": {
"data": {
"message": friendlyName + " switched " + state
}
}
};
1 Like
Thank you both, I was planning to do exactly this but hadn’t had time to look into setting it up.
With this is only took me a few seconds to do.
Thanks again
@MwC-Trexx can you share your flow please?