Node-red-contrib-homekit-bridged: [Setup Help]: Split input from output

Created on 27 Nov 2020  Â·  8Comments  Â·  Source: NRCHKB/node-red-contrib-homekit-bridged

Trying 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}]
help wanted

All 8 comments

Have you unchecked the box in the setup node “pass messages through to output”?

I don’t remember exactly what it’s called but something like that

Alright I was being lazy a few minutes ago, I was just going to give you that answer then go to bed.

Then I had a look at your flow and saw "atvscript" in there ... which is my favorite bit of python code. So I had to take a better look.

To answer your question, you should be able to uncheck this box:
Screen Shot 2020-11-28 at 11 54 18 PM

This is a pretty cool use of atvscript. I prefer to use it in a daemon node which keeps it running always. I'm not using it with homekit, I'm using it instead to control lights based on what the apple tv is up to.

The start of my pyatv flow, if you're interested:

[{"id":"9d0cd250.593ac","type":"ui_button","z":"7c77bf66.1f173","name":"Bed restart","group":"1ba90704.f2f459","order":1,"width":"3","height":"1","passthru":false,"label":"Bed restart","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":110,"y":140,"wires":[["78c3aa90.c26144"]]},{"id":"78c3aa90.c26144","type":"change","z":"7c77bf66.1f173","name":"sigterm","rules":[{"t":"set","p":"kill","pt":"msg","to":"SIGTERM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":140,"wires":[["1cb21dd2.bc742a"]]},{"id":"1cb21dd2.bc742a","type":"daemon","z":"7c77bf66.1f173","name":"Bed TV","command":"atvscript","args":"-s 10.11.11.2 push_updates","autorun":true,"cr":false,"redo":true,"op":"lines","closer":"SIGTERM","x":440,"y":140,"wires":[["66e251f6.355538"],[],["ec1c9ea5.b1e6d"]]},{"id":"66e251f6.355538","type":"function","z":"7c77bf66.1f173","name":"Process","func":"let InPut = JSON.parse(msg.payload);\nlet powerMsg = null;\nlet mediaMsg = null;\nlet errMsg = null;\n\nif (InPut.power_state !== undefined){\n    powerMsg = {\n        payload: InPut.power_state\n    }\n} else if (InPut.media_type !== undefined){\n    mediaMsg = {\n        payload: InPut\n    }\n} else if (InPut.result === \"failure\"){\n    errMsg = {\n        payload: InPut\n    }\n} else {\n    node.error('Error: please use a valid payload')\n    return;\n}\n\n\nreturn [powerMsg,mediaMsg,errMsg];","outputs":3,"noerr":0,"initialize":"","finalize":"","x":640,"y":140,"wires":[["d41b2e3e.82ef38","86f778d5.296a98"],["5d7f200b.d9681","86f778d5.296a98"],["12ff51b3.4d2646"]]},{"id":"1ba90704.f2f459","type":"ui_group","name":"Debug","tab":"c0f2bb5f.71ee7","order":4,"disp":true,"width":"6","collapse":false},{"id":"c0f2bb5f.71ee7","type":"ui_tab","name":"Control","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

If you have a minute I'd be interested to hear what you're building here (final goals and what not).

Hmm, I do not have that option in the node:
image

I am on the latest version according to the release overview on github (1.2.0). Am I missing out on something here?

I seem to have found a workaround, the issue for me was that for turning off the ATV I call "menu" to stop any current playback, wait a second then press "top_menu" to exit any current active app, and only then I call turn_off. Reason for this is that in my experience some apps tend to not like it when the ATV is suspended when playing.

My workaround is to store the playstate of the ATV in context and when the television node sends active:0, I filter on this context and just sends turn_off if nothing is playing. This way I get out of the endless loop.

What I am trying to build here is basically just a television service identical (or as close to) to the one I have for my smart tv - which I btw never use as it basically acts as a dumb screen for my receiver (which switch between gaming consoles and ATV) and my ATV that is the main tv watching access point.

It baffles me that there are more control options available in Homekit for a third party smart tv than there is for Apple's own setup box. So I basically just want to be able to integrate the ATV status in various scenes in homekit, e.g. Going to Bed should suspend the ATV, and once pyatv at some point hopefully manages to figure out launching apps, I could have a kids want to watch Disney+ scene. You get the picture...

The option isn’t on the node but on the bridge. Edit the bridge and you’ll see the pass through option.

@mtjoernelund like @crxporter said.
We currently have two nodes: service node (which appears on flow) and bridge node (which is a config node and appears in configs).

service node:
service node

After you click that pencil icon next to Bridge name you will gain access to Bridge node (config):
bridge node

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!

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

I’ll close it, thanks again for helping out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

a2sky picture a2sky  Â·  7Comments

Delphius7 picture Delphius7  Â·  5Comments

thomasssso picture thomasssso  Â·  10Comments

Supergiovane picture Supergiovane  Â·  9Comments

Shaquu picture Shaquu  Â·  10Comments