HI
I need to measure the daily number of hours that a power sensor is above zero and the number of hours it is below zero.
I have set up the following sensors:
- platform: history_stats
name: Import Hours Today
entity_id: sensor.import
state: 'true'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: Export Hours Today
entity_id: sensor.import
state: 'false'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: template
sensors:
import:
value_template: "{{states.sensor.grid_power.state > '0' }}"
sensor.grid_power is the sensor that measures the power ie + or - (defined elsewhere)
sensor.import gives ‘true’ if +ve and ‘false’ if -ve
The 2 history_stats sensors remain at 0.0h
What am I missing