feat: add voltage param to minerdata

This commit is contained in:
John-Paul Compagnone
2024-05-13 15:44:12 -04:00
parent 4cd0c3357b
commit a65c4ba215
4 changed files with 32 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ class MinerData:
temperature_avg: The average temperature across the boards. Calculated automatically.
env_temp: The environment temps as a float.
wattage: Current power draw of the miner as an int.
voltage: Current voltage draw of the miner as an float.
wattage_limit: Power limit of the miner as an int.
fans: A list of fans on the miner with their speeds.
fan_psu: The speed of the PSU on the fan if the miner collects it.
@@ -84,6 +85,7 @@ class MinerData:
env_temp: float = None
wattage: int = None
wattage_limit: int = field(init=False)
voltage: float = None
_wattage_limit: int = field(repr=False, default=None)
fans: List[Fan] = field(default_factory=list)
fan_psu: int = None

View File

@@ -58,6 +58,10 @@ EPIC_DATA_LOC = DataLocations(
"_get_wattage",
[WebAPICommand("web_summary", "summary")],
),
str(DataOptions.WATTAGE): DataFunction(
"_get_voltage",
[WebAPICommand("web_summary", "summary")],
),
str(DataOptions.FANS): DataFunction(
"_get_fans",
[WebAPICommand("web_summary", "summary")],
@@ -217,6 +221,20 @@ class ePIC(BaseMiner):
except KeyError:
pass
async def _get_voltage(self, web_summary: dict = None) -> Optional[float]:
if web_summary is None:
try:
web_summary = await self.web.summary()
except APIError:
pass
if web_summary is not None:
try:
voltage = web_summary["Power Supply Stats"]["Output Voltage"]
return voltage
except KeyError:
pass
async def _get_hashrate(self, web_summary: dict = None) -> Optional[float]:
if web_summary is None:
try:

View File

@@ -249,6 +249,14 @@ class MinerProtocol(Protocol):
"""
return await self._get_wattage()
async def get_voltage(self) -> Optional[float]:
"""Get voltage from the miner as a float.
Returns:
Voltage of the miner as an float.
"""
return await self._get_voltage()
async def get_wattage_limit(self) -> Optional[int]:
"""Get wattage limit from the miner as an int.
@@ -337,6 +345,9 @@ class MinerProtocol(Protocol):
async def _get_wattage(self) -> Optional[int]:
pass
async def _get_voltage(self) -> Optional[float]:
pass
async def _get_wattage_limit(self) -> Optional[int]:
pass

View File

@@ -37,6 +37,7 @@ class DataOptions(Enum):
IS_MINING = "is_mining"
UPTIME = "uptime"
CONFIG = "config"
VOLTAGE = "voltage"
def __str__(self):
return self.value