Skip to content

Add a 'last' mode and attribute to min_max sensor#11037

Merged
fabaff merged 3 commits into
home-assistant:devfrom
markferry:min-max-last
Jan 18, 2018
Merged

Add a 'last' mode and attribute to min_max sensor#11037
fabaff merged 3 commits into
home-assistant:devfrom
markferry:min-max-last

Conversation

@markferry
Copy link
Copy Markdown
Contributor

@markferry markferry commented Dec 8, 2017

Add a 'last' mode and attribute to min_max sensor

Inspired by this question "Combining multiple sensor values into one with most recent wins strategy", provide a mode of min_max sensor to report only the most recent value received from a list of sensors. (Follows the nomenclature of Grafana for 'last' value of a sensor).

This solves the issue of multiple sensors providing intermittent and unsolicited readings of the same metric - multiple battery-powered temperature sensors within a room for example.

It does not identify which of the monitored sensors provided the most recent update.

The current workaround is a template sensor or virtual device (input_number or similar) with an automation to update the value when any of the monitored sensors triggers.

Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#4167

Example entry for configuration.yaml (if applicable):

# Example configuration.yaml entry
sensor:
  - platform: min_max
    type: last
    entity_ids:
      - sensor.kitchen_east_temperature
      - sensor.kitchen_west_temperature

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

Now supports types: min, max, mean, last
'last' is the most recently received value from all tracked entities.
@homeassistant
Copy link
Copy Markdown
Contributor

Hi @markferry,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@tinloaf tinloaf changed the title Min max last Add a 'last' mode and attribute to min_max sensor Dec 9, 2017
@tinloaf
Copy link
Copy Markdown
Contributor

tinloaf commented Dec 9, 2017

I don't think this should be part of the min_max sensor. It's conceptually different from min or max. This sensor shouldn't become a "collection of selection functions we could think of"-sensor. If we want this functionality, I think it should live in its own sensor.

@markferry
Copy link
Copy Markdown
Contributor Author

To an extent, @tinloaf, I'm with you, though one could argue min_max sensor is misnamed since it already includes mean as a significant feature.
We might instead call it aggregate_sensor and allow many more modes, complementing statistics sensor which calculates various stats across multiple values of a single sensor.

But a much more ambitious change would instead expand how homogeneous groups work, providing something like OpenHABs AND, OR, AVG, SUM groups, etc.

@fabaff
Copy link
Copy Markdown
Member

fabaff commented Dec 10, 2017

min_max is just a name. It's always possible to rename platforms if it makes sense and not happen every other release. If a new feature can be added with a couple of lines and it fits the purpose of an existing sensor then we should just add it.

Copy link
Copy Markdown
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

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

🐦

@fabaff fabaff merged commit 526405c into home-assistant:dev Jan 18, 2018
@balloob balloob mentioned this pull request Jan 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants