feature: improve speed of bosminer check_light by 10x using graphql.

This commit is contained in:
Upstream Data
2022-11-13 11:01:22 -07:00
parent d0da08eb10
commit 1cfd895deb

View File

@@ -18,6 +18,7 @@ import logging
from typing import List, Union from typing import List, Union
import toml import toml
import httpx
from pyasic.API.bosminer import BOSMinerAPI from pyasic.API.bosminer import BOSMinerAPI
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
@@ -242,15 +243,10 @@ class BOSMiner(BaseMiner):
await conn.run("/etc/init.d/bosminer start") await conn.run("/etc/init.d/bosminer start")
async def check_light(self) -> bool: async def check_light(self) -> bool:
if self.light: url = f"http://{self.ip}/graphql"
return self.light async with httpx.AsyncClient() as client:
data = ( d = (await client.post(url, json={"query": "{bos {faultLight}}"})).json()
await self.send_ssh_command("cat /sys/class/leds/'Red LED'/delay_off") return d["data"]["bos"]["faultLight"]
).strip()
self.light = False
if data == "50":
self.light = True
return self.light
async def get_errors(self) -> List[MinerErrorData]: async def get_errors(self) -> List[MinerErrorData]:
tunerstatus = None tunerstatus = None