Average Sensor

Very strange.
Did you manage to get any logs?

Once again made changes.

Now the logic of work is as follows:

  • If the duration parameter is specified, updating the sensor value occurs regularly, but no more than once every 20 seconds;
  • If this parameter is not specified, the sensor value is updated every time any of the sensors is updated, where the source values ​​come from.

You can test again :slight_smile:: https://github.com/Limych/ha-average/tree/develop/custom_components/average

Hi,

thanks for that custom component!
I just added some sensors for testing and wonder if i have to add all the custom sensors to my recoder include when using the history graph card?

It is up to you. I just give the instrument. It all depends on what you want to get in the end.

Is there a way to use 2 sensor instances, like this?:

sensor:
  - platform: average
    name: 'Downstairs average temperature'
    entities:
      - sensor.lumi_lumi_weather_ad594404_temperature
      - sensor.lumi_lumi_weather_12114a04_temperature
      - sensor.lumi_lumi_weather_9315f103_temperature
      - sensor.lumi_lumi_weather_a6014a04_temperature
sensor:
  - platform: average
    name: 'Upstairs average temperature'
    entities:
      - sensor.lumi_lumi_weather_28344b04_temperature
      - sensor.lumi_lumi_weather_41624404_temperature

It worked briefly, maybe 2 days, then only displays the ‘Upstairs average temperature’

There is no average platform for sensor (maybe a custom component?) Are you sure this worked?

See here:

this custom component allows creating average sensors .

My bad… didn’t read from the beginning :neutral_face:

average
Sure did, now it’s just the Upstairs average temperature…

I don’t quite get what is the problem and what exactly worked briefly?

If you look at the code there are 2 separate sensor instances. One upstairs (red on the graph), one for downstairs (green on the graph). Both showed up for a day, now only the upstairs.

Where?
I take you posted a Lovelace card of one of them - do you expect both on one card?

Apparently we have some differences with our vocabularies. The red (upstairs temperature) and green (downstairs temperature) values displayed at the same intervals, for roughly 2 days. Then the downstairs average temperature disappeared from the graph and I am unable to see it again.

You CANT have 2 sensor sections…

sensor:
|
|
sensor:

That is INVALID

sensor:
  - platform: average
    name: 'Downstairs average temperature'
    entities:
      - sensor.lumi_lumi_weather_ad594404_temperature
      - sensor.lumi_lumi_weather_12114a04_temperature
      - sensor.lumi_lumi_weather_9315f103_temperature
      - sensor.lumi_lumi_weather_a6014a04_temperature
  - platform: average
    name: 'Upstairs average temperature'
    entities:
      - sensor.lumi_lumi_weather_28344b04_temperature
      - sensor.lumi_lumi_weather_41624404_temperature

That is valid and should work. I have multiple average sensors configured

1 Like

I appreciate your help, David. But why the heck did it work for a few days then quit? Now I see that it should have never operated properly and I did not change anything in configuration.yaml, and yes it is working properly now.

Yep

You must have.

I’d have to agree with @DavidFW1960 something may have changed even somewhere else… an error in parsing the yaml above or below your sensor could have somehow oddly made it work temporarily… but once something was changed (possibly anywhere in your config) it now picked up both sensor: lines and started ignoring one of them… possibly an error in yaml just above the first sensors: caused it to ignore the first one thinking it was part of the yaml above… I’ve done something similar myself.

So, I must be doing something wrong. I have created the sensor, it has data and I have added it to my history component.

Here is my config under my sensor folder:

- platform: average
  name: 'Average Temperature BR temp'
  duration: 15
  entities:
    - sensor.br_temp

Sensor history graph card and config:
image

entities:
  - sensor.br_temp
  - sensor.average_temperature_br_temp
  - sensor.br_hum
refresh_interval: 60
show_header_toggle: false
title: Bathroom ESP
type: history-graph

And yes, the sensor is created:

So, why when it is added to the history card do I not even see it listed in the header and why do I not see data? I would like it to establish a rolling average of the room temp over the time period of the card.

I should add that a history card with only that entry looks like this:
image

I assume that I am misunderstanding something about the operation of this sensor.
Thanks Matt

I found an error… had one to many spaces between the dash and the sensor name in the history component.

Now I see the data…

My question is as follows… I am trying to keep a rolling average of this data point that should yield a smooth’ish curve. I am trying to figure out what interval to generate the data point… Should I go for minutes? do I need to set it up for 24 hours? I am not sure I understand the data gathering and reporting part of this.

I am or was expecting a median line that runs through the graph… how does one get there?

It’s simple: the sensor averages the data over your chosen range. The more you set a measure window for it, the smoother the line will be. For example, to calculate the average temperature outside, I use data for three days.

I think, for the smoothness of your line, it is reasonable to set the range so that inside it there are about three temperature peaks. Judging by the schedule in your picture, you have air conditioning. One peak you have is about 1 hour 45 minutes. So the range of 5 hours will capture about 3 peaks.
Try the following settings:

- platform: average
  name: 'Average Temperature BR temp'
  duration:
    hours: 5
  entities:
    - sensor.br_temp