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

Record IQS for Switchbot #136058

Merged
merged 7 commits into from
Jan 22, 2025
Merged

Conversation

huyuwei1996
Copy link
Contributor

Breaking change

Proposed change

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, mind taking a look at this pull request as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Please do the fixes other than the IQS in separate PRs

@huyuwei1996 huyuwei1996 marked this pull request as draft January 20, 2025 10:15
@huyuwei1996
Copy link
Contributor Author

Please do the fixes other than the IQS in separate PRs

ok, thanks.

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Let's add the things we agree on fixing in the comments of the rule (in the file) and let's get this merged and improve from there!

@@ -0,0 +1,66 @@
rules:
Copy link
Member

Choose a reason for hiding this comment

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

One general note: I believe there are quite a few issues where users try to set up their new device (which isnt supported by HA yet at that time), and then it gets detected as led strip, but doesn't actually work. I think that is something that can be improved on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a known issue.Does it need to be done under the gold standard? We have some ideas, but it will take some time to develop

Copy link
Member

Choose a reason for hiding this comment

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

This was fixed in sblibs/pySwitchbot#265

Copy link
Contributor Author

@huyuwei1996 huyuwei1996 Jan 22, 2025

Choose a reason for hiding this comment

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

This was fixed in sblibs/pySwitchbot#265

As far as I know, we probably have a way to correctly determine the device type during passive scanning, which is what we hope for. And it can be done without modifying the firmware

Copy link
Member

Choose a reason for hiding this comment

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

There currently isn't sblibs/pySwitchbot#284

Also confirmed by Switchbot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There currently isn't sblibs/pySwitchbot#284

Also confirmed by Switchbot

Yes, I just modified my comment. There was a grammatical error in what I said just now.

entity-category: done
entity-device-class: done
entity-disabled-by-default: done
entity-translations: done
Copy link
Member

Choose a reason for hiding this comment

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

One thing on entity names, I happen to have a Hub 2, and the temperature sensor's name is set to None (because there is also a thermometer or another device where the temperature sensor is the mail feature of the device), but that looks weird on the Hub 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. I also found it when I used it myself. Because I was just developing it for my own use, I simply added the sensor reading of hub2. I will make changes later to change the entity name of hub2 temperature sensor to xxx_temperature.

appropriate-polling: done
brands: todo
common-modules: done
config-flow-test-coverage: todo
Copy link
Member

Choose a reason for hiding this comment

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

Consider making

def patch_async_setup_entry(return_value=True):
    """Patch async setup entry to return True."""
    return patch(
        "homeassistant.components.switchbot.async_setup_entry",
        return_value=return_value,
    )

a proper generator

@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
    """Override async_setup_entry."""
    with patch(
        "homeassistant.components.switchbot.async_setup_entry",
        return_value=True,
    ) as mock_setup_entry:
        yield mock_setup_entry

This way you only have to include it as a fixture and you can remove all the with patch_async_setup_entry() as mock_setup_entry from the tests

appropriate-polling: done
brands: todo
common-modules: done
config-flow-test-coverage: todo
Copy link
Member

Choose a reason for hiding this comment

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

Let's also test the unique id in test_bluetooth_discovery and test_bluetooth_discovery_requires_password and test_bluetooth_discovery_encrypted_key

appropriate-polling: done
brands: todo
common-modules: done
config-flow-test-coverage: todo
Copy link
Member

Choose a reason for hiding this comment

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

Consider parametrizing tests like test_user_setup_wohand, test_user_setup_wocurtain

homeassistant/components/switchbot/quality_scale.yaml Outdated Show resolved Hide resolved
homeassistant/components/switchbot/quality_scale.yaml Outdated Show resolved Hide resolved
homeassistant/components/switchbot/quality_scale.yaml Outdated Show resolved Hide resolved
homeassistant/components/switchbot/quality_scale.yaml Outdated Show resolved Hide resolved
homeassistant/components/switchbot/quality_scale.yaml Outdated Show resolved Hide resolved
@huyuwei1996 huyuwei1996 marked this pull request as ready for review January 21, 2025 16:22
@joostlek joostlek merged commit 4c8b4b3 into home-assistant:dev Jan 22, 2025
32 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2025
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.

4 participants