-
Notifications
You must be signed in to change notification settings - Fork 8
feature: add pyasic miner adapter #27
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
base: dev
Are you sure you want to change the base?
Conversation
CC: #3 |
Thanks @b-rowan for your contribution |
We have a conflict with dependencies:
the issue is with |
Digging deeper I saw that It is possible to downgrade homeassistant-api version and upgrade pydantic version. Modified versions:
Use this branch to test: https://github.com/edge-mining/core/tree/feature-add-pyasic-miner-adapter |
If it's a huge deal I could in theory downgrade the required version of pydantic in pyasic, but seems like you got it resolved. |
Happy to update this branch as needed with changes, I'm just not fully familiar with the project so not sure what else is required to implement this adaptor. |
Starting from your excellent work, I've added everything necessary to fully integrate the PyAsic adapter into the rest of the application. Now that it has been fully incorporated, the only thing left is to give it a quick check to verify that everything is working as it should, so we can merge it into the main branch. I don't have a miner and don't have the ability to test the functionality myself, but if someone is willing to, they can follow these steps:
|
I wrote a small simulator a while back for this exact thing, I'm not sure it keeps track of on/off state internally, but it should suffice for small tests. |
I'm trying it right now. For what it's needed, it does the job. Thanks, It is really a great solution, It will be very helpful! 👍 I'm fixing some issues with asynchronous function calls in mixed The fastest option I think to implement (and sure also the least elegant) is to call the async functions via a dedicated function that splits the Something like: def run_async_func(func: Callable[[], Coroutine[Any, Any, T]]) -> T:
try:
asyncio.get_running_loop() # Triggers RuntimeError if no running event loop
with ThreadPoolExecutor(1) as pool:
return pool.submit(lambda: asyncio.run(func())).result()
except RuntimeError:
return asyncio.run(func()) What do you think? Do you have any suggestions that might be helpful? |
I see no issues with this. The idea scenario IMO would be if the caller of the adaptor functions (one level above my understanding of what you are suggesting) could inspect the signatures of the functions in the adaptor and call it automatically (this is what FastAPI does). Also nitpicking on the code in this comment, I believe you can use |
I appreciate the point about using Using Anyway, thanks for the suggestions. |
Hi! We tried testing the Pyasic adapter with a miner. |
…trieval before operations and fix typo
…an up code formatting
…ddress validation
…o be compatible with pyasic
Rebased onto @GitGab19 anything else that needs to be done? |
Usually |
Awesome, thank you for doing it. The other guys told me they wanted to test this PR with a real miner before merging it. So I think we just need that and, together with a review, it should be good to go. |
Great! I wanted to ask you to merge the branch I created for testing with the one in your pull request, but you were quicker and already did it all yourself. 👍
You can do that adding the required authentication data to the The miner controller instance is created only once, the first time an instance of its ID is requested, and is then cached using the Adapter Service. Adapter Service takes care of retrieving the parameters saved in the configuration from the database (each type of miner adapter has its own) and passing them to the adapter constructor, which uses them to create the new instance. Any parameters required for the adapter to work can be added to the configuration and passed to the adapter constructor. I hope I've been clear, if not I'll try to explain myself better. 🙂 |
Super basic starter implementation of a miner adapter using pyasic. Good chance it is completely broken since I am using
asyncio.run
to run all tasks, and I also likely missed some stuff, but a good start for feedback.