Skip to content

Commit

Permalink
bug: ensure pyasic version is correct on setup, and update hass version
Browse files Browse the repository at this point in the history
  • Loading branch information
UpstreamData committed Jan 7, 2025
1 parent df9a774 commit 89dd268
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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!
Expand Down
10 changes: 8 additions & 2 deletions custom_components/miner/config_flow.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion custom_components/miner/coordinator.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion custom_components/miner/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 19 additions & 5 deletions custom_components/miner/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/miner/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 89dd268

Please sign in to comment.