AppleTV randomly turns on light via HomeKit

Hi,

I’ve just started to build out a HA configuration and I’ve bumped into a strange issue. I have some light fixtures in my office connected to a pair of zwave switches and I’ve found that the lights turn on randomly. After setting up debug logging for homeassistant.components.homekit and pyhap, I figured out that my AppleTV is triggering the light to come on:

2018-11-02 19:16:13 DEBUG (Thread-6) [pyhap.hap_server] Request PUT from address '('172.16.21.190', 49166)' for path '/characteristics'.
2018-11-02 19:16:13 DEBUG (Thread-6) [pyhap.characteristic] client_update_value: On to 1
2018-11-02 19:16:13 DEBUG (Thread-6) [homeassistant.components.homekit.type_switches] switch.office_lights: Set switch state to 1
2018-11-02 19:16:13 INFO (Thread-6) [pyhap.hap_server] 172.16.21.190 - "PUT /characteristics HTTP/1.1" 207 -
2018-11-02 19:16:14 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state switch.office_lights=on; friendly_name=office_lights @ 2018-11-02T19:16:14.133479-07:00>

The light is exposed to HomeKit through a template switch that controls 2 zwave switches. The HomeKit config looks like this:

homekit:
  auto_start: False

  entity_config:
    switch.office_lights:
      name: Office Lights
    switch.front_door_light:
      name: Front Door Light

  filter:
    include_entities:
      - switch.office_lights
      - switch.front_door_light

I can’t figure out why the AppleTV is triggering the light to turn on. Any ideas how to troubleshoot this? I understand that the AppleTV is the HomeKit hub and it is responsible for relaying commands when I’m out of the house. I’m just not sure why it is doing it without someone pressing the switch. I don’t know if this is related, but when I pull up favorite accessories on my phone from the control panel, this particular switch that it is not responding. Any help would be appreciated.

Thanks
Mike

Hi,

Any ideas on this one?

Shortly after I posted this, I removed the HomeKit configuration from HA and restarted. This allowed all of my Apple devices to “unlearn” about the switches that had previously been presented. This stopped the AppleTv from repeatedly turning on the office light and I restored the HomeKit config. About a day later, however, the AppleTv started switching on the front door light.

I have a theory, that I’m hoping to test out this weekend, that the AppleTv consider’s itself as authoritative for the state of any HomeKit devices. My thought is that a light turned on from HomeKit and turned off from HA may be causing this behavior. The AppleTv considers its self authoritative and upon discovering the light has been turned off, asserts the state by turning it on again. Just a theory, but it seems to fit the conditions.

Any ideas would be greatly appreciated. Since I neglected to mention it before, this is on HA 0.80.3 running within a docker instance on a Raspberry Pi.

Thanks
Mike