Code adapted from a python file found in the Whatsminer Telegram group that is credited to @passby
Python 3.x is required (tested on Python 3.11 and newer).
pip install pywhatsminer
Instantiate a Client for each ASIC that you want to access. Then make read-only or writeable API calls by using the chapters and their methods.
Read-only information can be retrieved with just the ASIC's ip address:
from pywhatsminer import Client
asic = Client(ip="192.168.0.117")
summary = asic.System.get_summary()
print(summary)The methods of recording and interacting with the machine require authorization using an administrator password:
from pywhatsminer import Client
asic = Client(ip="192.168.0.117", port=4028, password="SatoshiAnonymoto123")
asic.Power.off()Tokens for writeable API calls are renewed automatically after they expire (30 minutes).
You could define a whole server farm's worth of Whatsminer ASICs and manage them all in one script:
from pywhatsminer import Client
asics = [
Client(ip="192.168.0.117", port=4028, password="123"),
Client(ip="192.168.0.118", port=4028, password="123"),
Client(ip="192.168.0.119", port=4028, password="123")
]
for asic in asics:
if asic.System.get_summary().temperature > 80:
asic.Power.off(respbefore=True)At the moment, the project is under development, so the documentation on the methods is not ready yet, but nevertheless, you can use the documentation on the methods of the Whatsminer API, which will repeat most of the names of the methods and their logic in the module.
There are just notes to self for updating the pypi distribution
- Update the release number in
setup.pyand commit to repo. - Draft a new release in github using the same release number.
- Run
python setup.py sdist - Publish the distribution to pypi:
twine upload dist/*