Core: HomeKit filtering doesn't work correctly

Created on 31 Mar 2018  路  13Comments  路  Source: home-assistant/core

Home Assistant release with the issue:

0.66

Last working Home Assistant release (if known):

Unknown

Operating environment (Hass.io/Docker/Windows/etc.):

Docker with host networking

Component/platform:

homekit

Description of problem:

HomeKit filtering within 0.66 doesn't appear to work correctly. Using the below YAML (with the intention of loading only a single entity), HomeKit still sees 122 unique entities upon setup:

img_0210

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

homekit:
  filter:
    include_entities:
      - climate.thermostat

Traceback (if applicable):
N/A

Additional information:
N/A

homekit

All 13 comments

The documentation on the component doesn't provide the proper format for the filter parameters.
https://www.home-assistant.io/components/homekit/#configure-filter

I found a sample in the pull request, but its not in the user documentation. Can this be added?

Here's what I found:
https://github.com/home-assistant/home-assistant/pull/12997

homekit:
  auto_start: False
  filter:
    include_domains: []
    include_entities: []
    exclude_domains: []
    exclude_entities: []
  entity_config:
    alarm_control_panel.alarm:
    code: '1234'

@VdkaShaker Those []s imply that each key accepts a list (which is what I tried). Do you have a configuration that works?

It should work with only include_entites specified, it does for me. In that case only those entities listed will be added.

@bachya Can you try the following:

homekit:
  filter:
    include_entitites:
      - demo.demo

If you pair, this should only add the bridge, no accessories (since demo.demo is no valid entity_id).

The filter is also used by the alexa smart home component: https://www.home-assistant.io/components/alexa/#smart-home

Also the parameter hierarchic is slightly different, it is also used by the recorder component: https://www.home-assistant.io/components/recorder/#exclude

@bachya no working config yet. I鈥檓 waiting for the HASS.io update to home assistant .66 which should be soon. In the mean time I鈥檓 trying to stage my config and couldn鈥檛 find the proper format for the filter parameter.

I don鈥檛 understand what @cdce8p is trying to suggest with his links.

I don鈥檛 know if a comma separated last inside the brackets [] in the sample code I shared would work.

Bottom line I鈥檓 trying to get someone who developed this to give us the proper format. I鈥檒l be attempting to use this soon.

@VdkaShaker I implemented the filter for HomeKit, but didn't wrote it originally.
The filter config should look like this:

filter:
  exclude_domains:
    - cover
    - switch
  exclude_entities:
    - light.kitchen
    - light.living_room
  include_domain:
    - light
  include_entities:
    - light.bedroom

All of those entries should be yaml lists (that should include ['light', 'cover']), but don't need to be specified.

To quote from the py file of the filter functionality, there are more or less four different cases:

Case 1 - no includes or excludes - pass all entities

Case 2 - includes, no excludes - only include specified entities

Case 3 - excludes, no includes - only exclude specified entities

Case 4 - both includes and excludes specified
Case 4a - include domain specified
- if domain is included, and entity not excluded, pass
- if domain is not included, and entity not included, fail
note: if both include and exclude domains specified,
the exclude domains are ignored

Case 4b - exclude domain specified
- if domain is excluded, and entity not included, fail
- if domain is not excluded, and entity not excluded, pass

Case 4c - neither include or exclude domain specified
- Only pass if entity is included. Ignore entity excludes.

Unfortunately I didn't / don't have the time to include a perfect description of the filter in the docs. @VdkaShaker If you have, please feel free to add it.

@cdce8p Thanks for the follow-up. I added this config:

homekit:
  filter:
    include_entities:
      - demo.demo

..., deleted the existing .homekit.state file, restarted HASS, and used the persistent notification's PIN to active a new home within the Home app. It worked!

I retried my original config and it started working, too... So, chalk this up to user error. Thanks!

@cdce8p I don't know how/where to submit updates to documentation, but happy to do it if you can point the way.

I don't understand when you say:

All of those entries should be yaml lists (that should include ['light', 'cover'])

By "all of those entries" you mean the includes and excludes? Why do you reference the bracketed format, if that's not what is used (it actually looks like something I'd use in a json, not a yaml)?

Thanks for the cases, that's very helpful and I'd like to add it to documentation.

@bachya Good to here that it worked.

@VdkaShaker Yaml lists can be represented in different way (http://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html#yaml-basics), both are possible and result in the same outcome:

# Option 1 (preferred)
key:
  - entry_1
  - entry_2

# Option 2
key: ['entry_1', 'entry_2']

all of those entries

All filter keys, see: https://rc.home-assistant.io/components/homekit/#filter

I don't know how/where to submit updates to documentation, but happy to do it if you can point the way.

Take a look at: https://www.home-assistant.io/developers/documentation/
It's basically the following:

  1. Open the page you want to edit
  2. Click on Edit this page on GitHub
  3. Click Edit this file (the pencil)
  4. Edit
  5. Commit changes
  6. Open a PR against (in this case) the current branch. Should be already selected

If you link me in the PR, I can look it over if you want.

I've started to draft changes on GitHub, but I'm not sure how to save (without submitting) the changes. Also, how do I link you to the PR?

A commit is only to your branch. All commits to one branch are then grouped for the PR.

A link to the PR would simply be: copy the link and past it, although linking to my name, like you did earlier, would be nice as well. That way I will get a notification about the PR.

With apologies for hijacking this issue while I learn how to edit docs... @cdce8p I attempted to link to you from the PR. Let me know if you did not receive.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piitaya picture piitaya  路  3Comments

flsabourin picture flsabourin  路  3Comments

neonandu picture neonandu  路  3Comments

MartinHjelmare picture MartinHjelmare  路  3Comments

sogeniusio picture sogeniusio  路  3Comments