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

Optional model parameter #133

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8c49f5f
Update discovery.py
rowinho Jan 3, 2023
2c55cbc
Update x3_hybrid_g4.py
rowinho Jan 3, 2023
c500548
Update x3_hybrid_g4.py
rowinho Jan 3, 2023
e6d9ec3
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
8aecd4c
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
d06cf0f
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
f5ba902
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
465d14f
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
c93f0d0
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
0928bc9
Update x3_hybrid_g4.py
rowinho Sep 15, 2023
b33f294
Update discovery.py
rowinho Sep 18, 2023
8bf2794
Update x3_hybrid_g4.py
rowinho Sep 18, 2023
8fac029
Merge pull request #1 from squishykid/master
rowinho Sep 18, 2023
99765f3
Update x3_hybrid_g4.py
rowinho Sep 18, 2023
b96605d
Update discovery.py
rowinho Sep 18, 2023
43b5ab5
Update discovery.py
rowinho Sep 18, 2023
b266bcf
Update x3_hybrid_g4.py
rowinho Sep 18, 2023
c6e9932
Update discovery.py
rowinho Sep 18, 2023
f06f6f9
Update __init__.py
rowinho Sep 18, 2023
580363e
Update __init__.py
rowinho Sep 18, 2023
d6e371c
Update discovery.py
rowinho Sep 18, 2023
6d8cdff
Update discovery.py
rowinho Sep 18, 2023
0ae4af3
Update discovery.py
rowinho Sep 18, 2023
5165343
Update discovery.py
rowinho Sep 18, 2023
caff52e
Update discovery.py
rowinho Sep 18, 2023
5eaeebb
Update discovery.py
rowinho Sep 18, 2023
5759b52
Update discovery.py
rowinho Sep 18, 2023
d281a6b
Update discovery.py
rowinho Sep 18, 2023
3c4098d
Update x3_hybrid_g4.py
rowinho Sep 18, 2023
ccedf54
Update discovery.py
rowinho Sep 18, 2023
807ccee
Update discovery.py
rowinho Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions solax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async def rt_request(inv: Inverter, retry, t_wait=0) -> InverterResponse:
raise


async def real_time_api(ip_address, port=80, pwd=""):
i = await discover(ip_address, port, pwd)
async def real_time_api(ip_address, port=80, pwd="", model=""):
i = await discover(ip_address, port, pwd, model)
return RealTimeAPI(i)


Expand Down
20 changes: 13 additions & 7 deletions solax/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ async def _discovery_task(cls, i) -> Inverter:
await i.get_data()
return i

async def discover(self, host, port, pwd="") -> Inverter:
async def discover(self, host, port, pwd="", model=None) -> Inverter:
for inverter in REGISTRY:
for i in inverter.build_all_variants(host, port, pwd):
task = asyncio.create_task(self._discovery_task(i), name=f"{i}")
task.add_done_callback(self._task_handler)
self._tasks.add(task)
if inverter.__name__ == model or model is None:
for i in inverter.build_all_variants(host, port, pwd):
task = asyncio.create_task(self._discovery_task(i), name=f"{i}")
task.add_done_callback(self._task_handler)
self._tasks.add(task)

while len(self._tasks) > 0:
logging.debug("%d discovery tasks are still running...", len(self._tasks))
Expand All @@ -97,7 +98,12 @@ class DiscoveryError(Exception):
"""Raised when unable to discover inverter"""


async def discover(host, port, pwd="") -> Inverter:
async def discover(host, port, pwd="", model=None) -> Inverter:
discover_state = DiscoveryState()
await discover_state.discover(host, port, pwd)
await discover_state.discover(host, port, pwd, model)
return discover_state.get_discovered_inverter()

def get_models() -> List[str]:
models = list(map(lambda inverter: inverter.__name__, REGISTRY))
models.sort()
return models