From 1cfd895deb6301be6512dd6d234cac5bab59f799 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Sun, 13 Nov 2022 11:01:22 -0700 Subject: [PATCH] feature: improve speed of bosminer `check_light` by 10x using graphql. --- pyasic/miners/_backends/bosminer.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pyasic/miners/_backends/bosminer.py b/pyasic/miners/_backends/bosminer.py index 38d5bb23..b617de0e 100644 --- a/pyasic/miners/_backends/bosminer.py +++ b/pyasic/miners/_backends/bosminer.py @@ -18,6 +18,7 @@ import logging from typing import List, Union import toml +import httpx from pyasic.API.bosminer import BOSMinerAPI from pyasic.config import MinerConfig @@ -242,15 +243,10 @@ class BOSMiner(BaseMiner): await conn.run("/etc/init.d/bosminer start") async def check_light(self) -> bool: - if self.light: - return self.light - data = ( - await self.send_ssh_command("cat /sys/class/leds/'Red LED'/delay_off") - ).strip() - self.light = False - if data == "50": - self.light = True - return self.light + url = f"http://{self.ip}/graphql" + async with httpx.AsyncClient() as client: + d = (await client.post(url, json={"query": "{bos {faultLight}}"})).json() + return d["data"]["bos"]["faultLight"] async def get_errors(self) -> List[MinerErrorData]: tunerstatus = None