Skip to content

Add Sensor platform to NASweb integration #133063

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

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

nasWebio
Copy link
Contributor

@nasWebio nasWebio commented Dec 12, 2024

Breaking change

Proposed change

Adds Sensor platform to NASweb integration

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
  • 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:

@dgomes dgomes changed the title Add Sensor platform Add Sensor platform to NASweb integration Dec 12, 2024
Comment on lines 45 to 49
def _get_input(coordinator: NASwebCoordinator, index: int) -> NASwebInput | None:
for entry in coordinator.webio_api.inputs:
if entry.index == index:
return entry
return None
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this, why don't we make the data of the coordinator a dict of {index: entry} so we can do a quick lookup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this function is used in one place, I decided to make a change to _check_entities which makes it no longer needed.

Comment on lines 153 to 158
async def async_update(self) -> None:
"""Update the entity.

Only used by the generic entity update service.
Scheduling updates is not necessary, the coordinator takes care of updates via push notifications.
"""
Copy link
Member

Choose a reason for hiding this comment

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

not needed

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'm not sure if you're referring here to the docstring or the function itself. This function is abstract and I need to implement it, but it does nothing in my case, so I added a docstring explaining why it's empty.

@home-assistant home-assistant bot marked this pull request as draft January 16, 2025 11:17
@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.

@nasWebio nasWebio marked this pull request as ready for review January 22, 2025 15:25
@home-assistant home-assistant bot requested a review from joostlek January 22, 2025 15:25
Copy link

github-actions bot commented Apr 5, 2025

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Apr 5, 2025
@nasWebio
Copy link
Contributor Author

nasWebio commented Apr 7, 2025

Waiting for the review

@github-actions github-actions bot removed the stale label Apr 8, 2025
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Jun 25, 2025
@emontnemery
Copy link
Contributor

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Looks mostly good, I think this can be merged when an icons.json file has been added

Comment on lines 106 to +109
data: dict[str, Any] = {}
data[KEY_OUTPUTS] = self.webio_api.outputs
data[KEY_INPUTS] = self.webio_api.inputs
data[KEY_TEMP_SENSOR] = self.webio_api.temp_sensor
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
data: dict[str, Any] = {}
data[KEY_OUTPUTS] = self.webio_api.outputs
data[KEY_INPUTS] = self.webio_api.inputs
data[KEY_TEMP_SENSOR] = self.webio_api.temp_sensor
data: dict[str, Any] = {
KEY_OUTPUTS: self.webio_api.outputs,
KEY_INPUTS: self.webio_api.inputs,
KEY_TEMP_SENSOR: self.webio_api.temp_sensor,
}

Comment on lines 107 to +109
data[KEY_OUTPUTS] = self.webio_api.outputs
data[KEY_INPUTS] = self.webio_api.inputs
data[KEY_TEMP_SENSOR] = self.webio_api.temp_sensor
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little bit odd to use constants from the library to index data which we construct and consume ourselves

STATE_NORMAL,
STATE_PROBLEM,
]
_attr_icon = "mdi:import"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be set in icons.json instead if we never modify it: https://developers.home-assistant.io/docs/core/entity?_highlight=icons.json#icon-translations

@home-assistant home-assistant bot marked this pull request as draft June 25, 2025 09:35
@github-actions github-actions bot removed the stale label Jun 25, 2025
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.

3 participants