hello,
I have also create a bed sensor. It works smoothly.
Followed the detailed project of @tom_l
I have also create a sensor (with history stats) to monitor the daily sleep time.
### daily usage of sleep time @ makis side
- platform: history_stats
name: sleep time yesterday for makis
entity_id: binary_sensor.master_bed_occupied
state: 'on'
type: time
end: '{{ now().replace(hour=11, minute=0, second=0) }}'
duration:
hours: 15
As far as I can understand the above sensor has a duration of 15 hours and resets daily at 11.00 am
(so it starts daily at 20.00 pm). Please correct me if I am wrong.
What it confuses me is if the sensor should be reset at 11.00 am ??
Because at the lovelace card (even after 11.00 am) it still shows the yesterday sleep time.
Apart that, I use the following code, thanks to @tom_l again, a mini graph card to keep track of the daily sleep time for a week. It seems to work fine.
aggregate_func: last
card_mod:
class: top-level-graph
color_thresholds:
- color: '#e45e65'
value: 5
- color: '#039BE5'
value: 7
- color: '#e0b400'
value: 9
color_thresholds_transition: soft
entities:
- sensor.sleep_time_yesterday_for_makis
group_by: date
hour24: true
hours_to_show: 168
name: Ημερήσια διάρκεια ύπνου (7 days)
show:
extrema: true
fill: fade
graph: bar
labels: false
smoothing: false
lower_bound: 0
type: custom:mini-graph-card