refactor(sensor): rename sensors

This commit is contained in:
Brian Berg 2020-07-09 00:31:02 +00:00
parent a31d524e10
commit 743fd0febf
4 changed files with 36 additions and 40 deletions

View File

@ -23,7 +23,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
class NiceHashBalanceSensor(Entity):
class BalanceSensor(Entity):
"""
Displays [available|pending|total] balance of an account for a currency
"""

View File

@ -23,7 +23,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
class NiceHashDeviceSensor(Entity):
class DeviceSensor(Entity):
"""
Mining rig device sensor
"""
@ -129,7 +129,7 @@ class NiceHashDeviceSensor(Entity):
self._algorithm = None
class NiceHashDeviceStatusSensor(NiceHashDeviceSensor):
class DeviceStatusSensor(DeviceSensor):
"""
Displays status of a mining rig device
"""
@ -155,7 +155,7 @@ class NiceHashDeviceStatusSensor(NiceHashDeviceSensor):
return ICON_PULSE
class NiceHashDeviceSpeedSensor(NiceHashDeviceSensor):
class DeviceSpeedSensor(DeviceSensor):
"""
Displays speed of a mining rig device
"""
@ -186,7 +186,7 @@ class NiceHashDeviceSpeedSensor(NiceHashDeviceSensor):
return f"{self._speed_unit}/s"
class NiceHashDeviceAlgorithmSensor(NiceHashDeviceSensor):
class DeviceAlgorithmSensor(DeviceSensor):
"""
Displays algorithm of a mining rig device
"""
@ -212,7 +212,7 @@ class NiceHashDeviceAlgorithmSensor(NiceHashDeviceSensor):
return ICON_PICKAXE
class NiceHashDeviceTemperatureSensor(NiceHashDeviceSensor):
class DeviceTemperatureSensor(DeviceSensor):
"""
Displays temperature of a mining rig device
"""
@ -244,7 +244,7 @@ class NiceHashDeviceTemperatureSensor(NiceHashDeviceSensor):
return "C"
class NiceHashDeviceLoadSensor(NiceHashDeviceSensor):
class DeviceLoadSensor(DeviceSensor):
"""
Displays load of a mining rig device
"""
@ -275,7 +275,7 @@ class NiceHashDeviceLoadSensor(NiceHashDeviceSensor):
return "%"
class NiceHashDeviceRPMSensor(NiceHashDeviceSensor):
class DeviceRPMSensor(DeviceSensor):
"""
Displays RPM of a mining rig device
"""

View File

@ -20,7 +20,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
class NiceHashRigTemperatureSensor(Entity):
class RigTemperatureSensor(Entity):
"""
Displays highest temperature of active mining rig devices
"""
@ -112,7 +112,7 @@ class NiceHashRigTemperatureSensor(Entity):
await self.coordinator.async_request_refresh()
class NiceHashRigStatusSensor(Entity):
class RigStatusSensor(Entity):
"""
Displays status of a mining rig
"""
@ -199,7 +199,7 @@ class NiceHashRigStatusSensor(Entity):
await self.coordinator.async_request_refresh()
class NiceHashRigProfitabilitySensor(Entity):
class RigProfitabilitySensor(Entity):
"""
Displays profitability of a mining rig
"""

View File

@ -22,19 +22,19 @@ from .const import (
DEVICE_SPEED_ALGORITHM,
)
from .nicehash import NiceHashPrivateClient, NiceHashPublicClient
from .account_sensors import NiceHashBalanceSensor
from .account_sensors import BalanceSensor
from .rig_sensors import (
NiceHashRigStatusSensor,
NiceHashRigTemperatureSensor,
NiceHashRigProfitabilitySensor,
RigStatusSensor,
RigTemperatureSensor,
RigProfitabilitySensor,
)
from .device_sensors import (
NiceHashDeviceAlgorithmSensor,
NiceHashDeviceSpeedSensor,
NiceHashDeviceStatusSensor,
NiceHashDeviceLoadSensor,
NiceHashDeviceRPMSensor,
NiceHashDeviceTemperatureSensor,
DeviceAlgorithmSensor,
DeviceSpeedSensor,
DeviceStatusSensor,
DeviceLoadSensor,
DeviceRPMSensor,
DeviceTemperatureSensor,
)
_LOGGER = logging.getLogger(__name__)
@ -80,19 +80,19 @@ async def async_setup_platform(
def create_balance_sensors(organization_id, currency, coordinator):
balance_sensors = [
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=CURRENCY_BTC,
balance_type=BALANCE_TYPE_AVAILABLE,
),
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=CURRENCY_BTC,
balance_type=BALANCE_TYPE_PENDING,
),
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=CURRENCY_BTC,
@ -101,7 +101,7 @@ def create_balance_sensors(organization_id, currency, coordinator):
]
if currency == CURRENCY_USD or currency == CURRENCY_EUR:
balance_sensors.append(
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=currency,
@ -109,7 +109,7 @@ def create_balance_sensors(organization_id, currency, coordinator):
)
)
balance_sensors.append(
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=currency,
@ -117,7 +117,7 @@ def create_balance_sensors(organization_id, currency, coordinator):
)
)
balance_sensors.append(
NiceHashBalanceSensor(
BalanceSensor(
coordinator,
organization_id,
currency=currency,
@ -133,9 +133,9 @@ def create_balance_sensors(organization_id, currency, coordinator):
def create_rig_sensors(mining_rigs, coordinator):
rig_sensors = []
for rig in mining_rigs:
rig_sensors.append(NiceHashRigStatusSensor(coordinator, rig))
rig_sensors.append(NiceHashRigTemperatureSensor(coordinator, rig))
rig_sensors.append(NiceHashRigProfitabilitySensor(coordinator, rig))
rig_sensors.append(RigStatusSensor(coordinator, rig))
rig_sensors.append(RigTemperatureSensor(coordinator, rig))
rig_sensors.append(RigProfitabilitySensor(coordinator, rig))
return rig_sensors
@ -146,15 +146,11 @@ def create_device_sensors(mining_rigs, coordinator):
devices = rig.get("devices")
for i in range(len(devices)):
device = devices[i]
device_sensors.append(
NiceHashDeviceAlgorithmSensor(coordinator, rig, device)
)
device_sensors.append(NiceHashDeviceSpeedSensor(coordinator, rig, device))
device_sensors.append(NiceHashDeviceStatusSensor(coordinator, rig, device))
device_sensors.append(
NiceHashDeviceTemperatureSensor(coordinator, rig, device)
)
device_sensors.append(NiceHashDeviceLoadSensor(coordinator, rig, device))
device_sensors.append(NiceHashDeviceRPMSensor(coordinator, rig, device))
device_sensors.append(DeviceAlgorithmSensor(coordinator, rig, device))
device_sensors.append(DeviceSpeedSensor(coordinator, rig, device))
device_sensors.append(DeviceStatusSensor(coordinator, rig, device))
device_sensors.append(DeviceTemperatureSensor(coordinator, rig, device))
device_sensors.append(DeviceLoadSensor(coordinator, rig, device))
device_sensors.append(DeviceRPMSensor(coordinator, rig, device))
return device_sensors