Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor performance in climate mode #282

Open
3 tasks done
briancmpbll opened this issue Aug 9, 2024 · 1 comment
Open
3 tasks done

Poor performance in climate mode #282

briancmpbll opened this issue Aug 9, 2024 · 1 comment

Comments

@briancmpbll
Copy link

What version of Adaptive Cover are you using?

1.4.2

What version of Home Assistant are you using?

2024.8.0

Checklist

  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

I have a template weather entity created from various entities from a tempest weather station. The tempest updates frequently, so the template weather entity also updates frequently.I created an instance of this integration in climate mode using this weather entity, and I noticed very high CPU usage after creating this instance. I could barely use homeassistant, so I did some debugging.

It looks like coordiator.async_check_entity_state_change gets fired multiple times a second from this particularly talkative weather entity. This causes shade position to get calculated multiple times a second, as well as normal_cover.solar_times, which is created in a separate thread.

I'm guessing the integration is spawning multiple threads per second to run solar_times, which is what is causing the high CPU load. I modified the coordinator.py file to only run solar_times on first refresh or if the entity that fired the state change event is sun.sun, and this resolved the CPU load issue, but the End Sun and Start Sun entities are now Unknown. I must have gotten some logic wrong about when and how to update them.

I also think there are multiple improvements that could be made in terms of how often calculations are run in climate mode beyond this one, such as ignoring weather entity events that don't modify the temperature or condition.

Reproduction steps

Create an instance of the integration in climate mode with a talkative weather entity.
Observe CPU load and responsiveness of the system.
Remove the loop.run_in_executor call to run normal_cover.solar_times in coordinator.py.
Restart homeassistant.
Observe improved CPU load and responsiveness of homeassistant.

Diagnostics dump

No response

@glc1031
Copy link

glc1031 commented Oct 2, 2024

I have this issue also. I'm seeing 3 to 4 per second per integration. I have 18 tilt blinds most on the west and south walls. Several I need to control independently so that I can disable the integration when I don't want the blinds to open. If I run enough instances to do what I want, the CPU is taxed so much the whole home assistant becomes unresponsive. If pushed too hard it reboots.

Debug log with just once instance enabled.

2024-10-02 05:37:13.655 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:37:13.655 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:37:13.658 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:37:13.659 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:37:13.659451, now < time: True 2024-10-02 05:37:13.660 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:37:13.660086, now >= time: True 2024-10-02 05:37:13.661 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:37:13.661 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:05:05.280584, threshold: 15.0, condition: False 2024-10-02 05:37:13.661 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:37:13.661 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:37:13.662 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:37:13.664 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:37:13.666 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:37:13.665717, now < time: True 2024-10-02 05:37:13.676 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:37:13.675832, now >= time: True 2024-10-02 05:37:13.676 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:37:13.676 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:05:05.295587, threshold: 15.0, condition: False 2024-10-02 05:37:13.676 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:37:15.812 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 2.157 seconds (success: True) 2024-10-02 05:37:15.817 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 2.155 seconds (success: True) 2024-10-02 05:37:41.115 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:37:41.116 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:37:41.119 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:37:41.123 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:37:41.122430, now < time: True 2024-10-02 05:37:41.124 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:37:41.124151, now >= time: True 2024-10-02 05:37:41.124 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:37:41.125 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:05:32.744473, threshold: 15.0, condition: False 2024-10-02 05:37:41.125 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:37:41.984 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 0.868 seconds (success: True) 2024-10-02 05:38:14.671 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:38:14.672 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:38:14.676 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:38:14.681 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:38:14.680244, now < time: True 2024-10-02 05:38:14.683 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:38:14.682501, now >= time: True 2024-10-02 05:38:14.683 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:38:14.695 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:06:06.314236, threshold: 15.0, condition: False 2024-10-02 05:38:14.695 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:38:14.696 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:38:14.696 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:38:14.710 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:38:14.712 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:38:14.711554, now < time: True 2024-10-02 05:38:14.724 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:38:14.723837, now >= time: True 2024-10-02 05:38:14.724 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:38:14.724 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:06:06.344017, threshold: 15.0, condition: False 2024-10-02 05:38:14.725 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:38:16.047 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for binary_sensor.system_monitor_process_s6_ipcserverd (<class 'homeassistant.components.systemmonitor.binary_sensor.SystemMonitorSensor'>) took 0.422 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+systemmonitor%22 2024-10-02 05:38:19.879 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 5.208 seconds (success: True) 2024-10-02 05:38:19.888 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 5.192 seconds (success: True) 2024-10-02 05:39:15.669 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:39:15.669 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:39:15.675 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 0 2024-10-02 05:39:15.679 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:39:15.679284, now < time: True 2024-10-02 05:39:15.682 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:39:15.680689, now >= time: True 2024-10-02 05:39:15.683 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 0, delta position: 2, min_change: 5.0, condition: False 2024-10-02 05:39:15.683 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:07:07.302768, threshold: 15.0, condition: False 2024-10-02 05:39:15.683 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:39:18.049 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 2.380 seconds (success: True) 2024-10-02 05:39:28.712 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:39:28.712 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:39:28.717 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 44 2024-10-02 05:39:28.722 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:39:28.718666, now < time: True 2024-10-02 05:39:28.724 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:39:28.723579, now >= time: True 2024-10-02 05:39:28.725 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 44, delta position: 42, min_change: 5.0, condition: True 2024-10-02 05:39:28.727 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:07:20.346814, threshold: 15.0, condition: False 2024-10-02 05:39:28.728 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:39:30.978 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 2.266 seconds (success: True) 2024-10-02 05:40:16.693 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:40:16.694 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:40:16.703 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 44 2024-10-02 05:40:16.705 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:40:16.704294, now < time: True 2024-10-02 05:40:16.714 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:40:16.714162, now >= time: True 2024-10-02 05:40:16.715 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 44, delta position: 42, min_change: 5.0, condition: True 2024-10-02 05:40:16.715 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:08:08.334443, threshold: 15.0, condition: False 2024-10-02 05:40:16.715 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:40:16.716 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:40:16.716 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:40:16.732 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 44 2024-10-02 05:40:16.734 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:40:16.734146, now < time: True 2024-10-02 05:40:16.742 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:40:16.741494, now >= time: True 2024-10-02 05:40:16.742 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 44, delta position: 42, min_change: 5.0, condition: True 2024-10-02 05:40:16.742 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:08:08.362038, threshold: 15.0, condition: False 2024-10-02 05:40:16.743 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:40:16.744 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change 2024-10-02 05:40:16.744 DEBUG (MainThread) [custom_components.adaptive_cover.const] Updating data 2024-10-02 05:40:16.761 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 44 2024-10-02 05:40:16.763 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-10-03 00:00:00, now: 2024-10-02 05:40:16.762890, now < time: True 2024-10-02 05:40:16.765 DEBUG (MainThread) [custom_components.adaptive_cover.const] Start time: 2024-10-02 00:00:00, now: 2024-10-02 05:40:16.764651, now >= time: True 2024-10-02 05:40:16.765 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, position: 2, state: 44, delta position: 42, min_change: 5.0, condition: True 2024-10-02 05:40:16.777 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.blind_tilt_8dcb, time delta: 0:08:08.396605, threshold: 15.0, condition: False 2024-10-02 05:40:16.777 DEBUG (MainThread) [custom_components.adaptive_cover.const] State change handled 2024-10-02 05:40:23.875 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 7.159 seconds (success: True) 2024-10-02 05:40:23.906 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 7.212 seconds (success: True) 2024-10-02 05:40:24.016 DEBUG (MainThread) [custom_components.adaptive_cover] Finished fetching adaptive_cover data in 7.272 seconds (success: True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants