fix(nicehash): fix quickminer gpu temps

fix(sensor): handle no temps

    - remove unused parameter

    fix(nicehash): handle no devices
This commit is contained in:
Brian Berg 2021-06-18 16:11:54 -04:00
parent bbf0c7bb51
commit 46f1346551
4 changed files with 18 additions and 12 deletions

View File

@ -77,3 +77,5 @@ DEVICE_LOAD = "device-load"
DEVICE_RPM = "device-rpm"
# Payout types
PAYOUT_USER = "USER"
# Magic numbers
MAX_TWO_BYTES = 65536

View File

@ -16,7 +16,7 @@ import sys
from time import mktime
import uuid
from .const import NICEHASH_API_URL
from .const import MAX_TWO_BYTES, NICEHASH_API_URL
_LOGGER = logging.getLogger(__name__)
@ -45,7 +45,7 @@ class MiningRigDevice:
self.id = data.get("id")
self.name = parse_device_name(data.get("name"))
self.status = data.get("status").get("description")
self.temperature = int(data.get("temperature"))
self.temperature = int(data.get("temperature")) % MAX_TWO_BYTES
self.load = float(data.get("load"))
self.rpm = float(data.get("revolutionsPerMinute"))
self.speeds = data.get("speeds")
@ -60,11 +60,15 @@ class MiningRig:
self.profitability = data.get("profitability")
self.unpaid_amount = data.get("unpaidAmount")
devices = data.get("devices")
self.num_devices = len(devices)
self.devices = dict()
for device_data in devices:
device = MiningRigDevice(device_data)
self.devices[f"{device.id}"] = device
if devices is not None:
self.num_devices = len(devices)
self.devices = dict()
for device_data in devices:
device = MiningRigDevice(device_data)
self.devices[f"{device.id}"] = device
else:
self.num_devices = 0
self.devices = dict()
def get_algorithms(self):
algorithms = dict()

View File

@ -104,7 +104,8 @@ class RigHighTemperatureSensor(RigSensor):
for device in rig.devices.values():
if device.temperature > -1:
self._temps.append(device.temperature)
self._highest_temp = max(self._temps)
if len(self._temps) > 0:
self._highest_temp = max(self._temps)
return self._highest_temp
@ -160,7 +161,8 @@ class RigLowTemperatureSensor(RigSensor):
for device in rig.devices.values():
if device.temperature > -1:
self._temps.append(device.temperature)
self._lowest_temp = min(self._temps)
if len(self._temps) > 0:
self._lowest_temp = min(self._temps)
return self._lowest_temp
@ -365,8 +367,6 @@ class RigSpeedSensor(RigSensor):
self._algorithm = algo.name
self._speed = algo.speed
self._unit = algo.unit
print(self._algorithm)
print(self._speed)
return self._speed

View File

@ -161,7 +161,7 @@ def create_payout_sensors(organization_id, coordinator):
return payout_sensors
def create_rig_sensors(mining_rigs, coordinator, algorithms=[]):
def create_rig_sensors(mining_rigs, coordinator):
rig_sensors = []
for rig_data in mining_rigs:
rig = MiningRig(rig_data)