So I’m using a few history statistics sensors to track how long my air conditioning runs, total cycles, average cycle time, etc. However, the long cycle from 78+ degrees down to 73 when I get home from work makes the average cycle time look absurdly high.
At this point what I really want to do is track how long it takes for my AC to drop the temperature from 75 to 73 on average. I’m not sure if there’s a way to do this with history stats sensors. Any thoughts? This is totally unnecessary information for me to know but I love stats like this so it’d be cool to know.
you’d have to start a timer. Then you’d need to start the timer when the temperature starts to drop. If the temperature goes up, cancel the timer. If it continues to go down and drops below the threshold. Pause the timer. That will give you a value. The timer would have to have a very large time period attached to it.
Or you could use two input_number’s, two automations, and a template sensor. One automation would trigger when the AC’s set point changes to 73 (or maybe something else appropriate – not clear exactly when you want to start measuring), and it would set one input_number to the current timestamp and the other to zero. The second automation would trigger when the temperature reaches 73, and it would set the second input_number to the (now) current timestamp. The template sensor would be set up to have a value of zero (or maybe “Cooling to 73”) if the second input_number was zero, or the time difference between the two input_number’s otherwise.
I’m calculating the time when the battery of my solar battery will reach 100%.
The following sensor measures the time between the last two values in the db and gives the seconds that the loading needs for one percent.
The template sensor shows the calculated time.
sensor:
- platform: sql
db_url: !secret db_url
scan_interval: 86400
queries:
- name: e3dc_time_batt_percent
query: "select CAST(timestampdiff(second,
(select created from states where entity_id = 'sensor.e3dc_battery_percent'
and state != 'unknown' order by created desc limit 1,1),
(select created from states where entity_id = 'sensor.e3dc_battery_percent'
and state != 'unknown' order by created desc limit 1)
) AS CHAR CHARACTER SET utf8) as time_percent"
column: 'time_percent'
unit_of_measurement: 'sec'
- platform: template
sensors:
e3dc_batt_loading_end:
value_template: >
{% set remain = 100 - (states('sensor.e3dc_battery_percent') | int) %}
{% set timepercent = states('sensor.e3dc_time_batt_percent') | int %}
{{ (as_timestamp(now()) + remain * timepercent) | timestamp_custom('%H:%M', true)}}
The sensor gets only updated with an automation when the value of the sensor changes.