cristian5th / homebridge-appletv

Configuration of pyatv and cmd4 for reading the Apple TV status in Homebridge
GNU General Public License v3.0
25 stars 2 forks source link

on/off loop because timeout is too short #14

Open dieteroo opened 1 year ago

dieteroo commented 1 year ago

default timeout is 4000 ms; on my system it takes on average 5700 ms for the Set command, and on average 3000 ms for the Get command. (tested 20 times each; only 1 listed for each command)

*SHELL*> cat /proc/cpuinfo
Hardware        : BCM2835
Revision        : a02082
Model           : Raspberry Pi 3 Model B Rev 1.2

*SHELL*> env -i bash --noprofile --norc

bash-5.0$ time bash /var/lib/homebridge/appletv_control.sh Set 'ATV Power' 'On' '0'

real    0m5.695s
user    0m5.319s
sys     0m0.248s

bash-5.0$ time bash /var/lib/homebridge/appletv_control.sh Get 'ATV Power' 'On' 
0

real    0m2.988s
user    0m2.802s
sys     0m0.141s

Config

        {
            "platform": "Cmd4",
            "name": "Cmd4",
            "interval": 5,
            "timeout": 4000,
            "debug": true,
            "stateChangeResponseTime": 3,
            "queueTypes": [
                {
                    "queue": "A",
                    "queueType": "WoRm"
                }
            ],
            "accessories": [
                {
                    "type": "Switch",
                    "displayName": "ATV Power",
                    "on": "FALSE",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        }
                    ],
                    "state_cmd": "bash /var/lib/homebridge/appletv_control.sh"
                }
            ]
        }