Skip to content

Instantly share code, notes, and snippets.

@VincentSC
Created September 19, 2020 20:39
Show Gist options
  • Save VincentSC/d6dc4825d945983855e879f958191bf3 to your computer and use it in GitHub Desktop.
Save VincentSC/d6dc4825d945983855e879f958191bf3 to your computer and use it in GitHub Desktop.
See https://domoticz.com/forum/viewtopic.php?t=32236
The flow has been simplified and extended (more media-apps). Configuration is in one node now, and turning on is usinf standard methods (no 'etherwake' needed). Removed the VLC-camera.
[{"id":"aede20f5.0ac3e","type":"exec","z":"8f49c8f3.68e3d","command":"adb -e shell","addpay":true,"append":"","useSpawn":"false","timer":"9","oldrc":false,"name":"adb shell","x":1080,"y":580,"wires":[["c2df6ee6.773f1"],["c2df6ee6.773f1"],["f98d2489.00b2a","c2df6ee6.773f1"]]},{"id":"c3c59d89.c1a09","type":"change","z":"8f49c8f3.68e3d","name":"x,y","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"input tap \" & msg.req.query.x & \" \" & msg.req.query.y","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":560,"wires":[["1fdf7312.9cbecd"]]},{"id":"9081f17b.44b4d8","type":"change","z":"8f49c8f3.68e3d","name":"am start","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"am start -n\" & msg.payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":640,"wires":[["626bac2f.299a7c","1fdf7312.9cbecd"]]},{"id":"e2a23069.fadf4","type":"inject","z":"8f49c8f3.68e3d","name":"VOLUME_DOWN","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_VOLUME_DOWN","payloadType":"str","x":300,"y":420,"wires":[["91b77327.ad91"]]},{"id":"91b77327.ad91","type":"change","z":"8f49c8f3.68e3d","name":"input keyevent","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"input keyevent \" & msg.payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":520,"wires":[["626bac2f.299a7c","1fdf7312.9cbecd"]]},{"id":"d73da43b.7064b","type":"inject","z":"8f49c8f3.68e3d","name":"VOLUME_UP","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_VOLUME_UP","payloadType":"str","x":290,"y":380,"wires":[["91b77327.ad91"]]},{"id":"55554847.e9d608","type":"exec","z":"8f49c8f3.68e3d","command":"adb","addpay":true,"append":"","useSpawn":"false","timer":"3","oldrc":false,"name":"adb","x":1290,"y":660,"wires":[[],[],[]]},{"id":"f98d2489.00b2a","type":"function","z":"8f49c8f3.68e3d","name":"connect","func":"// if was error then reconnect and repeat last command\nif ( msg.payload.code !==0 )\n{\nmsg.payload = \" connect \"+msg.ipaddress+\" | grep connected\";\nmsg2 = { payload:flow.get('repeat') };\nreturn [msg,msg2];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1080,"y":640,"wires":[["55554847.e9d608"],["6462c6db.1b13c8"]]},{"id":"c16d250d.dc781","type":"inject","z":"8f49c8f3.68e3d","name":"Left","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_DPAD_LEFT","payloadType":"str","x":210,"y":540,"wires":[["91b77327.ad91"]]},{"id":"c9d9a5c6.939588","type":"inject","z":"8f49c8f3.68e3d","name":"Right","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_DPAD_RIGHT","payloadType":"str","x":370,"y":540,"wires":[["91b77327.ad91"]]},{"id":"7dd28447.b11914","type":"inject","z":"8f49c8f3.68e3d","name":"Up","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_DPAD_UP","payloadType":"str","x":290,"y":500,"wires":[["91b77327.ad91"]]},{"id":"cdfb4335.f03138","type":"inject","z":"8f49c8f3.68e3d","name":"Down","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_DPAD_DOWN","payloadType":"str","x":290,"y":580,"wires":[["91b77327.ad91"]]},{"id":"ab855e51.5a472","type":"inject","z":"8f49c8f3.68e3d","name":"OK","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_DPAD_CENTER","payloadType":"str","x":450,"y":640,"wires":[["91b77327.ad91"]]},{"id":"77d3f2bb.87bc2c","type":"inject","z":"8f49c8f3.68e3d","name":"Home","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"str","x":310,"y":640,"wires":[["91b77327.ad91"]]},{"id":"626bac2f.299a7c","type":"function","z":"8f49c8f3.68e3d","name":"repeat set","func":"// Last command store for repat after connection error\n//var count = flow.get('count')||0;\n//if ( count !==0 ) {\n flow.set('repeat',msg.payload); \n//}\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":600,"wires":[[]]},{"id":"6462c6db.1b13c8","type":"delay","z":"8f49c8f3.68e3d","name":"Try again when failed","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1120,"y":720,"wires":[[]]},{"id":"2bf9bd2e.e96f82","type":"inject","z":"8f49c8f3.68e3d","name":"Power Off","props":[{"p":"payload","v":"KEYCODE_POWER","vt":"str"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"KEYCODE_POWER","payloadType":"str","x":820,"y":420,"wires":[["1fdf7312.9cbecd"]]},{"id":"d73f7e24.2d2a1","type":"inject","z":"8f49c8f3.68e3d","name":"Back / Wake","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"str","x":150,"y":640,"wires":[["91b77327.ad91"]]},{"id":"c2df6ee6.773f1","type":"debug","z":"8f49c8f3.68e3d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1290,"y":580,"wires":[]},{"id":"f3bea8ae.4f3e7","type":"inject","z":"8f49c8f3.68e3d","name":"Disney+","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.disney.disneyplus/com.bamtechmedia.dominguez.main.MainActivity","payloadType":"str","x":300,"y":1000,"wires":[["9081f17b.44b4d8"]]},{"id":"900ea3c5.d339e8","type":"inject","z":"8f49c8f3.68e3d","name":"NPO","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"nl.uitzendinggemist/.main.SplashActivity","payloadType":"str","x":290,"y":960,"wires":[["9081f17b.44b4d8"]]},{"id":"346bb1ab.d9662e","type":"inject","z":"8f49c8f3.68e3d","name":"Sleep","props":[{"p":"payload","v":"26","vt":"str"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"26","payloadType":"str","x":810,"y":460,"wires":[["91b77327.ad91"]]},{"id":"d79194d1.6a75f","type":"inject","z":"8f49c8f3.68e3d","name":"Netflix","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.netflix.ninja/.MainActivity","payloadType":"str","x":290,"y":920,"wires":[["9081f17b.44b4d8"]]},{"id":"6b75734.cedc40c","type":"inject","z":"8f49c8f3.68e3d","name":"Amazon","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.amazon.amazonvideo.livingroom/com.amazon.ignition.IgnitionActivity","payloadType":"str","x":300,"y":880,"wires":[["9081f17b.44b4d8"]]},{"id":"fc82e175.539a28","type":"inject","z":"8f49c8f3.68e3d","name":"YT Kids","props":[{"p":"payload","v":"com.google.android.youtube.tvkids/com.google.android.apps.youtube.tvkids.activity.MainActivity","vt":"str"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.google.android.youtube.tvkids/com.google.android.apps.youtube.tvkids.activity.MainActivity","payloadType":"str","x":290,"y":840,"wires":[["9081f17b.44b4d8"]]},{"id":"98a0303e.2b3de8","type":"change","z":"8f49c8f3.68e3d","name":"dumpsys package","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"dumpsys package | grep -i \" & msg.payload & \" | grep Activity\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":800,"wires":[["1fdf7312.9cbecd"]]},{"id":"8d0ef96d.a411a","type":"inject","z":"8f49c8f3.68e3d","name":"Find activity name","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.google.android.youtube.tv","payloadType":"str","x":790,"y":760,"wires":[["98a0303e.2b3de8"]]},{"id":"dbb0bbcd.aae098","type":"inject","z":"8f49c8f3.68e3d","name":"TED","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.ted.android.tv/.view.MainActivity","payloadType":"str","x":290,"y":1040,"wires":[["9081f17b.44b4d8"]]},{"id":"4687a4ae.0657ec","type":"inject","z":"8f49c8f3.68e3d","name":"Vimeo","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.vimeo.android.videoapp/.core.MainActivity","payloadType":"str","x":290,"y":1080,"wires":[["9081f17b.44b4d8"]]},{"id":"1fdf7312.9cbecd","type":"change","z":"8f49c8f3.68e3d","name":"Configuration","rules":[{"t":"set","p":"ipaddress","pt":"msg","to":"192.168.XXX.XXX","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":520,"wires":[["aede20f5.0ac3e"]]},{"id":"555da642.c92d","type":"comment","z":"8f49c8f3.68e3d","name":"Debug","info":"Get the name from the Android package. Then the activity name will be logged","x":770,"y":720,"wires":[]},{"id":"f2393d80.ba6488","type":"inject","z":"8f49c8f3.68e3d","name":"Youtube","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity","payloadType":"str","x":300,"y":800,"wires":[["9081f17b.44b4d8"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment