You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_components/sensor.history_stats.markdown
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ sensor:
34
34
name: Lamp ON today
35
35
entity_id: light.my_lamp
36
36
state: 'on'
37
+
type: time
37
38
start: '{% raw %}{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}{% endraw %}'
38
39
end: '{% raw %}{{ now() }}{% endraw %}'
39
40
```
@@ -43,6 +44,7 @@ Configuration variables:
43
44
- **entity_id** (*Required*): The entity you want to track
44
45
- **state** (*Required*): The state you want to track
45
46
- **name** (*Optional*): Name displayed on the frontend
47
+
- **type** (*Optional*): The type of sensor: `time`, `ratio`, or `count`. Defaults to `time`
46
48
- **start**: When to start the measure (timestamp or datetime).
47
49
- **end**: When to stop the measure (timestamp or datetime)
48
50
- **duration**: Duration of the measure
@@ -55,6 +57,14 @@ Configuration variables:
55
57
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.
56
58
</p>
57
59
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
+
58
68
## {% linkable_title Time periods %}
59
69
60
70
The `history_stats` component will execute a measure within a precise time period. You should always provide 2 of the following :
0 commit comments