-
-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use native datetime value in UniFi sensors #59926
Conversation
Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration ( |
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.
Looks good!
Thanks @frenck ! |
@@ -172,8 +172,8 @@ def name(self) -> str: | |||
def native_value(self) -> datetime: | |||
"""Return the uptime of the client.""" | |||
if self.client.uptime < 1000000000: | |||
return (dt_util.now() - timedelta(seconds=self.client.uptime)).isoformat() | |||
return dt_util.utc_from_timestamp(float(self.client.uptime)).isoformat() | |||
return dt_util.now() - timedelta(seconds=self.client.uptime) |
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.
Side note: The timestamp should always be in UTC time. Looks like we're returning local time here.
Proposed change
As introduced in #52671, sensors now should return a native date(time) when using the date(time) device classes.
This PR adjusts UniFi to comply with that.
Type of change
Additional information
Checklist
black --fast 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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: