-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Clear the Hydrawise next_cycle sensor when the value is unknown #111971
Conversation
Hey there @ptcryan, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@@ -99,4 +97,4 @@ def _update_attrs(self) -> None: | |||
if (next_run := self.zone.scheduled_runs.next_run) is not None: | |||
self._attr_native_value = dt_util.as_utc(next_run.start_time) | |||
else: | |||
self._attr_native_value = datetime.max.replace(tzinfo=dt_util.UTC) | |||
self._attr_native_value = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the change should be to make the sensor unavailable rather than unknown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, unavailable is a separate property. None
is a perfectly valid value and converts to "unknown". See the test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this discussion as I think it's equivalent to this. #104522 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I misunderstood your original comment.
I don't think setting this to unavailable is correct.
https://developers.home-assistant.io/docs/core/entity#generic-properties says "Indicate if Home Assistant is able to read the state and control the underlying device."
In this case, we can read the sensor value just fine--it just doesn't have a value. That's equivalent to None
, which equates to "unknown".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! I will leave it up to another member to determine this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not comfortable reviewing this, can you unassign yourself so someone else can review?
I integrated this change into #116303 since we are already touching all the sensor code there. |
Proposed change
If the
next_cycle
sensor value is unknown, we currently set it todatetime.max
. Despite that being a constant value, it causes the sensor entities to update on every data refresh. (See #110054) Setting this toNone
changes the value to show as "unknown", which should prevent updates. (It's also arguably more correct)Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: