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

Fix hdmi_cec entity race #18753

Merged
merged 1 commit into from
Dec 2, 2018
Merged

Fix hdmi_cec entity race #18753

merged 1 commit into from
Dec 2, 2018

Conversation

yottatsa
Copy link
Contributor

@yottatsa yottatsa commented Nov 27, 2018

Update shouldn't be called before adding the entity.

Description:

  1. update() is moved outside of the __init__(), otherwise it triggers entity creation with entity_platform.async_add_entities, see f241bec.
  2. add_entities is now updating those entities instead.
  3. Callback is now registered with async_added_to_hass.
  4. Callback is only schedules update with self.schedule_update_ha_state(True).
  5. Added transitional states.

Related issue: fixes #12846

Example entry for configuration.yaml:

hdmi_cec:

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

@homeassistant
Copy link
Contributor

Hi @yottatsa,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

homeassistant/components/media_player/hdmi_cec.py Outdated Show resolved Hide resolved
homeassistant/components/media_player/hdmi_cec.py Outdated Show resolved Hide resolved
homeassistant/components/media_player/hdmi_cec.py Outdated Show resolved Hide resolved
homeassistant/components/switch/hdmi_cec.py Outdated Show resolved Hide resolved
@yottatsa yottatsa force-pushed the cec branch 4 times, most recently from e0b3ae1 to 3165364 Compare November 28, 2018 14:30
@yottatsa
Copy link
Contributor Author

@MartinHjelmare addressed. Now I'm using add_entities(entities, True), and self.schedule_update_ha_state(True) is in the proper place.

@yottatsa
Copy link
Contributor Author

yottatsa commented Nov 29, 2018

@MartinHjelmare addressed. async_schedule_update_ha_state is used now.

@yottatsa yottatsa force-pushed the cec branch 2 times, most recently from 43b5448 to b144f26 Compare November 29, 2018 22:01
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

For future PRs please don't squash commits after review has started to make it easier for readers to track changes. We always squash when we merge anyway.

Can be merged when build passes.

@balloob balloob merged commit debae6a into home-assistant:dev Dec 2, 2018
@ghost ghost removed the in progress label Dec 2, 2018
@balloob balloob mentioned this pull request Dec 12, 2018
@yottatsa yottatsa deleted the cec branch December 27, 2018 16:44
@heisenberg2980
Copy link
Contributor

Has this issue being fixed? I am still having the same problem

2020-03-06 12:06:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.hdmi_2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hdmi_cec errors on startup
6 participants