diff --git a/README.md b/README.md index a6d7a27..86b3d6f 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,14 @@ [![Project Maintenance][maintenance1-shield]][user1_profile] [![Project Maintenance][maintenance2-shield]][user2_profile] -Control and monitor your Bitcoin Miners from Home Assistant. +Control and monitor your Bitcoin Miners from Home Assistant. Great for Heat Reusage, Solar Mining or any usecase where you don't need your miners running 24/7 or with a specific wattage. Works great in coordination with [ESPHome](https://www.home-assistant.io/integrations/esphome/) for Sensors (like temperature) and [Grafana](https://github.com/hassio-addons/addon-grafana) for Dashboards. ### Support for: + - Antminers - Whatsminers - Avalonminers @@ -26,7 +27,7 @@ Works great in coordination with [ESPHome](https://www.home-assistant.io/integra - Auradine - BitAxe - IceRiver -- Hammer +- Hammer - Braiins Firmware - Vnish Firmware - ePIC Firmware @@ -55,7 +56,6 @@ Works great in coordination with [ESPHome](https://www.home-assistant.io/integra Use HACS, add the custom repo https://github.com/Schnitzel/hass-miner to it - [![Installation and usage Video](http://img.youtube.com/vi/eL83eYLbgQM/0.jpg)](https://www.youtube.com/watch?v=6HwSQag7NU8) ## Contributions are welcome! diff --git a/custom_components/miner/config_flow.py b/custom_components/miner/config_flow.py index ff769b0..c769244 100644 --- a/custom_components/miner/config_flow.py +++ b/custom_components/miner/config_flow.py @@ -1,15 +1,21 @@ """Config flow for Miner.""" import logging +from importlib.metadata import version + +from .const import PYASIC_VERSION try: import pyasic + + if not version("pyasic") == PYASIC_VERSION: + raise ImportError except ImportError: from .patch import install_package - from .const import PYASIC_VERSION install_package(f"pyasic=={PYASIC_VERSION}") import pyasic - from pyasic import MinerNetwork + +from pyasic import MinerNetwork import voluptuous as vol from homeassistant import config_entries diff --git a/custom_components/miner/coordinator.py b/custom_components/miner/coordinator.py index 43efbac..0e62e7a 100644 --- a/custom_components/miner/coordinator.py +++ b/custom_components/miner/coordinator.py @@ -1,15 +1,21 @@ """Miner DataUpdateCoordinator.""" import logging from datetime import timedelta +from importlib.metadata import version + +from .const import PYASIC_VERSION try: import pyasic + + if not version("pyasic") == PYASIC_VERSION: + raise ImportError except ImportError: from .patch import install_package - from .const import PYASIC_VERSION install_package(f"pyasic=={PYASIC_VERSION}") import pyasic + from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.debounce import Debouncer diff --git a/custom_components/miner/number.py b/custom_components/miner/number.py index 9cf1df3..828f75e 100644 --- a/custom_components/miner/number.py +++ b/custom_components/miner/number.py @@ -2,12 +2,17 @@ from __future__ import annotations import logging +from importlib.metadata import version + +from .const import PYASIC_VERSION try: import pyasic + + if not version("pyasic") == PYASIC_VERSION: + raise ImportError except ImportError: from .patch import install_package - from .const import PYASIC_VERSION install_package(f"pyasic=={PYASIC_VERSION}") import pyasic diff --git a/custom_components/miner/select.py b/custom_components/miner/select.py index 7f8116c..ac31f69 100644 --- a/custom_components/miner/select.py +++ b/custom_components/miner/select.py @@ -2,6 +2,24 @@ from __future__ import annotations import logging +from importlib.metadata import version + +from .const import PYASIC_VERSION + +try: + import pyasic + + if not version("pyasic") == PYASIC_VERSION: + raise ImportError +except ImportError: + from .patch import install_package + + install_package(f"pyasic=={PYASIC_VERSION}") + import pyasic + +from pyasic.config.mining import MiningModeHPM +from pyasic.config.mining import MiningModeLPM +from pyasic.config.mining import MiningModeNormal from homeassistant.components.select import SelectEntity from homeassistant.config_entries import ConfigEntry @@ -10,10 +28,6 @@ from homeassistant.helpers import entity from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from pyasic import MinerConfig -from pyasic.config.mining import MiningModeHPM -from pyasic.config.mining import MiningModeLPM -from pyasic.config.mining import MiningModeNormal from custom_components.miner import DOMAIN from custom_components.miner import MinerCoordinator @@ -79,7 +93,7 @@ def device_info(self) -> entity.DeviceInfo: @property def current_option(self) -> str | None: """The current option selected with the select.""" - config: MinerConfig = self.coordinator.data["config"] + config: pyasic.MinerConfig = self.coordinator.data["config"] return str(config.mining_mode.mode).title() @property diff --git a/custom_components/miner/sensor.py b/custom_components/miner/sensor.py index 917eddd..86843cf 100644 --- a/custom_components/miner/sensor.py +++ b/custom_components/miner/sensor.py @@ -5,11 +5,11 @@ from collections.abc import Callable from dataclasses import dataclass +from homeassistant.components.sensor import EntityCategory +from homeassistant.components.sensor import SensorDeviceClass from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntityDescription from homeassistant.components.sensor import SensorStateClass -from homeassistant.components.sensor import SensorDeviceClass -from homeassistant.components.sensor import EntityCategory from homeassistant.config_entries import ConfigEntry from homeassistant.const import REVOLUTIONS_PER_MINUTE from homeassistant.const import UnitOfPower diff --git a/poetry.lock b/poetry.lock index 48891cc..3cfd41f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -617,17 +617,17 @@ docs = ["Sphinx (>=5.0,<6.0)", "myst-parser (>=0.18,<1.1)", "sphinx-rtd-theme (> [[package]] name = "boto3" -version = "1.35.92" +version = "1.35.93" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.35.92-py3-none-any.whl", hash = "sha256:786930d5f1cd13d03db59ff2abbb2b7ffc173fd66646d5d8bee07f316a5f16ca"}, - {file = "boto3-1.35.92.tar.gz", hash = "sha256:f7851cb320dcb2a53fc73b4075187ec9b05d51291539601fa238623fdc0e8cd3"}, + {file = "boto3-1.35.93-py3-none-any.whl", hash = "sha256:7de2c44c960e486f3c57e5203ea6393c6c4f0914c5f81c789ceb8b5d2ba5d1c5"}, + {file = "boto3-1.35.93.tar.gz", hash = "sha256:2446e819cf4e295833474cdcf2c92bc82718ce537e9ee1f17f7e3d237f60e69b"}, ] [package.dependencies] -botocore = ">=1.35.92,<1.36.0" +botocore = ">=1.35.93,<1.36.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -636,13 +636,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.35.92" +version = "1.35.93" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.35.92-py3-none-any.whl", hash = "sha256:f94ae1e056a675bd67c8af98a6858d06e3927d974d6c712ed6e27bb1d11bee1d"}, - {file = "botocore-1.35.92.tar.gz", hash = "sha256:caa7d5d857fed5b3d694b89c45f82b9f938f840e90a4eb7bf50aa65da2ba8f82"}, + {file = "botocore-1.35.93-py3-none-any.whl", hash = "sha256:47f7161000af6036f806449e3de12acdd3ec11aac7f5578e43e96241413a0f8f"}, + {file = "botocore-1.35.93.tar.gz", hash = "sha256:b8d245a01e7d64c41edcf75a42be158df57b9518a83a3dbf5c7e4b8c2bc540cc"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index b1f890e..a5768a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,10 +8,10 @@ package-mode = false [tool.poetry.dependencies] python = ">=3.12.0,<3.14" -homeassistant = "^2024.12.5" +homeassistant = "^2025.1.1" colorlog = "^6.9.0" ruff = "^0.8.4" -pyasic = "^0.67.2" +pyasic = "^0.68.5" setuptools = "^75.6.0" pre-commit = "^4.0.1" diff --git a/requirements.txt b/requirements.txt index 7361e0b..9a96a56 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ colorlog==6.8.2 -homeassistant>=2024.10.0 +homeassistant>=2025.1.1 pip>=21.0,<23.2 ruff==0.6.9 -pyasic==0.63.2 +pyasic==0.68.5 setuptools==75.1.0 pre-commit