[Setup Help]: Split input from output
See original GitHub issueTrying to setup Television Service to make my own improved AppleTV implementation in HomeKit, using the scripts provided by pyatv (https://pyatv.dev), the exec node and NRCHKB.
Help Needed This may just be me missing something obvious, but is it possible some way to “separate” input and output?
My issue is that my flow ends up being “circular”. When I turn off the ATV from the remote, the atvscript updates the HomeKit status which in turn triggers the turn off command, which powers the ATV back on (because the turn on command includes virtually pressing the top-menu button).
What I would like was for input to the node to update the status in HomeKit, but not send any output when doing so. I can help shake the felling that I am missing something obvious.
Current Flow
[{"id":"82710845.7e98e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a6b96c5f.98d4a8","type":"exec","z":"82710845.7e98e","command":"","addpay":true,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"ATV Stue Push playstate","x":490,"y":280,"wires":[["bce4a91a.f1c868"],[],[]]},{"id":"335055b3.200cda","type":"inject","z":"82710845.7e98e","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":260,"wires":[["50eaf43e.d5226c"]]},{"id":"dcd4f8f3.d5e9e8","type":"inject","z":"82710845.7e98e","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":300,"wires":[["50eaf43e.d5226c"]]},{"id":"50eaf43e.d5226c","type":"function","z":"82710845.7e98e","name":"","func":"if(msg.payload == \"on\"){\n //msg.payload = \"atvremote -i 90:DD:5D:B8:4C:EB --mrp-credentials c4058ac42d62c90246b32fc416352bb654da65e852dd93f8260123d639bc3968:0b5b3c8d1cf06ac2f6afaf59a5dd7d6b61a2e22d954d3551bbb75aefc977807e:30633732366433332d303430372d343033642d383833632d316563313066656266323431:31313933386430312d633965352d343963332d396365652d643665333566623932613665 push_updates\";\n msg.payload = \"/home/pi/.local/bin/atvscript -s 192.168.0.85 push_updates\";\nreturn msg;\n}\nif(msg.payload == \"off\"){\n msg.kill = 'SIGTERM';\nreturn msg;\n}\n\n//-i 90:DD:5D:B8:4C:EB --mrp-credentials c4058ac42d62c90246b32fc416352bb654da65e852dd93f8260123d639bc3968:0b5b3c8d1cf06ac2f6afaf59a5dd7d6b61a2e22d954d3551bbb75aefc977807e:30633732366433332d303430372d343033642d383833632d316563313066656266323431:31313933386430312d633965352d343963332d396365652d643665333566623932613665","outputs":1,"noerr":0,"x":290,"y":280,"wires":[["a6b96c5f.98d4a8"]]},{"id":"db45d2d9.26f128","type":"debug","z":"82710845.7e98e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":340,"wires":[]},{"id":"bce4a91a.f1c868","type":"json","z":"82710845.7e98e","name":"","property":"payload","action":"","pretty":false,"x":690,"y":280,"wires":[["db45d2d9.26f128","d8559685.49cba","90e6e814.e17aa8"]]},{"id":"55165bba.477a74","type":"exec","z":"82710845.7e98e","command":"/home/pi/.local/bin/atvremote -s 192.168.0.85 ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"ATV Stue Commands","x":1760,"y":280,"wires":[[],[],[]]},{"id":"13fbbd7f.7c86bb","type":"debug","z":"82710845.7e98e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1230,"y":340,"wires":[]},{"id":"f50ded7b.4dd588","type":"inject","z":"82710845.7e98e","name":"AppleTV","topic":"","payload":"{\"Identifier\":1,\"Name\":\"AppleTV\",\"ConfiguredName\":\"AppleTV\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1300,"y":560,"wires":[["bf312133.47f358"]]},{"id":"a018ad8c.94b4f8","type":"inject","z":"82710845.7e98e","name":"Netflix","topic":"","payload":"{\"Identifier\":3,\"Name\":\"Netflix\",\"ConfiguredName\":\"Netflix\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1290,"y":640,"wires":[["580fda8d.2ac41c"]]},{"id":"7cdfe10b.dc4d","type":"inject","z":"82710845.7e98e","name":"HBO","topic":"","payload":"{\"Identifier\":4,\"Name\":\"HBO\",\"ConfiguredName\":\"HBO\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1290,"y":680,"wires":[["54cafe1b.74721"]]},{"id":"1ec26416.5422bc","type":"switch","z":"82710845.7e98e","name":"Power","property":"payload.Active","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1390,"y":280,"wires":[["20c0c3a3.cc9cbc"],["1eaf3704.2629f9"]]},{"id":"20c0c3a3.cc9cbc","type":"change","z":"82710845.7e98e","name":"Tænd","rules":[{"t":"set","p":"payload","pt":"msg","to":"turn_on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1530,"y":260,"wires":[["55165bba.477a74"]]},{"id":"1eaf3704.2629f9","type":"change","z":"82710845.7e98e","name":"Sluk","rules":[{"t":"set","p":"payload","pt":"msg","to":"menu delay=1000 top_menu delay=1000 turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1530,"y":300,"wires":[["55165bba.477a74"]]},{"id":"d8559685.49cba","type":"switch","z":"82710845.7e98e","name":"Power","property":"payload.power_state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":220,"wires":[["5169bbb3.4eafbc"],["bb5d2502.a6993"]]},{"id":"5169bbb3.4eafbc","type":"change","z":"82710845.7e98e","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"Active\":1}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":200,"wires":[["92d6eb49.ace628"]]},{"id":"bb5d2502.a6993","type":"change","z":"82710845.7e98e","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"Active\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":240,"wires":[["92d6eb49.ace628"]]},{"id":"90e6e814.e17aa8","type":"switch","z":"82710845.7e98e","name":"App","property":"payload.app_id","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"","vt":"str"},{"t":"eq","v":"dk.tv2.play","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":830,"y":320,"wires":[["5af94a61.22f274"],["69a08638.1fe6b8"],["270d6325.0e75f4"],["1cba52c6.3a17c5"],["82b937cc.61ab8"],["b3a383a4.e724a8"]]},{"id":"69a08638.1fe6b8","type":"change","z":"82710845.7e98e","name":"AppleTV","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":320,"wires":[["92d6eb49.ace628"]]},{"id":"b3a383a4.e724a8","type":"change","z":"82710845.7e98e","name":"TV2Play","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":480,"wires":[["92d6eb49.ace628"]]},{"id":"b0c82182.5aad9","type":"inject","z":"82710845.7e98e","name":"TV2Play","topic":"","payload":"{\"Identifier\":5,\"Name\":\"TV2Play\",\"ConfiguredName\":\"TV2Play\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1300,"y":720,"wires":[["b62241a0.0945b"]]},{"id":"30ef671d.4e82e8","type":"inject","z":"82710845.7e98e","name":"DRTV","topic":"","payload":"{\"Identifier\":0,\"Name\":\"DRTV\",\"ConfiguredName\":\"DRTV\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1290,"y":520,"wires":[["2e6c2e16.7fa302"]]},{"id":"c313354d.bf67e8","type":"inject","z":"82710845.7e98e","name":"Disney+","topic":"","payload":"{\"Identifier\":2,\"Name\":\"Disney+\",\"ConfiguredName\":\"Disney+\",\"InputSourceType\":\"APPLICATION\",\"IsConfigured\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1300,"y":600,"wires":[["7fb4968.c7f9568"]]},{"id":"92d6eb49.ace628","type":"homekit-service","z":"82710845.7e98e","isParent":true,"bridge":"8cc46e3.16aa49","parentService":"","name":"AppleTV 4K","serviceName":"Television","topic":"","filter":false,"manufacturer":"Apple","model":"AppleTV 4K","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1230,"y":280,"wires":[["1ec26416.5422bc","13fbbd7f.7c86bb"],[]]},{"id":"2e6c2e16.7fa302","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 0","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":520,"wires":[[],[]]},{"id":"bf312133.47f358","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 1","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":560,"wires":[[],[]]},{"id":"7fb4968.c7f9568","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 2","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":600,"wires":[[],[]]},{"id":"580fda8d.2ac41c","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 3","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":640,"wires":[[],[]]},{"id":"54cafe1b.74721","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 4","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":680,"wires":[[],[]]},{"id":"b62241a0.0945b","type":"homekit-service","z":"82710845.7e98e","isParent":false,"bridge":"","parentService":"f57fc1ed.f37928","name":"Input 5","serviceName":"InputSource","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":1460,"y":720,"wires":[[],[]]},{"id":"5af94a61.22f274","type":"change","z":"82710845.7e98e","name":"DRTV","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":280,"wires":[[]]},{"id":"270d6325.0e75f4","type":"change","z":"82710845.7e98e","name":"Disney+","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":360,"wires":[["92d6eb49.ace628"]]},{"id":"1cba52c6.3a17c5","type":"change","z":"82710845.7e98e","name":"Netflix","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":400,"wires":[["92d6eb49.ace628"]]},{"id":"82b937cc.61ab8","type":"change","z":"82710845.7e98e","name":"HBO","rules":[{"t":"set","p":"payload.ActiveIdentifier","pt":"msg","to":"4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":440,"wires":[["92d6eb49.ace628"]]},{"id":"a5105db0.15abf","type":"comment","z":"82710845.7e98e","name":"Start/stop pyatv script","info":"","x":180,"y":200,"wires":[]},{"id":"a2e4a652.0887f8","type":"comment","z":"82710845.7e98e","name":"Parse and split output from pyatv script","info":"","x":930,"y":140,"wires":[]},{"id":"d1fedf59.aa3ad8","type":"comment","z":"82710845.7e98e","name":"Setup inputs","info":"","x":1290,"y":480,"wires":[]},{"id":"f27bfceb.017608","type":"comment","z":"82710845.7e98e","name":"Split output to turn on/off appletv through pyatv","info":"","x":1520,"y":200,"wires":[]},{"id":"8cc46e3.16aa49","type":"homekit-bridge","z":"","bridgeName":"NodeRedBridged","pinCode":"111-11-111","port":"","allowInsecureRequest":false,"manufacturer":"NodeRed","model":"None","serialNo":"123456","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}]
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Happy to help!
There are great arguments for allowing passthrough and for disabling passthrough. I’m on the side of “mostly I keep it allowed” but I’ve written my functions to work that way…
Come back anytime! Feel free to close this issue if you’re all sorted out
Thanks guys! So there was an easy way to deal with this and it was just me who did not look hard enough. Actually I think this simplifies a couple of other scripts that I have been struggling with.
Thank you for your great work, and thanks for the feedback. Really appreciate!