Skip to content

Add binary_sensor to Starlink#85409

Merged
bdraco merged 20 commits into
home-assistant:devfrom
boswelja:feature/starlink-binary-sensors
Jan 12, 2023
Merged

Add binary_sensor to Starlink#85409
bdraco merged 20 commits into
home-assistant:devfrom
boswelja:feature/starlink-binary-sensors

Conversation

@boswelja
Copy link
Copy Markdown
Contributor

@boswelja boswelja commented Jan 8, 2023

Proposed change

Adding the binary_sensor platform to the Starlink integration. This primarily takes data from all "alerts" that the Starlink system exposes, which may change at any given time.

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

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@boswelja
Copy link
Copy Markdown
Contributor Author

boswelja commented Jan 8, 2023

Not sure what's going on with mypy, nothing is declared as Any in code and I don't see those errors locally 😕

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 8, 2023

Are you missing a py.typed file in the upstream lib?
https://peps.python.org/pep-0561/

@boswelja
Copy link
Copy Markdown
Contributor Author

boswelja commented Jan 8, 2023

Possibly, we did have issues with typing due to the wide range of supported Python versions. If that's the case, do we just need an empty marker file py.typed? Also, why would it not have been flagged before?

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 8, 2023

Possibly, we did have issues with typing due to the wide range of supported Python versions. If that's the case, do we just need an empty marker file py.typed?

seems so

Also, why would it not have been flagged before?

homeassistant.components.starlink.* was added to .strict-typing in this PR

@boswelja
Copy link
Copy Markdown
Contributor Author

boswelja commented Jan 8, 2023

Interesting that it didn't flag it locally with that change, but I will roll that back for now. Thanks!

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 8, 2023

Interesting that it didn't flag it locally with that change, but I will roll that back for now. Thanks!

You probably wouldn't see it until mypy.ini gets rebuilt and mypy was run again

@boswelja boswelja marked this pull request as ready for review January 8, 2023 06:36
@boswelja boswelja force-pushed the feature/starlink-binary-sensors branch from 208cac7 to 11d725c Compare January 8, 2023 06:36
Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
@boswelja boswelja force-pushed the feature/starlink-binary-sensors branch from e76895e to 632279d Compare January 9, 2023 02:55
@boswelja
Copy link
Copy Markdown
Contributor Author

boswelja commented Jan 9, 2023

I have switched to more standard binary_sensor declarations, and updated the documentation PR to reflect changes.

Comment thread homeassistant/components/starlink/__init__.py Outdated
Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 9, 2023

Looks good. 👍 Some minor comments above.

I'll try to find a time this week where I can reset again and test

@boswelja
Copy link
Copy Markdown
Contributor Author

boswelja commented Jan 9, 2023

I probably should've given you a heads-up to avoid re-resetting for this 😅
Next up I want to look at buttons, once this is merged I'll open up another PR

Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
@boswelja boswelja force-pushed the feature/starlink-binary-sensors branch from ea4a439 to d272fc9 Compare January 10, 2023 07:00
Comment thread homeassistant/components/starlink/coordinator.py Outdated
StarlinkBinarySensorEntityDescription(
key="install_pending",
name="Update pending",
device_class=BinarySensorDeviceClass.UPDATE,
Copy link
Copy Markdown
Member

@bdraco bdraco Jan 12, 2023

Choose a reason for hiding this comment

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

https://developers.home-assistant.io/docs/core/entity/binary-sensor?_highlight=binarys

On means update available, Off means up-to-date. The use of this device class should be avoided, please consider using the update entity instead.

This should be implemented as an update entity instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will look into the update platform next. Buttons (and switches) are relatively small, would it make sense to tack update on the end of the same PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better to do one platform per PR. Its a lot easier to find small blocks of time to do reviews. Its the big PRs that sit for a long time because they need large chunks of time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On update platform - how should I handle this situation? Starlink doesn't expose the "latest version" as far as we know, it just says "there is an update"

Copy link
Copy Markdown
Member

@bdraco bdraco Jan 12, 2023

Choose a reason for hiding this comment

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

We talked about this and it looks like that ends up falling into the exception case since there is no good solution currently when you don't know the new version.

So good to add back in a new PR. Sorry for the churn.

Comment thread homeassistant/components/starlink/binary_sensor.py Outdated
@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 12, 2023

Did the reset song and dance to get dishy out of bypass mode.

Looks good.

I'll take care of dropping the update binary sensor so you don't have to wait for me to retest again

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Jan 12, 2023

Screenshot 2023-01-11 at 5 11 01 PM

Screenshot 2023-01-11 at 5 11 14 PM

@bdraco bdraco merged commit 43cc8a1 into home-assistant:dev Jan 12, 2023
@boswelja boswelja deleted the feature/starlink-binary-sensors branch January 12, 2023 04:09
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 13, 2023
Copy link
Copy Markdown
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!

@@ -12,7 +15,11 @@
COORDINATOR_SUCCESS_PATCHER = patch.object(
StarlinkUpdateCoordinator,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should patch the library and not the coordinator. The coordinator is a detail of the integration.

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

@home-assistant home-assistant unlocked this conversation Jan 16, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 17, 2023
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