homebridge-appletv icon indicating copy to clipboard operation
homebridge-appletv copied to clipboard

Multiple ATVs

Open UKenGB opened this issue 2 years ago • 1 comments

I see no allowance for having multiple ATVs in this setup. I have 6 for which I want to be able to detect state (ON or OFF, i.e. awake or asleep), to use as a HomeKit trigger. Is that possible using this method?

UKenGB avatar Jul 18 '22 18:07 UKenGB

Yes, but for each AppleTV you should create a slightly altered config and script

Script

create a copy of appletv_control.sh for each AppleTV you want to detect the state of appletv_control_1.sh appletv_control_2.sh open each script in your favorite text-editor and replace (on both line 47 & line 132) "ATV Power" with "ATV_1 Power" "ATV Power" with "ATV_2 Power" Don't forget to make these files executable

Config

create a copy of the accessory for each AppleTV you want to detect the state of for the first accessory you change displayName & state_cmd (add _1) "displayName": "ATV Power", to "displayName": "ATV_1 Power", "state_cmd": "bash /var/lib/homebridge/appletv_control.sh" to "state_cmd": "bash /var/lib/homebridge/appletv_1_control.sh"

for the second accessory you change displayName & state_cmd (add _2) "displayName": "ATV Power", to "displayName": "ATV_2 Power", "state_cmd": "bash /var/lib/homebridge/appletv_control.sh" to "state_cmd": "bash /var/lib/homebridge/appletv_2_control.sh"

Example config

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

dieteroo avatar Feb 22 '23 16:02 dieteroo