I found this great integration the other day when I was looking for a way to calculate an average of current electricity consumption in real-time. As I’m presenting the value on a wall tablet I don’t want it to update every second but an average of the measurements from the last 10 secs and a new calculation done every 10 secs.
I have two questions:
Is it possible to set the rate when the average is calculated? Right now is looks like every 30 secs.
Is it possible to remove the decimals to just show the integer? Right now .0 is shown.
So I installed this sensor, and it appears to have an issue. I defined an automation which will trigger whenever the average sensor goes above 1000. It works as expected when value goes from 900 to 1,100, but the problem is that it keeps triggering the action when it goes from 1,100 to 1,500 to 2,000 and so forth.
Any ideas how to solve this?
Ok, so I will be more specific - if I use the average sensor on Philips Hue light sensor (which is in fact a motion sensor) - so the values per the average sensor will be ‘lightlevel’ (and not for example, lux)?
I’m sorry, I’m not using the Philips Hue Light Sensor and cannot answer you for sure.
The Average Sensor will take the history values of the sensor you provided and calculate the average. It will use the same units as on the original sensor. Attribute values are not included in calculations.
Every time the source data is updated Average Sensor updates its value;
Every time the Average Sensor value is updated, your automation wakes and the conditions for its triggering are checked;
If the conditions are acceptable, the automation works completely.
This is where it happens that the automation is triggered many times when the value is above the specified threshold.
In order for it to run only once, you need to come up with a way to check that the value was previously below the threshold and start automation only in this case.
But this does not apply to the Average Sensor topic anymore, sorry.
That’s all right. If there is a calculation period, the sensor is updated approximately once every 30 seconds. The reason is that as the update period decreases, the load to the system increases dramatically. So you have to be careful with that.
As far as I understand, you can add the scan_interval field to the sensor settings indicating the required update period. This can be applied to any entity in HA, not only to this sensor, since this property is handled by the HA core itself.
I will try to solve this, but I’m not sure if this is possible in principle: the sensor does not set the format of the data output — HA itself is responsible for this.
The mechanism for specifying the unique ID of sensors has been changed. To prevent duplicate sensors from being created, add option unique_id: __legacy__ to the settings of already available sensors. For more information, see the component’s documentation.
So I got stung by this and got duplicate _2 sensors.
I just deleted all the original ones which was easy to do with a few clicks in configuration>entities. Then restarted HA and all the _2’s were now the original sensor again complete with their history. No editing config to add legacy needed. Seems way quicker this way than doing that edit…
If you have many, adding legacy is a nightmare. If you search for average in the entities screen it’s just a few clicks to mark and delete all the old ones then restart.