-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implement inverter.py own logger / Python 3.9 retro-compatibility / Restore .connected attribute #35
Merged
Conversation
This file contains 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
This is a proposal to replace the `match/case/case...` by `if/elif/elif.../else` in the function `.decode()` to ensure compatibility with python 3.9 and earlier. The use of `match/case` in this function is the only place in the whole package where a construction requires python >= 3.10. The proposed modification seems worth because python 3.9 is still widely used; it is e.g. the version available in Debian/oldstable repositories, which is still supported.
This is a proposal to reintroduce the '.connected` attribute. Its suppression in recent versions of the module causes errors in programs using earlier versions. In this proposal, an equivalent is reintroduced, now as a property, relying directly on the new `.isConnected()` method.
Retro-compatibility with python 3.9
Reintroduce `.connected` attrubute
This proposal implements an own logger for the `sun2000_modbus.inverter` module. Before, it was using the default "root" logger. If a program using the module needed to mute its log messages, the only option was to mute the "root" logger, which also muted messages from all other loggers. A module-specific logger can be tuned without impact on other loggers and its messages will clearly display their origin as "sun2000_modbus.inverter" instead of "root". Usage examples (in a custom program): 1°) catch the logger inv_log = logging.getLogger("sun2000_modbus.inverter") 2°) use one of the following instructions inv_log.setLevel(logging.INFO) # original behaviour inv_log.setLevel(logging.ERROR) # or any other level inv_log.disabled = True # disables this logger only
Implement sun2000_modbus.inverter own logger
This proposal implements the formatting numbers with the proper thousand separator and decimal sign according to the locale for the `.read_formatted()` function. To use this feature, a module should at first ` import locale locale.setlocale(locale.LC_ALL, '') ` and then call `.read_formatted()` with the named parameter `use_locale` set to `True`, for example: `read_formatted(register, use_locale=True)`.
olivergregorius
approved these changes
Apr 3, 2024
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.
No description provided.