Skip to content

Clean up HomeKit accessory information characteristics#14114

Merged
cdce8p merged 3 commits intohome-assistant:devfrom
schmittx:homekit-accessory-information-cleanup
Apr 28, 2018
Merged

Clean up HomeKit accessory information characteristics#14114
cdce8p merged 3 commits intohome-assistant:devfrom
schmittx:homekit-accessory-information-cleanup

Conversation

@schmittx
Copy link
Copy Markdown
Contributor

@schmittx schmittx commented Apr 27, 2018

Description:

Clean up HomeKit accessory information characteristics. Model is now mapped to domain and serial number is mapped to entity_id. Also added firmware revision characteristic using current Home Assistant version.

fullsizeoutput_3dfb

Related issue (if applicable): N/A

Pull request in home-assistant.github.io with documentation (if applicable): N/A

Example entry for configuration.yaml (if applicable):

N/A

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@schmittx schmittx requested a review from cdce8p as a code owner April 27, 2018 07:58
@cdce8p cdce8p self-assigned this Apr 27, 2018
Copy link
Copy Markdown
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small changes.
FYI: The test test_home_accessory fails, since I hard coded the some values.


def set_accessory_info(acc, name, model, manufacturer=MANUFACTURER,
serial_number='0000'):
serial_number=UNKNOWN):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of removing the manufacturer parameter and just assigning the constant below.
The serial_number will always be given, so we don't need UNKNOWN.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave manufacturer for now because I wanted to look into allowing user-specified manufacturer, model, etc. using the HomeKit entity_config.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave it in there for now, but I don't think this should be done. To be honest I personally what prefer to only those required by HomeKit (SerialNumber) and the the ones necessary to identify the accessory (entity_id either in the Model or like your suggestion in the SerialNumber).

While writing this, is there anything useful you can do with this infos? Why not leave it to just Manufacturer='Home Assistant' and SerialNumber=entity_id?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the Apple HomeKit Developer Guide, the Accessory Information service requires Manufacturer, Model, Name, Serial Number, and Firmware Revision so I think we should keep all of these characteristics for now.

screen shot 2018-04-27 at 5 46 52 pm

I don't think there's much usefulness from allowing the user to specify the info, more of just a matter of making the user experience more beautiful/correct. My image is that it would be all optional config (i.e. Home Assistant = default manufacturer). I'll experiment with it, if it can be implemented cleanly and without a lot of config, then I'll submit a PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right in that they are required chars. However everyone except for Serial Number can be empty strings. In the case of Firmware Revision the char would be hidden if the value is empty.

I will take a look at your PR (regarding the optional config) once it's finished. Have in mind however that every option you add needs to be maintained and therefore is extra work. Sometimes it's best to not do all thats possible.

"""Initialize a Accessory object."""
super().__init__(name, aid=aid)
set_accessory_info(self, name, model=entity_id)
domain = entity_id.split(".")[0].replace("_", " ").title()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use split_entity_id(entity_id)[0].replace(..... from homeassistant.core instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@schmittx
Copy link
Copy Markdown
Contributor Author

schmittx commented Apr 27, 2018

@cdce8p Added #14112 contents, updated per your comments, and fixed up the tests.

@cdce8p cdce8p merged commit 2091f86 into home-assistant:dev Apr 28, 2018
@balloob balloob mentioned this pull request May 11, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants