Node-RED controlled Hyperion

Due to the high CPU usage of Hyperion when processing the usb capture unit, I only use it for sources that don’t allow for screen capture within the android box using the Android Grabber app. As I needed a way to change it automatically, I created a flow in Node-RED that checks which app is playing and selects the correct source for Hyperion. It also stops and starts Hyperion based on playing/idle status of the media.

Hyperion Flow

The above picture shows the entire flow, which I’m now going to explain in detail.

The first node is a HomeAssistant ‘state node’, which allows me to get the status of my Nvidia Shield. That info goes to a ‘switch node’ that creates a different output for each status.

If the status is other than ‘playing’, Hyperion turns off after 30 seconds (defined in the green timer). If it’s playing, and depending on the time condition, it starts the WLED and Hyperion.

At this stage, it will check the source app and if it’s Plex or Youtube it deactivates the usb capture and will use the info from the Android Grabber app. If it’s using an app like Netflix it will turn the USB capture on.

Here’s the complete flow:

[{"id":"1a80ca9e.94dd45","type":"tab","label":"hyperion","disabled":false,"info":""},{"id":"48849958.8ab3a8","type":"server-state-changed","z":"1a80ca9e.94dd45","name":"Shield Sala Status","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.living_room_nvidia_shield","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":160,"wires":[["34cb201b.bfdfa"]]},{"id":"9f0a9c7b.2c255","type":"api-call-service","z":"1a80ca9e.94dd45","name":"wld-pwr-off","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.smart_plug_mss310_main_channel_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":120,"wires":[["23916314.5bb69c"]]},{"id":"a028c2a3.98cbd","type":"api-call-service","z":"1a80ca9e.94dd45","name":"wld-pwr-on","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.smart_plug_mss310_main_channel_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":200,"wires":[["7ee75f85.cda98"]]},{"id":"cff7cba0.808048","type":"api-call-service","z":"1a80ca9e.94dd45","name":"hyperion-on","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"light.wled_tv","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":200,"wires":[["27fc772c.b1d998"]]},{"id":"7ee75f85.cda98","type":"delay","z":"1a80ca9e.94dd45","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":740,"y":200,"wires":[["cff7cba0.808048"]]},{"id":"34cb201b.bfdfa","type":"switch","z":"1a80ca9e.94dd45","name":"status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"running","vt":"str"},{"t":"eq","v":"playing","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":350,"y":140,"wires":[["65ea9253.3b7f3c"],["65ea9253.3b7f3c"],["9f0a9c7b.2c255"],["9f0a9c7b.2c255"],["d015ba3.16baf48","173a3680.8d2c5a"]]},{"id":"65ea9253.3b7f3c","type":"stoptimer","z":"1a80ca9e.94dd45","duration":"30","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":590,"y":120,"wires":[["9f0a9c7b.2c255"],[]]},{"id":"d015ba3.16baf48","type":"change","z":"1a80ca9e.94dd45","name":"Stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":160,"wires":[["65ea9253.3b7f3c"]]},{"id":"27fc772c.b1d998","type":"switch","z":"1a80ca9e.94dd45","name":"Source","property":"data.old_state.attributes.app_name","propertyType":"msg","rules":[{"t":"eq","v":"YouTube","vt":"str"},{"t":"eq","v":"Plex","vt":"str"},{"t":"eq","v":"Netflix","vt":"str"},{"t":"eq","v":"Disney+","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":360,"y":300,"wires":[["23916314.5bb69c"],["23916314.5bb69c"],["26b1b683.7fe9da"],["26b1b683.7fe9da"]]},{"id":"26b1b683.7fe9da","type":"api-call-service","z":"1a80ca9e.94dd45","name":"hyperion VL4","server":"","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.wled_tv","data":"{\"effect\":\"V4L\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":300,"wires":[[]]},{"id":"23916314.5bb69c","type":"api-call-service","z":"1a80ca9e.94dd45","name":"hyperion APP","server":"","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.wled_tv","data":"{\"effect\":\"GRABBER\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":260,"wires":[[]]},{"id":"173a3680.8d2c5a","type":"time-range-switch","z":"1a80ca9e.94dd45","name":"","lat":"","lon":"","startTime":"12:00","endTime":"08:00","startOffset":0,"endOffset":0,"x":380,"y":220,"wires":[["a028c2a3.98cbd"],[]]}]

Leave a comment

Your email address will not be published. Required fields are marked *