Skip to content

Can anyone provide an example of JSON formatting expected in node-red for calling services? #1314

Answered by jerblack
jerblack asked this question in Q&A
Discussion options

You must be logged in to vote

Never mind, I figure it out with help from this issue:
AYapejian/node-red-contrib-home-assistant#59
I ended up with an empty Call Service node with {} in the Data field and this in the Function Node

const newTemp = msg.data.new_state.attributes.temperature
const oldTemp = msg.data.old_state.attributes.temperature

if (newTemp !== oldTemp && newTemp >= 60) {
    msg.payload = {
        domain: "notify",
        service: "alexa_media_living_room_echo",
        data: {
            message: "it is "+ newTemp +" degrees",
            data: {
              type: "tts"
        }
      }
    }
    node.send(msg);
}


return ;

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jerblack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant