feat(sensors): record all device temperatures
- stop attempting to ignore inactive/disabled devices - remove active devices count attribute - minor import cleanup
This commit is contained in:
parent
7ca95d8ca2
commit
04820e1aa9
@ -51,4 +51,3 @@ CURRENCY_EUR = "EUR"
|
|||||||
BALANCE_TYPE_AVAILABLE = "available"
|
BALANCE_TYPE_AVAILABLE = "available"
|
||||||
BALANCE_TYPE_PENDING = "pending"
|
BALANCE_TYPE_PENDING = "pending"
|
||||||
BALANCE_TYPE_TOTAL = "total"
|
BALANCE_TYPE_TOTAL = "total"
|
||||||
DEVICE_STATUS_INACTIVE = "INACTIVE"
|
|
||||||
|
@ -16,13 +16,7 @@ from .const import (
|
|||||||
CURRENCY_BTC,
|
CURRENCY_BTC,
|
||||||
CURRENCY_EUR,
|
CURRENCY_EUR,
|
||||||
CURRENCY_USD,
|
CURRENCY_USD,
|
||||||
DEFAULT_NAME,
|
|
||||||
DEVICE_STATUS_INACTIVE,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ICON_CURRENCY_BTC,
|
|
||||||
ICON_CURRENCY_EUR,
|
|
||||||
ICON_CURRENCY_USD,
|
|
||||||
ICON_TEMPERATURE,
|
|
||||||
)
|
)
|
||||||
from .nicehash import NiceHashPrivateClient, NiceHashPublicClient
|
from .nicehash import NiceHashPrivateClient, NiceHashPublicClient
|
||||||
from .sensors import NiceHashBalanceSensor, NiceHashRigTemperatureSensor
|
from .sensors import NiceHashBalanceSensor, NiceHashRigTemperatureSensor
|
||||||
|
@ -142,7 +142,6 @@ class NiceHashRigTemperatureSensor(Entity):
|
|||||||
self._name = rig["name"]
|
self._name = rig["name"]
|
||||||
self._temps = []
|
self._temps = []
|
||||||
self._num_devices = 0
|
self._num_devices = 0
|
||||||
self._num_active_devices = 0
|
|
||||||
_LOGGER.debug(f"Mining Rig Temperature Sensor: {self._name} ({self._rig_id})")
|
_LOGGER.debug(f"Mining Rig Temperature Sensor: {self._name} ({self._rig_id})")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -179,16 +178,10 @@ class NiceHashRigTemperatureSensor(Entity):
|
|||||||
if self._num_devices > 0:
|
if self._num_devices > 0:
|
||||||
_LOGGER.debug(f"{self._name}: Found {self._num_devices} devices")
|
_LOGGER.debug(f"{self._name}: Found {self._num_devices} devices")
|
||||||
for device in devices:
|
for device in devices:
|
||||||
status = device.get("status").get("enumName")
|
|
||||||
# Ignore inactive devices
|
|
||||||
if status == DEVICE_STATUS_INACTIVE:
|
|
||||||
continue
|
|
||||||
temp = int(device.get("temperature"))
|
temp = int(device.get("temperature"))
|
||||||
self._temps.append(temp)
|
self._temps.append(temp)
|
||||||
if temp > highest_temp:
|
if temp > highest_temp:
|
||||||
highest_temp = temp
|
highest_temp = temp
|
||||||
|
|
||||||
self._num_active_devices = len(self._temps)
|
|
||||||
return highest_temp
|
return highest_temp
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(f"{self._name}: No devices found")
|
_LOGGER.debug(f"{self._name}: No devices found")
|
||||||
@ -215,7 +208,6 @@ class NiceHashRigTemperatureSensor(Entity):
|
|||||||
return {
|
return {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||||
"temperatures": self._temps,
|
"temperatures": self._temps,
|
||||||
"active_devices": self._num_active_devices,
|
|
||||||
"total_devices": self._num_devices,
|
"total_devices": self._num_devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user