Skip to content

Commit eac2426

Browse files
bokubballoob
authored andcommitted
Add history_stats "type" parameter (home-assistant#2204)
1 parent 436d9d4 commit eac2426

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

source/_components/sensor.history_stats.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ sensor:
3434
name: Lamp ON today
3535
entity_id: light.my_lamp
3636
state: 'on'
37+
type: time
3738
start: '{% raw %}{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}{% endraw %}'
3839
end: '{% raw %}{{ now() }}{% endraw %}'
3940
```
@@ -43,6 +44,7 @@ Configuration variables:
4344
- **entity_id** (*Required*): The entity you want to track
4445
- **state** (*Required*): The state you want to track
4546
- **name** (*Optional*): Name displayed on the frontend
47+
- **type** (*Optional*): The type of sensor: `time`, `ratio`, or `count`. Defaults to `time`
4648
- **start**: When to start the measure (timestamp or datetime).
4749
- **end**: When to stop the measure (timestamp or datetime)
4850
- **duration**: Duration of the measure
@@ -55,6 +57,14 @@ Configuration variables:
5557
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.
5658
</p>
5759

60+
## {% linkable_title Sensor type %}
61+
62+
Depending on the sensor type you choose, the `history_stats` component can show different values:
63+
64+
- **time**: The default value, which is the tracked time, in hours
65+
- **ratio**: The tracked time divided by the length of your period, as a percentage
66+
- **count**: How many times the component you track was changed to the state you track
67+
5868
## {% linkable_title Time periods %}
5969

6070
The `history_stats` component will execute a measure within a precise time period. You should always provide 2 of the following :

0 commit comments

Comments
 (0)