All,
Please see the following links for quick access to Whatsminer API documentation from MicroBT.
All,
Please see the following links for quick access to Whatsminer API documentation from MicroBT.
Havenβt looked at the whatsminer api docs in a while but they seem to be only slightly easier to digest ![]()
Itβs wild how adversarial the pleb relationship is with the OEMs.
Hi. I think I got Home Assistant to work with this M64β¦
This document summarizes the setup of Home Assistant Core with the Whatsminer integration for remote miner control.
/home/dsthermal/home_assistant//home/dsthermal/home_assistant/
βββ venv/ # Python virtual environment
βββ config/ # Home Assistant configuration
β βββ configuration.yaml # Main config
β βββ automations.yaml # Mining schedule
β βββ custom_components/ # Symlink to integration
β βββ home-assistant.log # Log file
βββ custom_components/
β βββ whatsminer/ # Whatsminer integration
β βββ __init__.py
β βββ api.py # API client (with encryption fix)
β βββ sensor.py
β βββ switch.py
β βββ const.py
β βββ manifest.json
βββ README.md
βββ SETUP_GUIDE.md # This file
βββ configuration_example.yaml
βββ automations_example.yaml
βββ install.sh
βββ WhatsMiner_API_Manual.pdf
cd /home/dsthermal/home_assistant
/usr/bin/python3 -m venv venv
./venv/bin/pip install --upgrade pip wheel
./venv/bin/pip install homeassistant pycryptodome numpy
mkdir -p config
ln -s /home/dsthermal/home_assistant/custom_components config/custom_components
config/configuration.yaml:
homeassistant:
name: Home
unit_system: metric
time_zone: America/Chicago
frontend:
api:
logger:
default: info
logs:
custom_components.whatsminer: debug
automation: !include automations.yaml
whatsminer:
- host: "XXX.XXX.X.X"
name: "Miner 1"
password: "root"
port: 4028
scan_interval: 30
The original Whatsminer API implementation used simple MD5 hashing, but the actual Whatsminer API requires Unix MD5-crypt ($1$ format) for authentication.
api.py:Password Key Derivation: Changed from MD5(salt + password) to:
pwd_hash = crypt.crypt(password, "$1$" + salt + "$")
key = pwd_hash.split('$')[3]
Sign Token Generation: Uses MD5-crypt with newsalt:
sign_hash = crypt.crypt(key + time_val, "$1$" + newsalt + "$")
sign = sign_hash.split('$')[3]
AES Key: SHA256 hash of the key, converted to bytes:
aes_key = binascii.unhexlify(hashlib.sha256(key.encode()).hexdigest())
Command Format: Token goes inside the JSON command before encryption:
command = {"cmd": "power_off", "token": sign}
Important: The Whatsminer API write access must be enabled on the miner itself.
Without this, commands return: "can't access write cmd" (Code 45)
Current Schedule (in config/automations.yaml):
| Day | Pause | Resume |
|---|---|---|
| Monday-Friday | 8:00 AM | 1:00 PM |
| Saturday-Sunday | No pause | Runs 24/7 |
Holiday Exceptions (miner runs all day):
Schedule End Date: May 31, 2026
cd /home/dsthermal/home_assistant
./venv/bin/hass -c ./config &
pkill -f "hass -c ./config"
ps aux | grep hass
tail -f ./config/home-assistant.log
sensor.miner_1_power - Power consumption (W)sensor.miner_1_hashrate - Hash rate (MH/s)sensor.miner_1_temperature_env - Environmental temp (Β°C)sensor.miner_1_temperature_chip_avg - Avg chip temp (Β°C)sensor.miner_1_temperature_chip_max - Max chip temp (Β°C)sensor.miner_1_fan_speed_in - Inlet fan (RPM)sensor.miner_1_fan_speed_out - Outlet fan (RPM)switch.miner_1_mining - Toggle mining on/offping XXX.XXX.X.Xnc -zv XXX.XXX.X.X 4028grep automation ./config/home-assistant.logAre yβall familiar with pyasic/pyasic/miners/whatsminer/btminer at master Β· UpstreamData/pyasic Β· GitHub?