Skip to content

Commit

Permalink
Merge pull request #11 from pascalberski/6-new-feature-custom-interval
Browse files Browse the repository at this point in the history
added custom refresh interval to configuration
  • Loading branch information
pascalberski authored Apr 2, 2022
2 parents 5e9cbcf + 8c72129 commit f0bb7be
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ In order to be able to establish a connection between OCTune and Home Assistant,
2. Insert this example and modify it.
```text
octune:
refreshinterval: 60
miners:
- host: 192.168.178.10
port: 18000
Expand Down
7 changes: 4 additions & 3 deletions custom_components/octune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
https://github.com/pascalberski/ha-nhqm-octune
"""
import logging
import json
from datetime import timedelta
from homeassistant.core import Config, HomeAssistant
from homeassistant.helpers import discovery
from homeassistant.exceptions import PlatformNotReady

from .const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_AUTH, CONF_MINERS
from .const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_AUTH, CONF_MINERS, REFRESH_INTERVAL

from .const import (
DOMAIN,
Expand All @@ -34,6 +34,7 @@ async def async_setup(hass: HomeAssistant, config: Config):
# Configuration
#host = charger_config.get(CONF_HOST)

refresh_interval = timedelta(seconds=int(integration_config.get(REFRESH_INTERVAL)))
miners = integration_config.get(CONF_MINERS)
sensor_coordinators = []

Expand All @@ -46,7 +47,7 @@ async def async_setup(hass: HomeAssistant, config: Config):
client = OCTuneApiClient(host, port, auth)

_LOGGER.debug("initialising sensor coordinator %s - %s:%s - %s", minername, host, port, auth)
sensor_coordinator = SensorDataUpdateCoordinator(hass, client, host, port, auth, minername)
sensor_coordinator = SensorDataUpdateCoordinator(hass, client, host, port, auth, minername, refresh_interval)
await sensor_coordinator.async_refresh()

if not sensor_coordinator.last_update_success:
Expand Down
3 changes: 1 addition & 2 deletions custom_components/octune/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Constants for nhqm-octune
"""

from datetime import timedelta


NAME = "NiceHash QuickMiner OCTune"
Expand Down Expand Up @@ -31,7 +30,7 @@
CONF_AUTH = "auth"
CONF_NAME = "name"

REFRESH_INTERVAL = timedelta(seconds=10)
REFRESH_INTERVAL = "refreshinterval"

# Startup
STARTUP_MESSAGE = f"""
Expand Down
5 changes: 3 additions & 2 deletions custom_components/octune/coordinators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
sensor data update coordinator
"""
from datetime import timedelta
import logging

from homeassistant.core import HomeAssistant
Expand All @@ -21,7 +22,7 @@
class SensorDataUpdateCoordinator(DataUpdateCoordinator):
"""Manages fetching Status Data from octune api"""

def __init__(self, hass: HomeAssistant, client: OCTuneApiClient, host: str, port: int, auth: str, minername: str):
def __init__(self, hass: HomeAssistant, client: OCTuneApiClient, host: str, port: int, auth: str, minername: str, refresh_interval:timedelta):
"""Initialize"""
self.name = f"{DOMAIN}_{host}_sensor_coordinator"
self._client = client
Expand All @@ -31,7 +32,7 @@ def __init__(self, hass: HomeAssistant, client: OCTuneApiClient, host: str, port
self.minername = minername

super().__init__(
hass, _LOGGER, name=self.name, update_interval=REFRESH_INTERVAL
hass, _LOGGER, name=self.name, update_interval=refresh_interval
)

async def _async_update_data(self):
Expand Down
17 changes: 10 additions & 7 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@


[![GitHub Release][releases-shield]][releases]

[![GitHub Activity][commits-shield]][commits]

[![License][license-shield]](LICENSE)

![Project Maintenance][maintenance-shield]

[![Project Maintenance][maintenance-shield]](https://github.com/pascalberski)
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]


Expand All @@ -29,6 +25,8 @@ I'm using the Excavator api (https://github.com/nicehash/excavator/tree/master/a
- GPU temperature
- Hotspot temperature
- VRAM temperature
- Fan speed in percent
- Fan speed in RPM
- Sensors for the mining rig
- Hashrate (sum of all GPUs inside the rig)
- Global sensors
Expand All @@ -43,11 +41,15 @@ Request a new feature [here](https://github.com/pascalberski/ha-nhqm-octune/issu
In order to be able to establish a connection between OCTune and Home Assistant, it must first be ensured that OCTune can be reached by other devices.

1. **Open your Nice Hash Quick Miner config file.**
You can open the file via the Windows GUI as shown in the image below or directly via the file path: `C:\NiceHash\NiceHash QuickMiner\nhqm.conf`

You can open the file via the Windows GUI as shown in the image below or directly via the file path: `C:\NiceHash\NiceHash QuickMiner\nhqm.conf`

![openconfigfile][openconfigfileimg]
2. **Change OCTune API host**

You have to find the parameter `watchDogAPIHost` and change it from `localhost` to `0.0.0.0`.
3. **Restart**

Now you need to restart NH QuickMiner for the changes to take effect. *not just restart the Excavator*

### 2. Enable this Integration in HACS
Expand All @@ -62,6 +64,7 @@ In order to be able to establish a connection between OCTune and Home Assistant,
2. Insert this example and modify it.
```text
octune:
refreshinterval: 60
miners:
- host: 192.168.178.10
port: 18000
Expand Down Expand Up @@ -122,4 +125,4 @@ Please let me know in the [Issues tab][issues]

[issues]: https://github.com/pascalberski/ha-nhqm-octune/issues

[todos]: https://github.com/pascalberski/ha-nhqm-octune/issues?q=is%3Aopen+is%3Aissue+label%3Atodo
[todos]: https://github.com/pascalberski/ha-nhqm-octune/issues?q=is%3Aopen+is%3Aissue+label%3Atodo

0 comments on commit f0bb7be

Please sign in to comment.