Skip to content

Instantly share code, notes, and snippets.

@martenjacobs
Created July 10, 2022 11:36
Show Gist options
  • Save martenjacobs/3794a546e34e5b8990b72f619d9a02b4 to your computer and use it in GitHub Desktop.
Save martenjacobs/3794a546e34e5b8990b72f619d9a02b4 to your computer and use it in GitHub Desktop.
NodeRED flow to show live camera stream from Home Assistant on NodeRED Dashboard
[
{
"id": "18ba589599062bca",
"type": "ui_template",
"z": "a9e188856305ac06",
"group": "da3f48b5.d98ca8",
"name": "",
"order": 17,
"width": 18,
"height": 10,
"format": "<div style=\"overflow:hidden;\">\n <script src=\"https://vjs.zencdn.net/7.2.3/video.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.14.1/videojs-contrib-hls.js\"></script>\n \n <div id=\"babyfoon\">\n <div class=\"source-url\" style=\"display:none;\">\n http://10.0.1.10:8123{{msg.payload}}\n </div>\n <video class=\"target\" style=\"width:100%;height:100%;\"></video>\n </div>\n <script>\n (()=>{\n var elem = document.querySelector(\"#babyfoon\");\n if(!elem) return;\n var sourceUrlElem = elem.querySelector(\".source-url\");\n var targetElem = elem.querySelector(\".target\");\n if(!sourceUrlElem || !targetElem) return;\n var sourceUrl = null;\n var player = videojs(targetElem);\n const update=()=>{\n console.log(sourceUrl);\n player.src({\n src: sourceUrl,\n type: 'application/x-mpegURL'\n });\n \n player.play();\n };\n const check=()=>{\n const newSourceUrl = sourceUrlElem.innerText.trim()\n if(newSourceUrl !== sourceUrl){\n sourceUrl = newSourceUrl;\n update();\n }\n };\n setInterval(check, 500);\n })();\n </script>\n</div>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 540,
"y": 200,
"wires": [
[]
]
},
{
"id": "51601dd7066d904a",
"type": "ha-api",
"z": "a9e188856305ac06",
"name": "",
"server": "5e068ccc.ae6f34",
"version": 1,
"debugenabled": false,
"protocol": "websocket",
"method": "get",
"path": "",
"data": "payload",
"dataType": "jsonata",
"responseType": "json",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "results"
}
],
"x": 310,
"y": 240,
"wires": [
[
"6d03d6b82851ba70"
]
]
},
{
"id": "86f396d4135181b5",
"type": "inject",
"z": "a9e188856305ac06",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"type\":\"camera/stream\",\"entity_id\":\"camera.my_camera\"}",
"payloadType": "json",
"x": 190,
"y": 240,
"wires": [
[
"51601dd7066d904a"
]
]
},
{
"id": "a1411dfc2bef0e1e",
"type": "debug",
"z": "a9e188856305ac06",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 530,
"y": 240,
"wires": []
},
{
"id": "1662f7e816d30704",
"type": "rbe",
"z": "a9e188856305ac06",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 390,
"y": 200,
"wires": [
[
"a1411dfc2bef0e1e",
"18ba589599062bca"
]
]
},
{
"id": "6d03d6b82851ba70",
"type": "change",
"z": "a9e188856305ac06",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.url",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 220,
"y": 200,
"wires": [
[
"1662f7e816d30704"
]
]
},
{
"id": "375d7ec8c24446dc",
"type": "inject",
"z": "a9e188856305ac06",
"name": "reset",
"props": [
{
"p": "reset",
"v": "true",
"vt": "bool"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 190,
"y": 160,
"wires": [
[
"1662f7e816d30704"
]
]
},
{
"id": "da3f48b5.d98ca8",
"type": "ui_group",
"name": "WallFrame",
"tab": "f4a10774.2e4aa8",
"order": 1,
"disp": false,
"width": "18",
"collapse": false
},
{
"id": "5e068ccc.ae6f34",
"type": "server",
"name": "Home Assistant"
},
{
"id": "f4a10774.2e4aa8",
"type": "ui_tab",
"name": "Home",
"icon": "home",
"order": 2,
"disabled": false,
"hidden": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment