Hi all
I need some help in order to record for how long my water heater switch was on the last 24 hours.
I have made the following sensor
- platform: history_stats
name: water heater time on
entity_id: switch.sonoff_100099b6de
state: 'on'
type: time
end: '{{ now().replace(hour=0, minute=0, second=0) }}'
duration:
hours: 24 # Yesterday: ends today at 00:00, lasts 24 hours
I also have the following notify.yaml
- platform: file
name: filenotify6
filename: /config/water heater per day.csv
timestamp: true
and finally this automation
- id: Water Heat daily file
alias: Water Heat daily file
#initial_state: 'off'
trigger:
platform: time
at: '23:50:00'
condition: []
action:
- service: notify.filenotify6
data_template:
message: "{{ states.sensor.water_heater_time_on.state }}"
So my purpose is to record in a csv file each night the time that the switch was on.
Yesterday the switch was on for 38 minutes.
However in the csv file I got 0.00
This morning the in developers tool - states I see that the state of the sensor is 0.64
So now I am wondering what is wrong with the above setup and in the excel file I have 0.00 instead of 0.64.
I am not sure but I think the problem is with the history stats and how I set the time I need to expose.
Should I change it to
end: '{{ now().replace(hour=0, minute=0, second=0) }}'
duration:
days: 1
I have one more question but right now about this, but this is the first I need to solve.