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

Add support for X3 MIC/PRO G2 #116

Merged
merged 6 commits into from
Jun 10, 2023
Merged

Conversation

niclasku
Copy link
Contributor

@niclasku niclasku commented Jun 4, 2023

I implemented support for the X3-MIC/PRO-G2 using the tables published in issue #101. This pull request should solve issue #84. I tested this implementation with my inverter at home.

@squishykid Thank you for starting this great project!

@horamarques
Copy link

when can we have a release with this PR?
Thank you all for the great work.

@niclasku
Copy link
Contributor Author

niclasku commented Jun 9, 2023

I think it is ready to get merged. Please note that Home Assistant 2023.6 is required (home-assistant/core#92914).

@squishykid Are you happy with simply enumerating the sensors instead of using their internal id (fix for #112)? Using their internal id breaks Home Assistant if one inverter property is used twice (e.g. returning inverter state as text and as numerical value). Let me know if you have a better solution. I can implement it.

@@ -2,7 +2,7 @@
import asyncio
import logging

import async_timeout
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these changes are strictly required for this PR. Are you doing this because there is a new API available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change. Yes, there is an API change and a deprecation warning:

tests/test_smoke.py: 18 warnings
tests/test_solax.py: 3 warnings
/Users/niclas/PycharmProjects/solax/solax/__init__.py:25: DeprecationWarning: with timeout() is deprecated, use async with timeout() instead with async_timeout.timeout(REQUEST_TIMEOUT)

Shall I raise another PR for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raised a PR #123 to address this issue.

@@ -82,19 +82,15 @@ def sensor_map(cls) -> Dict[str, Tuple[int, Measurement]]:
Warning, HA depends on this
"""
sensors: Dict[str, Tuple[int, Measurement]] = {}
for name, mapping in cls.response_decoder().items():
for idx, (name, mapping) in enumerate(cls.response_decoder().items()):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that you're implementing these changes to address #112 . However we need to be careful not to change the names of existing sensors in home-assistant, as this would be a breaking change. Please revert this for now. We need to implement this separately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change. Additionally, I commented out the numerical run mode sensor to not return two sensors with the same id. We should consider to also comment out line 71 of x3_hybrid_g4.py for the same reason:

"Run mode": (19, Units.NONE),
"Run mode text": (19, Units.NONE, X3HybridG4._decode_run_mode),

Shall I raise another PR for this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, feel free to raise a separate PR to address #112. I think the easy one would just be to remove the non-text-mode "run mode" sensor from x3_hybrid_g4. But if you implement something which can keep both and doesn't change the names for existing sensors, that's great!

Copy link
Contributor Author

@niclasku niclasku Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I raised a PR #122 to address this issue.

@squishykid
Copy link
Owner

Just revert the changes in those two files and this is ready to merge! Thank you for raising the PR!

@niclasku niclasku requested a review from squishykid June 10, 2023 08:51
@squishykid
Copy link
Owner

This looks great. Thank you!

@squishykid squishykid merged commit e17c930 into squishykid:master Jun 10, 2023
@squishykid
Copy link
Owner

v0.3.2 should be available on PyPi shortly, which includes your change

To have your new inverter appear in home-assistant, you will need to make another PR in home-assistant/core. There is an example here: home-assistant/core#78219

@niclasku
Copy link
Contributor Author

Thanks for merging! I have just raised the Home Assistant PR: home-assistant/core#94545

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.

3 participants