ha-average
ha-average copied to clipboard
Update group entity sources when group members change
Is your feature request related to a problem? Please describe. The main issue I'm having is that whenever I add an entity to a group to be used with this integration, the new entity isn't factored by the integration. For example, I have the group "average temperature" and in the group I have 2 entities, one with 50F and the other with 100F. The initial average is 75F, but when I add another entity to the group via a service call, this integration doesn't take into account the third entity I just added and the average is still 75F.
Describe the solution you'd like I'd like the integration to have a way of knowing that the group's members have changed, and then get the new entities it should use in the averaging function. OR, if the integration can't "listen" to changes, just add an option for the number of minutes the integration will refresh the group's membership.
Describe alternatives you've considered No other alternatives that I know of.
Additional context This integration is the cornerstone of my thermostat in home assistant. It would save me a lot of manual work if group members could be refreshed every now and then.
I tried to implement your idea, but there were difficulties: at the time of sensor initialization, it creates a task to track changes in the states of all source sensors. To do this, it expands each group to a list of individual sensors. That is why you cannot change the calculations when adding a new group member.
As a solution, I can try to make a service that will restart the sensor initialization (#135). Will it be a convenient solution?