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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Shelly button device triggers #48974

Merged
merged 1 commit into from Apr 9, 2021

Conversation

thecode
Copy link
Member

@thecode thecode commented Apr 9, 2021

Proposed change

Shelly button is a sleeping device which it is not initialized after HA core restart until manually waked up by a button press.
When having device automations based input triggers for this device getting or validating the triggers will fail when device is not initialized.
Since this device has fixed input triggers it is not needed to wait for the device to wake up and input triggers types can be fixed.

Should be tagged for milestone 2021.4.3

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

Example entry for configuration.yaml:

# Example configuration.yaml

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:

@probot-home-assistant
Copy link

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

@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Apr 9, 2021
@balloob balloob added this to the 2021.4.3 milestone Apr 9, 2021
Dev automation moved this from By Code Owner to Reviewer approved Apr 9, 2021
@balloob balloob merged commit 98396e1 into home-assistant:dev Apr 9, 2021
Dev automation moved this from Reviewer approved to Done Apr 9, 2021
@thecode thecode deleted the fix-shelly-button branch April 10, 2021 00:00
balloob pushed a commit that referenced this pull request Apr 10, 2021
@balloob balloob mentioned this pull request Apr 10, 2021
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.

Please address the comment in a new PR. Thanks!

initialized=False,
)

hass.data[DOMAIN] = {DATA_CONFIG_ENTRY: {}}
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to interact with integration details in the tests. We should just set up the integration and patch in the periphery, eg the library, as needed.

https://developers.home-assistant.io/docs/development_testing#writing-tests-for-integrations

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not specific to this test, I am planning to rewrite all the tests, already tried some options but I was not happy with the result, If it is OK by you I would like to use your help for mocking the library in the right way.

Copy link
Member

Choose a reason for hiding this comment

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

Sure!

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the library, one thing that makes the library harder to patch is that it is mixing the business logic of the Device class with the transport handling (aiohttp, coap and socket). If we'd break out the transport handling into a client class that the device can use, it would be easier to patch the client and know that all I/O is patched.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

Shelly button issue with automations when used as trigger
4 participants