diff --git a/pyasic/data/__init__.py b/pyasic/data/__init__.py index 8051ea1d..e76dfe6c 100644 --- a/pyasic/data/__init__.py +++ b/pyasic/data/__init__.py @@ -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 diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index b4755c6f..cba74464 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -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: diff --git a/pyasic/miners/base.py b/pyasic/miners/base.py index 0126b59c..d393c951 100644 --- a/pyasic/miners/base.py +++ b/pyasic/miners/base.py @@ -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 diff --git a/pyasic/miners/data.py b/pyasic/miners/data.py index a21ccd16..9618e008 100644 --- a/pyasic/miners/data.py +++ b/pyasic/miners/data.py @@ -37,6 +37,7 @@ class DataOptions(Enum): IS_MINING = "is_mining" UPTIME = "uptime" CONFIG = "config" + VOLTAGE = "voltage" def __str__(self): return self.value