Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement source switching for homekit_controller televisions #32526

Merged
merged 1 commit into from
Mar 6, 2020

Conversation

Jc2k
Copy link
Member

@Jc2k Jc2k commented Mar 6, 2020

Proposed change

This implements source and source_list for the homekit_controller media player. If they are supported it sets SUPPORT_SELECT_SOURCE and it adds async_select_source.

Historically one HomeKit service mapped to one Home Assistant entity. But for TV's there are additional satellite services for input sources. This means that the polling and subscribing logic had to be tweaked a bit too, and to avoid some awful code in HA i've added some abstractions to aiohomekit to make it easier to work with these linked services.

This introduces an entity_map object on HKDevice. The plan is to stop using the raw JSON in HKDevice.accesories and HKDevice.current_state and to use entity_map instead, moving a lot of non-HA specific state management code upstream and out of HA. But that will be in a future PR.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@MartinHjelmare MartinHjelmare changed the title homekit_controller: Implement source switching for televisions Implement source switching for homekit_controller televisions Mar 6, 2020
]

def _setup_active_identifier(self, char):
self._features |= SUPPORT_SELECT_SOURCE
Copy link
Member

Choose a reason for hiding this comment

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

Will this ever change during entity lifetime?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now, no. Some TV's might support it some might not, but it will be determined when the TV is added to HA and not again (until restart). Characteristics don't come and go very frequently. If it changed it would probably be a firmware update that added more capabilities to a device that already had very basic HomeKit support in its firmware.

That said, in a future PR i plan to make it some that the setup phase /can/ be run again, idempotently. HomeKit accessories publish a change to their zeroconf metadata if what i call the entity map changes. I handle this already to some extent and add new entities that have been picked added to bridges. But I want to also reconfigure all entities in that case to pick up new features or altered limits.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Supported features shouldn't change during entity lifetime. It could be ok to remove an old entity and add a new one in the old ones place if we want to reconfigure in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks for the heads up - i'll bear that in mind!

@Jc2k Jc2k merged commit 2879081 into home-assistant:dev Mar 6, 2020
@Jc2k Jc2k deleted the homekit_controller_channels branch March 6, 2020 15:47
@lock lock bot locked and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants