Limych / ha-average

Average Sensor for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High CPU usage

jhrath opened this issue · comments

Environment

  • Home Assistant Core release with the issue: 2021.11.5
  • This custom component release with the issue: 2.2.0
  • Last working this custom component release (if known): I don't know
  • Operating environment (Home Assistant/Supervisor/Docker/venv): Proxmox. supervisor-2021.12.1. Home Assistant OS 6.6

Describe the bug

I have had this integration installed for some time but not using it. I started using it, and the server's average CPU load increased from 7% to 37%.

Configuration.yaml

sensor:
  - platform: average
    name: 'Ventilasjon snitt 24 timer'
    duration:
      hours: 24
    precision: 0
    entities:
      - sensor.bod_vent_plug_power
  - platform: average
    name: 'Ventilasjon snitt 1 uke'
    duration:
      days: 7
    precision: 0
    entities:
      - sensor.bod_vent_plug_power

Steps to Reproduce

I just started using the integration, and the CPU load jumped to 37%. I tested #-ing out the sensors to stop using it, and the load fell to 7% imediately. Removed the # in front of the code, and it was back to 37%.

Expected behavior

Debug log


Add your logs here.

Additional context

The sensor is based on input from a z-wave power plug, and the "count" for input values on one of my two sensors are now ca. 180.000 (one week)

I'm sorry, but I can't think of a more optimal version of the calculation of the average than is currently included in the program. The reason for the high processor load is solely in the amount of data that you collect. Do you really need to store such detailed indicators? When using influxdb, for example, it is possible to configure the replacement of detailed indicators with average values for a specified period. This allows you to dramatically reduce the load on the processor and hard drive without compromising the information content of the data.

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.