can't get average temperature over a 1 day period of last week
OldSurferDude opened this issue · comments
OldSurferDude commented
Environment
- Home Assistant Core release with the issue: 2023.4.0
- This custom component release with the issue: Average Sensor 2.3.0
- Last working this custom component release (if known):
- Operating environment (Home Assistant/Supervisor/Docker/venv): Supervisor
Describe the bug
Configuration.yaml
Add your configs here if any.
homeassistant:
name: Carlsbad
latitude: 33.17044842799367
longitude: -117.3212240116212
time_zone: America/Los_Angeles
# Loads default set of integrations. Do not remove.
default_config:
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
# Averaging temperatures for calibration
sensor:
- platform: average
name: 'Average Temp'
end: '{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0) ) - now().weekday() * 432000 }}'
duration:
days: 1
entities:
- sensor.batmoisthumtemp_133_4
![graph showing average](https://user-images.githubusercontent.com/21992042/230474049-6840a15a-519a-4ec2-a1ff-9c878bfbf6b7.jpg)
![Graph showing data from target period](https://user-images.githubusercontent.com/21992042/230474078-1faacd01-f84b-4dc5-a9fd-f1e609a8e15d.jpg)
Steps to Reproduce
Expected behavior
Debug log
Add your logs here.
Additional context
obelix05 commented
I think i have the same issue. I want to get the average from yesterday between 8 a.m. and 4 p.m.
I noticed, that the count of the average sensor is only 4. I want to get the average of two sensors. Could you check this on your side?
Does anyone have an idea on how to solve this?
I tried different types of config (start + end, start + duration, end + duration). Currently it looks like:
- platform: average
name: 'Daily Average Temperature'
end: "{{ now().replace(day=now().day-1, hour=16).replace(minute=0).replace(second=0) }}"
duration:
hours: 8
entities:
- weather.dwd_weather_hamburg_innenstadt
- weather.openweathermap
unique_id: sensor.daily_average_temperature
OldSurferDude commented
I ending up extracting the data from the database. Here's how I did it. Be sure to note the comment that describes an easier way ;)
OSD