-
Notifications
You must be signed in to change notification settings - Fork 33
Min_Max
The entity_min
and entity_max
options are here to display the maximum and minimum values that your entity reached in the past during a defined period.
The card will not compute this magically, you must define some entities yourself in Home Assistant.
You can track either the state of an entity with :
entity_min: sensor.your_min_sensor
entity_max: sensor.your_max_sensor
or you can track an attibute of an entity with (this is handy if you use statistics sensor):
entity_min: sensor.your_sensor.attribute_min
entity_max: sensor.your_sensor.attribute_max
To create such min and max sensor(s) several methods are possible, here are few examples.
You can use the statistics sensor of Home Assistant.
If you store states in an InfluxDB database (you should ! 😝 ) you can create InfluxDB sensors to get the min and max on a give period of time.
Example :
In this example entity name is pressure
, the state is stored in value
field, the database name is hassio
and we want the min and max on the current week.
This will create a max_pressure_this_week
sensor with the maximum pressure value that we hit this week.
- name: max pressure this week
unit_of_measurement: mbar
measurement: '"mbar"'
group_function: max
where: '"entity_id" = ''pressure'' AND time > {{(as_timestamp(now()) - (now().weekday() * 86400) - (now().hour * 3600) - (now().minute * 60) - (now().second)) | round(0)}}s'
field: value
database: hassio
This will create a min_pressure_this_week
sensor with the minimum pressure value that we hit this week.
- name: min pressure this week
unit_of_measurement: mbar
measurement: '"mbar"'
group_function: min
where: '"entity_id" = ''pressure'' AND time > {{(as_timestamp(now()) - (now().weekday() * 86400) - (now().hour * 3600) - (now().minute * 60) - (now().second)) | round(0)}}s'
field: value
database: hassio
Just be sure to put these config lines in the correct section of your configuration !
- sensor:
- platform: influxdb
host: <your_influxdb_host>
queries: