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

Set instance INFO_RESOURCES instead of mutating class INFO_RESOURCES for brp069 #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brentthew
Copy link

I have 3 DaikinBRP072C based units, and found that logs indicated that each unit is making 3x calls for aircon/get_week_power.

2024-12-28 22:59:43.049 DEBUG (MainThread) [pydaikin.daikin_base] Updating ['aircon/get_sensor_info', 'aircon/get_control_info', 'aircon/get_week_power', 'aircon/get_week_power', 'aircon/get_week_power']
2024-12-28 22:59:43.049 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_sensor_info {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 22:59:43.051 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_control_info {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 22:59:43.051 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_week_power {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 22:59:43.051 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_week_power {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 22:59:43.051 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_week_power {} [{'X-Daikin-uuid': 'xxx'}]

DaikinBRP069's class variable INFO_RESOURCES is being mutated in init, and as a result each new instance of the class is adding duplicated entries to a shared list.

Fixed by reassigning INFO_RESOURCES so it becomes a copy that's local to the instance. Logs after the fix:

2024-12-28 23:09:49.226 DEBUG (MainThread) [pydaikin.daikin_base] Updating ['aircon/get_sensor_info', 'aircon/get_control_info', 'aircon/get_week_power']
2024-12-28 23:09:49.227 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_sensor_info {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 23:09:49.228 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_control_info {} [{'X-Daikin-uuid': 'xxx'}]
2024-12-28 23:09:49.228 DEBUG (MainThread) [pydaikin.daikin_base] Calling: https://daikin-dining/aircon/get_week_power {} [{'X-Daikin-uuid': 'xxx'}]

@brentthew brentthew force-pushed the duplicate_info_resources branch from d350665 to 758efa3 Compare December 28, 2024 22:35
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

Successfully merging this pull request may close these issues.

1 participant