Skip to content

Instantly share code, notes, and snippets.

@frosenlind
Created December 11, 2020 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frosenlind/c3bf7c98fe8a1dbb7245ccef5a8db60b to your computer and use it in GitHub Desktop.
Save frosenlind/c3bf7c98fe8a1dbb7245ccef5a8db60b to your computer and use it in GitHub Desktop.
Node-Red, subflow, trigger custom_event
[
{
"id": "8d17ee2d.e3013",
"type": "subflow",
"name": "Trigger custom_event NEW",
"info": "> This subflow is from www.frosenlind.se\n\nAll input to msg.payload is piped to msg.throughput\n\nFires an event called custom_event\n\n## Output\nEvent type: msg.paayload.event = custom_event\n\nmsg.payload.data.event_id\n\nmsg.payload.data.sub_id\n\nmsg.payload.data = your data from data input field",
"category": "",
"in": [
{
"x": 160,
"y": 120,
"wires": [
{
"id": "175540b9.57e46f"
}
]
}
],
"out": [
{
"x": 780,
"y": 120,
"wires": [
{
"id": "69b71e5d.47a22",
"port": 0
}
]
}
],
"env": [
{
"name": "CUSTOM_EVENT_ID",
"type": "str",
"value": "",
"ui": {
"icon": "font-awesome/fa-angle-right",
"label": {
"en-US": "Event ID"
},
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "CUSTOM_EVENT_SUB_ID",
"type": "str",
"value": "",
"ui": {
"icon": "font-awesome/fa-angle-double-right",
"label": {
"en-US": "Sub ID"
},
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "DATA",
"type": "json",
"value": "{}",
"ui": {
"icon": "font-awesome/fa-graduation-cap",
"type": "input",
"opts": {
"types": [
"json"
]
}
}
}
],
"color": "#FDD0A2",
"icon": "font-awesome/fa-arrow-up"
},
{
"id": "69b71e5d.47a22",
"type": "ha-fire-event",
"z": "8d17ee2d.e3013",
"name": "Trigger custom_event",
"server": "b6162a50.c4af78",
"event": "custom_event",
"data": "",
"dataType": "json",
"x": 600,
"y": 120,
"wires": [
[]
]
},
{
"id": "175540b9.57e46f",
"type": "change",
"z": "8d17ee2d.e3013",
"name": "",
"rules": [
{
"t": "set",
"p": "throughput",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "payload",
"pt": "msg"
},
{
"t": "set",
"p": "payload.data",
"pt": "msg",
"to": "DATA",
"tot": "env"
},
{
"t": "set",
"p": "payload.data.event_id",
"pt": "msg",
"to": "CUSTOM_EVENT_ID",
"tot": "env"
},
{
"t": "set",
"p": "payload.data.sub_id",
"pt": "msg",
"to": "CUSTOM_EVENT_SUB_ID",
"tot": "env"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 340,
"y": 120,
"wires": [
[
"69b71e5d.47a22"
]
]
},
{
"id": "b6162a50.c4af78",
"type": "server",
"name": "Home Assistant - New",
"legacy": false,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
},
{
"id": "ac7f4e8b.3ff6b",
"type": "subflow:8d17ee2d.e3013",
"z": "65c6e443.16a6fc",
"name": "frosenlind.se Trigger custom_event",
"env": [
{
"name": "CUSTOM_EVENT_ID",
"value": "My test event",
"type": "str"
},
{
"name": "CUSTOM_EVENT_SUB_ID",
"value": "My sub ID",
"type": "str"
},
{
"name": "DATA",
"value": "{\"mydata\":\"information is king\"}",
"type": "json"
}
],
"x": 590,
"y": 800,
"wires": [
[
"ae6896f.4db6368"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment