Refactor#250
Merged
Merged
Conversation
Extract 3 dataclasses into soc_types.py and learning/persistence functions into soc_learning.py. SOCPredictor keeps thin delegates preserving the public API.
Extract CircuitBreaker class into stream_circuit_breaker.py and reconnection/auth/retry functions into stream_reconnect.py. All public API methods stay on CardataStreamManager as delegates.
Move setup/unload orchestration to lifecycle.py and token refresh loop to auth.py. __init__.py is now a thin delegate with just the three HA entry-point functions.
Move 12 descriptor path strings and the 60s lock acquisition timeout into named constants in const.py, replacing inline literals across 13 files. No functional changes.
- Remove loop_stop(force=) calls (parameter removed in paho v2) - Remove dead on_connack callback (on_connect handles CONNACK in v2) - Add missing return statement in stream_cardata.py main() - Fix Iterable→Sequence type for argparse.parse_args() compatibility
- Remove fuzz_quota_manager.py (quota.py deleted in e96364c) - Fix fuzz_stream_payload TIMESTAMPED_SOC_DESCRIPTORS import (moved from coordinator.py to message_utils.py) - Fix fuzz_gps_pairing mock: add missing add_job() and get_derived_is_moving() methods
Extract unit mapping helpers into sensor_helpers.py and diagnostic entity classes into sensor_diagnostics.py.
Owner
|
My effenciency refactor is also working (well getting the right ff with different charges so prolly will implement that one on of these days, it is backwards compatible. Adds a little bit off extra in in but effenciency calcualtion staus the same. Just more way to work with it |
Owner
|
Fuck this refactor is a ball kicker lol :D but i'll get it to work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keep all files below 1000 lines for readability.
Put reused values into constants.
Fix mypy issues.
As requested by HA best practices, keep __init__ tiny.
Fix fuzzers.
111 custom_components/cardata/api_parsing.py
677 custom_components/cardata/auth.py
295 custom_components/cardata/binary_sensor.py
468 custom_components/cardata/bootstrap.py
252 custom_components/cardata/button.py
785 custom_components/cardata/config_flow.py
251 custom_components/cardata/const.py
395 custom_components/cardata/container.py
267 custom_components/cardata/coordinator_housekeeping.py
754 custom_components/cardata/coordinator.py
46 custom_components/cardata/debug.py
41 custom_components/cardata/descriptor_state.py
326 custom_components/cardata/descriptor_titles.py
280 custom_components/cardata/device_flow.py
219 custom_components/cardata/device_info.py
534 custom_components/cardata/device_tracker.py
240 custom_components/cardata/entity.py
354 custom_components/cardata/http_retry.py
234 custom_components/cardata/image.py
54 custom_components/cardata/__init__.py
673 custom_components/cardata/lifecycle.py
700 custom_components/cardata/magic_soc.py
153 custom_components/cardata/message_utils.py
682 custom_components/cardata/metadata.py
211 custom_components/cardata/migrations.py
581 custom_components/cardata/motion_detection.py
210 custom_components/cardata/number.py
316 custom_components/cardata/pending_manager.py
403 custom_components/cardata/ratelimit.py
289 custom_components/cardata/runtime.py
256 custom_components/cardata/sensor_diagnostics.py
208 custom_components/cardata/sensor_helpers.py
486 custom_components/cardata/sensor.py
626 custom_components/cardata/services.py
415 custom_components/cardata/soc_learning.py
711 custom_components/cardata/soc_prediction.py
158 custom_components/cardata/soc_types.py
684 custom_components/cardata/soc_wiring.py
175 custom_components/cardata/stream_circuit_breaker.py
726 custom_components/cardata/stream.py
283 custom_components/cardata/stream_reconnect.py
589 custom_components/cardata/telematics.py
51 custom_components/cardata/units.py
263 custom_components/cardata/utils.py
16432 total