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 version to templates #78484

Merged
merged 3 commits into from
Sep 15, 2022
Merged

Add version to templates #78484

merged 3 commits into from
Sep 15, 2022

Conversation

ludeeus
Copy link
Member

@ludeeus ludeeus commented Sep 14, 2022

Breaking change

Proposed change

Adds a version filter/function to templates that returns awesomversion objects that can facilitate version comparison in templates.

Basic example:

{{ version("2022.9.5") < "2022.10.0" }}
> True

Automation example

alias: Auto update patches
description: Auto-update patch versions every night at 3AM
trigger:
  - platform: time
    at: "03:00:00"
condition:
  - condition: template
    value_template: >-
      {%- set changes = version(state_attr('update.home_assistant_core_update', 'installed_version')) - state_attr('update.home_assistant_core_update', 'latest_version') -%}
      {{ not changes.major and not changes.minor and changes.patch }}
action:
  - service: update.install
    data:
      backup: true
    target:
      entity_id: update.home_assistant_core_update
mode: single

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
  • 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • 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:

@ludeeus ludeeus marked this pull request as ready for review September 14, 2022 20:51
@ludeeus ludeeus requested a review from a team as a code owner September 14, 2022 20:51
@ludeeus ludeeus closed this Sep 15, 2022
@ludeeus ludeeus deleted the version_template branch September 15, 2022 07:11
@ludeeus ludeeus restored the version_template branch September 15, 2022 08:20
@ludeeus ludeeus reopened this Sep 15, 2022
@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Sep 15, 2022
@frenck frenck self-requested a review September 15, 2022 12:56
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.

Awesome(Version)! 👍

@frenck frenck added the noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) label Sep 15, 2022
@frenck frenck merged commit 8dbe293 into dev Sep 15, 2022
@frenck frenck deleted the version_template branch September 15, 2022 13:01
@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed core new-feature noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants