home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.98k stars 29.06k forks source link

Homekit Bridge - inclusion filter not working with 2nd service(bridge) configured #104440

Open garywg opened 7 months ago

garywg commented 7 months ago

The problem

Using HomeKit Bridge integration I hit the max 150 entities limit(Errors appeared in HASS logs to this effect). In the HomeKit Bridge integration using 'Configure' I removed the 'excess' entries from the 1st Bridge and then create a 2nd Bridge so I could add these entities to the 2nd Bridge in the integration. Everything works fine, and the entities I removed from the 1st bridge and added to the 2nd bridge appear in HomeKit correctly after pairing the 2nd Bridge with HomeKit. The issue is though that on the 2nd Bridge I have set to 'inclusion mode' to include (same as 1st bridge) and selected the same domains as the 1st bridge. For some reason the Domains 'Input Boolean' and 'Switch', even though selected I dont select any entities - but - all my switches and input booleans appear in HomeKit as a result of this 2nd Bridge. More strangely, where I did select some of these entities on the 1st Bridge, these entities are then duplicated in HomeKit. I tried removing the 2nd Bridge, restarting HASS, adding the 2nd bridge and adding the entities again but result is same, the only way I can stop the entities in these domains appearing is by not selecting them for inclusion on the 2nd bridge. None of the other domains or entities are duplicated in HomeKit.(Note: I'm not including all domains but the same domains are selected on both bridges - as I want to split the bridges using 'upstairs' and 'downstairs' as the logical split) The expected result for me is that even with the Domains selected for inclusion, unless I select an entity, is should not appearing HomeKit.

Updated 24/11/2023 : For clarity, I have no issue creating the bridges or pairing them so that the bridges appear in HomeKit, the issue is even though I am using 'Inclusion' on the Domains, I am not selecting the switches and input boolean entities, but all my switches and input booleans are then appearing in HomeKit , even though none selected. And where I did select a switch or input boolean on the 1st bridge the 2nd bridge, because is creating all switches and input booleans is in these cases creating duplicate switches/input booleans in Homekit.

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Homekit Bridge

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

happy to provide relevant logs if someone can point me to which logs required and where they are located.

home-assistant[bot] commented 7 months ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


homekit documentation homekit source (message by IssueLinks)

FabioEight commented 7 months ago

I have the same issue since the last update to 2023.11.3. I had 4 different HomeKit services/bridges and now I can pair just one.

FabioEight commented 7 months ago

I have the same issue since the last update to 2023.11.3. I had 4 different HomeKit services/bridges and now I can pair just one.

After spending an hour of troubleshooting, I restored a backup of my HAOS VM on 2023.11.2 and everything is back to normal. I had to re-create the HomeKit bridges but I have no issues adding them.

garywg commented 7 months ago

Hello, I have no issue creating the bridges or pairing them so that the bridges appear in HomeKit, the issue is even though I am using 'Inclusion' on the Domains, I am not selecting the switches and input boolean entities, but all my switches and input booleans are then appearing in HomeKit , even though none selected. And where I did select a switch or input boolean on the 1st bridge the 2nd bridge, because is creating all switches and input booleans is in these cases creating duplicate switches/input booleans in Homekit.

fjbravo commented 7 months ago

I'm having the same issue. After playing around and removing the Homekit Bridge integration and re-adding it, I've identified that if a "Domain" is selected to be included and no "Entities" for that domain are selected, all entities of that domain are included. Example:

Selected Domain, Sensor and Binary Sensor, and No Entities for Binary Sensor

HomeKit Bridge Configuration

HomeKit App Imported Entities:

Notes In the example above, I included the binary sensor in the domains but did NOT include any binary_sensor entities. So, all of the binary_sensor entities got pushed into HomeKit.

Selected Domain, Sensor and Binary Sensor, and One selected Entitie for Binary Sensor

HomeKit Bridge Configuration

HomeKit App Imported Entities:

Notes In the example above, I included the binary sensor in the domains and included the binary_sensor.office_motion. This removed the binary_sensor.bedroom_motion from the integration.

Version Core 2023.12.0 Supervisor 2023.11.6 Operating System 11.2 Frontend 20231206.0

garywg commented 7 months ago

Hi, I've spent many hours on this and now have this working after many many many attempts at different structures for my config. I've only succeeded by not doing the config via the UI and doing it via YAML. The inclusion/exclusion simply does not work if done via the UI and I have to wonder if a factor here is something to do with how the UI writes the config files, specifically the indentation structure in the config file plus you can only specify include or exclude, not both as far as I can tell, whereas doing it in YAML you can do both.

What I noticed is that when doing the config via YAML the editor did not always give an error when the indentation structure was incorrect. I only noticed this as I have more than 150 devices(lights, sensors, plugs, etc) and I was using !include to structure the .YAML files for easier reading. When indentation was incorrect, no error appears in the YAML editor, and even when doing a 'Check config' before restarting - no error. It was only because I was using !include files for the entities, and had to deal with the indentation being correct in the !include that I figured it out.

I tested by having the include / exclude entries directly in the HomeKit config file, and then moved them into the include files once the entities were appearing/not appearing as required.

The moment the indentation structure is correct the entities appear or disappear from HomeKit correctly based on their inclusion/exclusion rule in the .YAML files.

Because I wiped and redid my setup so many times I got fed up moving the entities into the correct rooms in HomeKit every time I tried a new config as HomeKit would loose all the settings or dump all the entities into the 'Default Room' and remove any entities over the 150 count I've now split this and got a number of bridges configured.

What I did find is that you have to specifically exclude entities, if there is a list of entities for include, you still have to specify the exclude for the ones you don't want for the domain. (See bridge 21066 example below)

My system Info Core 2023.11.3 Supervisor 2023.11.6 Operating System 1.2 Frontend 20231030.2

*********configuration.yaml` (I've only included the HomeKit entry from my configuration.yaml file here)
# Homekit Configuration
homekit: !include homekit.yaml

*********homekit.yaml (I've included the entire file here)
  - mode: bridge
#****************************
# 21063 Bridge
#****************************
#  - name: HASS Bridge 21063
#    port: 21063
    filter:
      include_domains:
        - person
      #exclude_entity_globs:
      #exclude_entities: !include hass_bridge_21063_entity_exclusion.yaml
      #include_entity_globs:
      include_entities: !include hass_bridge_21063_entity_inclusion.yaml
    #entity_config:
#****************************
# 21064 Bridge
#****************************
  - name: HASS Bridge 21064
    port: 21064
    filter:
      include_domains:
        - input_boolean
        - switch
      exclude_entity_globs:
        - switch.*adaptive*
        - switch.*trv*
      exclude_entities: !include hass_bridge_21064_entity_exclusion.yaml
      #include_entity_globs:
      include_entities: !include hass_bridge_21064_entity_inclusion.yaml
    #entity_config:
#****************************
# 21065 Bridge
#****************************
  - name: HASS Bridge 21065
    port: 21065
    filter:
      include_domains:
        - climate
      #exclude_entity_globs:
      exclude_entities: !include hass_bridge_21065_entity_exclusion.yaml 
      #include_entity_globs:
      include_entities: !include hass_bridge_21065_entity_inclusion.yaml
    #entity_config:
#****************************
# 21066 Bridge
#****************************
  - name: HASS Bridge 21066
    port: 21066
    filter:
      include_domains:
        - sensor
        - binary_sensor
      exclude_entity_globs:
        - sensor.*gas*
        - binary_sensor.*hive*
        - binary_sensor.*trv*
        - binary_sensor.*group*
        - binary_sensor.*iphone*
      exclude_entities: !include hass_bridge_21066_entity_exclusion.yaml
      #include_entity_globs:
      include_entities: !include hass_bridge_21066_entity_inclusion.yaml
    #entity_config:
#****************************
# 21067 Bridge
#****************************
  - name: HASS Bridge 21067
    port: 21067
    filter:
      include_domains:
        - light
      #exclude_entity_globs:
      #exclude_entities: !include hass_bridge_21067_entity_exclusion.yaml 
      #include_entity_globs:
      include_entities: !include hass_bridge_21067_entity_inclusion.yaml
    #entity_config:

*********(I've only included 2 of the include files here ,for bridge 21066)
*********hass_bridge_21066_entity_inclusion.yaml 
        - sensor.someone_home
        - sensor.dining_room_im_co2
        - sensor.dining_room_im_pressure
        - sensor.dining_room_im_noise
        - sensor.dining_room_im_humidity
        - sensor.back_garden_smart_rain_gauge_rain
        - sensor.back_garden_smart_rain_gauge_rain_today
        - sensor.back_garden_om_temperature
        - sensor.back_garden_om_humidity
        - sensor.upstairs_bathroom_door_temperature
        - sensor.upstairs_bathroom_door_illuminance_lux
        - sensor.landing_middle_temperature
        - sensor.landing_middle_illuminance_lux
        - sensor.landing_outside_bathroom_temperature
        - sensor.landing_outside_bathroom_illuminance_lux
        - sensor.master_bedroom_door_temperature
        - sensor.master_bedroom_door_illuminance_lux
        - sensor.driveway_temperature
        - sensor.driveway_illuminance_lux
        - sensor.stairs_temperature
        - sensor.stairs_illuminance_lux
        - sensor.landing_stairs_top_temperature
        - sensor.landing_stairs_top_illuminance_lux
        - sensor.upstairs_bathroom_back_temperature
        - sensor.upstairs_bathroom_back_illuminance_lux
        - sensor.laundry_room_temperature
        - sensor.laundry_room_illuminance_lux
        - sensor.passage_back_temperature
        - sensor.passage_back_illuminance_lux
        - sensor.dining_room_front_temperature
        - sensor.dining_room_front_illuminance_lux
        - sensor.dining_room_back_temperature
        - sensor.dining_room_back_illuminance_lux
        - sensor.bathroom_door_temperature
        - sensor.bathroom_door_illuminance_lux
        - sensor.bathroom_back_temperature
        - sensor.bathroom_back_illuminance_lux
        - sensor.kitchen_front_temperature
        - sensor.kitchen_front_illuminance_lux
        - sensor.kitchen_back_temperature
        - sensor.kitchen_back_illuminance_lux
        - sensor.lounge_front_couch_temperature
        - sensor.lounge_front_couch_illuminance_lux
        - sensor.entrance_hall_back_temperature
        - sensor.entrance_hall_back_illuminance_lux
        - sensor.entrance_hall_front_temperature
        - sensor.entrance_hall_front_illuminance_lux
        - sensor.lounge_front_temperature
        - sensor.lounge_front_illuminance_lux
        - sensor.bathroom_shower_temperature
        - sensor.bathroom_shower_illuminance_lux
        - sensor.downstairs_office_door_temperature
        - sensor.downstairs_office_door_illuminance_lux
        - sensor.downstairs_office_desk_temperature
        - sensor.downstairs_office_desk_illuminance_lux
        - binary_sensor.upstairs_bathroom_door_occupancy
        - binary_sensor.landing_middle_occupancy
        - binary_sensor.landing_outside_bathroom_occupancy
        - binary_sensor.master_bedroom_door_occupancy
        - binary_sensor.driveway_occupancy
        - binary_sensor.stairs_occupancy
        - binary_sensor.landing_stairs_top_occupancy
        - binary_sensor.upstairs_bathroom_back_occupancy
        - binary_sensor.laundry_room_occupancy
        - binary_sensor.passage_back_occupancy
        - binary_sensor.dining_room_front_occupancy
        - binary_sensor.dining_room_back_occupancy
        - binary_sensor.bathroom_door_occupancy
        - binary_sensor.bathroom_back_occupancy
        - binary_sensor.kitchen_front_occupancy
        - binary_sensor.kitchen_back_occupancy
        - binary_sensor.lounge_front_couch_occupancy
        - binary_sensor.entrance_hall_back_occupancy
        - binary_sensor.entrance_hall_front_occupancy
        - binary_sensor.lounge_front_occupancy
        - binary_sensor.bathroom_shower_occupancy
        - binary_sensor.downstairs_office_door_occupancy
        - binary_sensor.downstairs_office_desk_occupancy
        - binary_sensor.hot_tub_steps_occupancy

**** Even with the include above, I had to specifically enter these here to remove them from HomeKit as I could chose not to remove using the exclude_entity_globs.  If remove from the exclusion file , they reappear in HomeKit.
*********hass_bridge_21066_entity_exclusion.yaml
        - sensor.processor_temperature
        - sensor.hive_current_temp
        - sensor.hive_target_temp
        - sensor.bathroom_temperature

I hope this saves someone the days I have spent on this.

andredigenova commented 6 months ago

Same issue here. Setting the bridge in inclusion mode with no devices select is still including a seemingly random assortment of devices when I add the bridge to Homekit

BallistikG commented 3 months ago

Nothing to add beyond this still being an issue in April 2024

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

FabioEight commented 2 weeks ago

Issue still present.