Skip to content

Fix on/off button in the Broadlink integration#42443

Merged
elupus merged 1 commit intohome-assistant:devfrom
felipediel:the-button
Oct 30, 2020
Merged

Fix on/off button in the Broadlink integration#42443
elupus merged 1 commit intohome-assistant:devfrom
felipediel:the-button

Conversation

@felipediel
Copy link
Copy Markdown
Contributor

@felipediel felipediel commented Oct 27, 2020

The problem

Users are being tricked. Their universal remotes suddenly stop working because we are turning off the button accidentally.

The cause

When the last state is "unavailable" the state is being casted to "off" in async_added_to_hass().

Proposed change

I think we should consider the entity "off" only if the last state is "off". Any other state should be casted to "on". So we don't take the risk of deactivating the remote when the last state is "unavailable".

But now if the user turns the entity off and restarts Home Assistant when the remote is unavailable, the entity will be initialized as "on". Something that seems much less harmful, after all we usually want the entity on. But not perfect yet.

Something I won't touch here, but I leave it as a suggestion: I think that availability should not be mixed with the state. It is difficult to persist the user's choice in this way.

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 user exposed functionality or configuration variables are added/changed:

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

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

To help with the load of incoming pull requests:

@felipediel felipediel changed the title Fix on/off button Fix on/off button in the Broadlink integration Oct 27, 2020
@probot-home-assistant
Copy link
Copy Markdown

Hey there @Danielhiversen, mind taking a look at this pull request as its been labeled with an integration (broadlink) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

Copy link
Copy Markdown
Contributor

@elupus elupus left a comment

Choose a reason for hiding this comment

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

Hah! That explains how I ended up in that state.

Copy link
Copy Markdown
Contributor

@dgomes dgomes left a comment

Choose a reason for hiding this comment

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

LGTM

Since it sends UDP packets, could we consider it to be always on ?

@elupus elupus merged commit f920863 into home-assistant:dev Oct 30, 2020
@felipediel
Copy link
Copy Markdown
Contributor Author

felipediel commented Oct 30, 2020

Thaank you! I will add an assumed_state option soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

broadlink remote automatically disabled

5 participants