hello, I have history stats from binary sensor (bed sensor), I get data to history stats sensor and its work good, I tried to to show how long I slept every day on last week so I tried to use variable and script sleep record but the sleep record dont get data
here we can see just the history stats I created working
and here we can see the history of sleep record
This is my configuration code:
- platform: history_stats
name: שעות שינה נוי
entity_id: binary_sensor.right_side_bed_sensor
state: 'on'
type: time
end: '{{ now().replace(hour=11, minute=0, second=0) }}'
duration:
hours: 15
variable:
noy_sleep_record:
value: 'unknown'
restore: true
this is the script
update_sleep_record:
sequence:
- service: variable.set_variable
data:
variable: noy_sleep_record
attributes:
history_1: '{{states(''variable.noy_sleep_record'')}}'
history_2: '{{state_attr(''variable.noy_sleep_record'',''history_1'')}}'
history_3: '{{state_attr(''variable.noy_sleep_record'',''history_2'')}}'
history_4: '{{state_attr(''variable.noy_sleep_record'',''history_3'')}}'
history_5: '{{state_attr(''variable.noy_sleep_record'',''history_4'')}}'
history_6: '{{state_attr(''variable.noy_sleep_record'',''history_5'')}}'
history_7: '{{state_attr(''variable.noy_sleep_record'',''history_6'')}}'
history_1_date: '{{states(''sensor.time_formatted'')}}'
history_2_date: '{{state_attr(''variable.noy_sleep_record'',''history_1_date'')}}'
history_3_date: '{{state_attr(''variable.noy_sleep_record'',''history_2_date'')}}'
history_4_date: '{{state_attr(''variable.noy_sleep_record'',''history_3_date'')}}'
history_5_date: '{{state_attr(''variable.noy_sleep_record'',''history_4_date'')}}'
history_6_date: '{{state_attr(''variable.noy_sleep_record'',''history_5_date'')}}'
history_7_date: '{{state_attr(''variable.noy_sleep_record'',''history_6_date'')}}'
data_template:
value: '{{ states(''sensor.sensor.sh_vt_shynh_nt'')}}
And this is the Automation code
- id: '1637654048316'
alias: ' Update daily sleep record '
description: ''
trigger:
- platform: time
at: '17:30:00'
condition: []
action:
- service: script.turn_on
target:
entity_id:
- script.update_noy_sleep_record
initial_state: 'on'
mode: single
what the problem? someone know why its not working to me?
Thank you!!