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

Add Starlink state sensors #133184

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

MrConorAE
Copy link
Contributor

@MrConorAE MrConorAE commented Dec 14, 2024

Proposed change

Add detailed state sensors for Starlink.

The current integration has no way of representing Starlink being disconnected from the Internet for reasons other than obstruction. For example, if a network outage occurs, there is no sensor to indicate that it is not working.

This PR proposes to add the State (sensor.starlink_state) and Connected (binary_sensor.starlink_connected) sensors back. 'State' was originally present in the original HACS Starlink integration, and the 'Connected' sensor is a binary representation of the former.

This is my first 'real' PR, so feedback is very welcome.

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: none
  • This PR is related to issue: none
  • Link to documentation pull request: documentation PR

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.
    (not sure how or if needed in this case?)

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 @boswelja, mind taking a look at this pull request as it has been labeled with an integration (starlink) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of starlink 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 starlink 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.

@MrConorAE MrConorAE marked this pull request as draft December 14, 2024 03:27
@MrConorAE MrConorAE marked this pull request as ready for review December 14, 2024 03:33
Copy link
Member

@zweckj zweckj left a comment

Choose a reason for hiding this comment

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

What about an icon for the status?

homeassistant/components/starlink/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/starlink/binary_sensor.py Outdated Show resolved Hide resolved
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft December 14, 2024 15:59
@MrConorAE MrConorAE force-pushed the add-starlink-state-sensor branch from b42b4b2 to 644b654 Compare December 14, 2024 20:43
@MrConorAE
Copy link
Contributor Author

Added icon 'mdi:satellite-uplink' to the state sensor, because it looks like a Starlink dish :)

@MrConorAE MrConorAE force-pushed the add-starlink-state-sensor branch from 5fa3c4c to 8a65b5f Compare December 14, 2024 20:51
@MrConorAE MrConorAE force-pushed the add-starlink-state-sensor branch from 8a65b5f to ff62f3c Compare January 30, 2025 00:25
@MrConorAE MrConorAE marked this pull request as ready for review January 30, 2025 00:28
@home-assistant home-assistant bot requested review from zweckj and davidrapan January 30, 2025 00:28
Copy link
Contributor

@davidrapan davidrapan left a comment

Choose a reason for hiding this comment

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

Change

key="connected"

to

key="connectivity"

too. 👍

Edit: Name connected w/ a state connected is just off.

@MrConorAE MrConorAE force-pushed the add-starlink-state-sensor branch from ff62f3c to c26b259 Compare January 30, 2025 23:43
@MrConorAE
Copy link
Contributor Author

Random idea, but should I change the 'obstructed' binary sensor to be a diagnostic, like the other problem sensors, now that there's a catch-all 'connected' one (which would include obstructions)?

@davidrapan
Copy link
Contributor

Good point, I’m for it.

StarlinkBinarySensorEntityDescription(
key="connection",
device_class=BinarySensorDeviceClass.CONNECTIVITY,
value_fn=lambda data: (data.status["state"] == "CONNECTED"),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
value_fn=lambda data: (data.status["state"] == "CONNECTED"),
value_fn=lambda data: data.status["state"] == "CONNECTED",

What are the other states? Would it make sense to have it be an enum sensor instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sensor is specifically binary because the raw state can change with a Starlink software update, so no enum sensor in this PR - see this thread above for more.

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.

5 participants