From eac242642d478d6c9f991d499ee4cc9dcadb89d1 Mon Sep 17 00:00:00 2001 From: Boris K Date: Sat, 11 Mar 2017 20:15:57 +0100 Subject: [PATCH] Add history_stats "type" parameter (#2204) --- source/_components/sensor.history_stats.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/_components/sensor.history_stats.markdown b/source/_components/sensor.history_stats.markdown index 9491481f48a..bc2b79b76d4 100644 --- a/source/_components/sensor.history_stats.markdown +++ b/source/_components/sensor.history_stats.markdown @@ -34,6 +34,7 @@ sensor: name: Lamp ON today entity_id: light.my_lamp state: 'on' + type: time start: '{% raw %}{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}{% endraw %}' end: '{% raw %}{{ now() }}{% endraw %}' ``` @@ -43,6 +44,7 @@ Configuration variables: - **entity_id** (*Required*): The entity you want to track - **state** (*Required*): The state you want to track - **name** (*Optional*): Name displayed on the frontend + - **type** (*Optional*): The type of sensor: `time`, `ratio`, or `count`. Defaults to `time` - **start**: When to start the measure (timestamp or datetime). - **end**: When to stop the measure (timestamp or datetime) - **duration**: Duration of the measure @@ -55,6 +57,14 @@ Configuration variables: You can use [template extensions](/topics/templating/#home-assistant-template-extensions) such as `now()` or `as_timestamp()` to handle dynamic dates, as shown in the examples below.

+## {% linkable_title Sensor type %} + +Depending on the sensor type you choose, the `history_stats` component can show different values: + +- **time**: The default value, which is the tracked time, in hours +- **ratio**: The tracked time divided by the length of your period, as a percentage +- **count**: How many times the component you track was changed to the state you track + ## {% linkable_title Time periods %} The `history_stats` component will execute a measure within a precise time period. You should always provide 2 of the following :