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

Move uptime from relative time to absolute time #43623

Merged
merged 3 commits into from
Dec 1, 2020
Merged

Move uptime from relative time to absolute time #43623

merged 3 commits into from
Dec 1, 2020

Conversation

chemelli74
Copy link
Contributor

@chemelli74 chemelli74 commented Nov 25, 2020

Breaking change

In order to optimize stability and performance of HomeAssistant, sensors should use only absolute time values (store the date of the event) and not relative time values (seconds from event) so the db value doesn't change each seconds.
"uptime" integration is one leftover, so to adhere to HomeAssistant development rules, the sensor is now changed to a timestamp.
Please review your lovelace config to reflect the change.

Moved uptime sensor from relative time to absolute time

Proposed change

Moved uptime sensor from relative time to absolute 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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@yuvalabou
Copy link
Contributor

yuvalabou commented Nov 25, 2020

But how does this new sensor tells me the uptime of the system? It will only show last boot?

@frenck
Copy link
Member

frenck commented Nov 25, 2020

@yuvalabou because of the device class the frontend will show the relative time. As for any other use case, the time can be calculated if needed. Essentially, knowing when the last boot was, allows one to calculate it in any way one wants.

homeassistant/components/uptime/sensor.py Show resolved Hide resolved
homeassistant/components/uptime/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/uptime/sensor.py Outdated Show resolved Hide resolved
@frenck
Copy link
Member

frenck commented Nov 25, 2020

Could not place a comment on the specific line, but:

_LOGGER = logging.getLogger(__name__)

Is unused.

@chemelli74
Copy link
Contributor Author

Could not place a comment on the specific line, but:

_LOGGER = logging.getLogger(__name__)

Is unused.

You are right, strange flake8 didn't notice.

Simone

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

I'm OK with this. I think I want a second opinion from @balloob on this one. Mainly because of the impact of the change.

@frenck frenck requested a review from balloob November 30, 2020 08:55
@frenck frenck added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Nov 30, 2020
@frenck frenck changed the title Move from relative time to absolute time Move uptime from relative time to absolute time Dec 1, 2020
Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Nice!

@balloob balloob merged commit 52217f1 into home-assistant:dev Dec 1, 2020
@chemelli74 chemelli74 deleted the chemelli74-uptime branch December 1, 2020 19:41
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change cla-signed code-quality has-tests integration: uptime second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. small-pr PRs with less than 30 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non compliant uptime sensor
5 participants