Skip to content

Instantly share code, notes, and snippets.

@MorningZ
Created February 12, 2021 01:47
Show Gist options
  • Save MorningZ/76d914c24b6bffa14cc90a51f84d6638 to your computer and use it in GitHub Desktop.
Save MorningZ/76d914c24b6bffa14cc90a51f84d6638 to your computer and use it in GitHub Desktop.
Node-RED flow to send notification with image to Home Assistant
/******* DO NOT COPY THIS COMMENT PART ********
It is so hard to find dynamically built JSON payloads to make
Home Assistant Call Service calls. After watching this video
where he has things pretty much hard coded I thought I'd put
together this little flow to show the structure needed to build
the payload to pass into a Call Service node. The "data.data"
property was a hanging point for me, but this works.
Reference:
https://www.youtube.com/watch?v=W11VXmSTYSM
***********************************************/
[
{
"id": "dade90c6.e239a",
"type": "inject",
"z": "d9259d.bae46a6",
"name": "Test Message",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"domain\":\"notify\",\"service\":\"mobile_app_device_identifier\",\"data\":{\"title\":\"Driveway Motion\",\"message\":\"Car pulled into driveway\",\"data\":{\"attachment\":{\"content-type\":\"jpeg\",\"url\":\"https://yournabusubdomainname.ui.nabu.casa/local/snapshots/driveway.jpg\"}}}}",
"payloadType": "json",
"x": 750,
"y": 240,
"wires": [
[
"f19ab618.364288"
]
]
},
{
"id": "f19ab618.364288",
"type": "api-call-service",
"z": "d9259d.bae46a6",
"name": "Home Assistant Call",
"server": "108ce91c.7d67a7",
"version": 1,
"debugenabled": false,
"service_domain": "{{payload.domain}}",
"service": "{{payload.service}}",
"entityId": "",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 960,
"y": 240,
"wires": [
[]
]
},
{
"id": "108ce91c.7d67a7",
"type": "server",
"name": "Home Assistant Instance",
"legacy": false,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment