Skip to content

andrew-codechimp/HA-Periodic-Min-Max

Repository files navigation

HA-Periodic-Min-Max

GitHub Release GitHub Activity Downloads License hacs

Periodic Min/Max Helpers for Home Assistant

The helpers record the minimum or maximum of a sensor until manually reset via the reset action. The value is maintained through HA restarts.

A last_modified attribute is available to check when the min or max was really changed, this attribute does not update on HA restarts giving you an accurate indication on when the new min or max was hit. This can be useful for using as a trigger on an automation or for comparing via a template for a daily update. The attribute is in UTC.

Example use cases

  • Record the maximum temperature today, resetting at midnight via an automation.
  • Record the peak solar energy produced ever, reset when you upgrade your solar installation.

Please ⭐ this repo if you find it useful
If you want to show your support please

"Buy Me A Coffee"

Helper Creation

Reset Action

Tips

If you have many sensors you want to reset daily, create a label called daily reset, add the label to each sensor you want resetting, then create one automation that resets all sensors with that label at midnight.

alias: Periodic Reset Daily at Midnight
description: ""
triggers:
  - trigger: time
    at: "00:00:00"
conditions: []
actions:
  - action: periodic_min_max.reset
    target:
      label_id: daily_reset
    data: {}
mode: single

To tell whether a new min or max has been achieved in the last 24 hours use this template

{{ (utcnow() - as_datetime(state_attr("sensor.my_sensor", "last_modified"))).total_seconds() < 86400 }}

Installation

HACS

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Restart Home Assistant

In the HA UI go to "Configuration" -> "Devices & services" -> "Helpers" click "+" and select "Periodic Min/Max"

Manual Installation

Show detailed instructions

Installation via HACS is recommended, but a manual setup is supported.

  1. Manually copy custom_components/periodic_min_max folder from latest release to custom_components folder in your config folder.
  2. Restart Home Assistant.
  3. In the HA UI go to "Configuration" -> "Devices & services" -> "Helpers" click "+" and select "Periodic Min/Max"

Translations

You can help by adding missing translations when you are a native speaker. Or add a complete new language when there is no language file available.

Periodic Min/Max uses Crowdin to make contributing easy.

Instructions

Changing or adding to existing language

First register and join the translation project

Next translate a string

  • Select the language you want to contribute to from the dashboard.
  • Click Translate All.
  • Find the string you want to edit, missing translation are marked red.
  • Fill in or modify the translation and click Save.
  • Repeat for other translations.

Periodic Min/Max will automatically pull in latest changes to translations every day and create a Pull Request. After that is reviewed by a maintainer it will be included in the next release of Periodic Min/Max.

Adding a new language

Create an Issue requesting a new language. We will do the necessary work to add the new translation to the integration and Crowdin site, when it's ready for you to contribute we'll comment on the issue you raised.