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

Multiple ATVs #7

Open UKenGB opened 2 years ago

UKenGB commented 2 years ago

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?

dieteroo commented 1 year ago

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"
        }
}