whatsminer2mqtt enables data from the unofficial Whatsminer API to be polled and pushed to MQTT. Special thanks to Satoshi Anonymoto for creation of the unofficial Whatsminer API (https://github.com/satoshi-anonymoto/whatsminer-api)
Docker via docker-compose
(RECOMMENDED)
- Create your docker-compose.yaml (or add to existing). Example docker-compose.yaml with all environmental variables:
version: '3'
services:
whatsminer2mqtt:
container_name: whatsminer2mqtt
image: tediore/whatsminer2mqtt:latest
environment:
- MQTT_HOST=10.0.0.2
- MQTT_PORT=1883
- MQTT_USER=user
- MQTT_PASSWORD=password
- BASE_TOPIC=whatsminer2mqtt
- HOME_ASSISTANT=True
- MINER_IP=10.0.1.4
- INTERVAL=10
- LOG_LEVEL=debug
restart: unless-stopped
docker-compose up -d whatsminer2mqtt
Docker via docker run
Example docker run
command with all environment variables:
docker run --name whatsminer2mqtt \
-e MQTT_HOST=10.0.0.2 \
-e MQTT_PORT=1883 \
-e MQTT_USER=user \
-e MQTT_PASSWORD=password \
-e BASE_TOPIC=whatsminer2mqtt \
-e HOME_ASSISTANT=True \
-e MINER_IP=10.0.1.4 \
-e INTERVAL=10 \
-e LOG_LEVEL=debug \
tediore/whatsminer2mqtt:latest
Bare metal (not recommended) (Requires Python 3.9+)
- Set the necessary environment variables
git clone https://github.com/Tediore/whatsminer2mqtt
cd whatsminer2mqtt
python3 whatsminer2mqtt.py
Variable | Default | Required | Description |
---|---|---|---|
MQTT_HOST |
None | True | IP address or hostname of the MQTT broker to connect to. |
MQTT_PORT |
1883 | True | The port the MQTT broker is bound to. |
MQTT_USER |
None | False | The user to send to the MQTT broker. |
MQTT_PASSWORD |
None | False | The password to send to the MQTT broker. |
BASE_TOPIC |
whatsminer | True | The topic prefix to use for all payloads. |
HOME_ASSISTANT |
True | False | Set to True to enable Home Assistant MQTT discovery or False to disable. |
MINER_IP |
None | True | IP address of the Whatsminer API. |
INTERVAL |
10 | True | Interval (in seconds) to query the Whatsminer API and publish MQTT payloads. |
LOG_LEVEL |
info | False | Set minimum log level. Valid options are debug , info , warning , and error |
whatsminer2mqtt supports Home Assistant MQTT discovery which creates a Device for the Whatsminer instance and entities for each piece of information from the Whatsminer API summary
command.
Payloads for each piece of information are published to BASE_TOPIC/info/PARAMETER
where BASE_TOPIC
is the base topic you define and PARAMETER
is the name of each monitored condition from the summary
command.