Hello, I have a Withings sleep sensor and am attempting to plot the data of each night.
The data is output in seconds. I have created template sensors to convert that data into minutes and then hours. There are several problems.
1: Strangely this works for some of the data but not others. See REM-Hours versus Deep Hours.
-
At some point the seconds started being automatically converted to hours and minutes. See REM sleep in the chart (photo 1) - I definitely did not change that reading to hours. When I click on the entity in settings it’s still showing an output in seconds (photo 2).
-
This data is being tracked cumulatively rather than an a series. It’s showing me the TOTAL time I have slept over the course of the week rather than reporting data about EACH day of the week. I Light Sleep-ed for about 5 hours last night and Friday night and want to chart that as a line graph - but this is adding both nights together. Edit: I have changed the sensors from measurement to total_increasing. That should change them to report the sleep data to last night only instead of all the sleep.
#Adjusting sleep numbers
- sensor:
- name: "REM minutes last night"
unique_id: "REM"
state_class: measurement
unit_of_measurement: "Minutes"
state: >
{% set REM = states('sensor.withings_sleep_rem_duration_seconds_name') | float(0) %}
{{ REM / 60 }}
- sensor:
- name: "REM Hours last night"
unique_id: "REMh"
state_class: measurement
unit_of_measurement: "Hours"
state: >
{% set REMh = states('sensor.rem') | float(0) %}
{{ REMh / 60 }}
- sensor:
- name: "Deep Sleep minutes last night"
unique_id: "Deep"
state_class: measurement
unit_of_measurement: "Minutes"
state: >
{% set deep = states('sensor.withings_sleep_deep_duration_seconds_name') | float(0) %}
{{ deep / 60 }}
- sensor:
- name: "Deep Sleep Hours last night"
unique_id: "Deeph"
state_class: measurement
unit_of_measurement: "Hours"
state: >
{% set deeph = states('sensor.deep') | float(0) %}
{{ deeph / 60 }}
- sensor:
- name: "Light Sleep minutes last night"
unique_id: "Light"
state_class: measurement
unit_of_measurement: "Minutes"
state: >
{% set light = states('sensor.withings_sleep_light_duration_seconds_name') | float(0) %}
{{ light / 60 }}
- sensor:
- name: "Light Sleep Hours last night"
unique_id: "Lighth"
state_class: measurement
unit_of_measurement: "Hours"
state: >
{% set lighth = states('sensor.light') | float(0) %}
{{ lighth / 60 }}