From 3451127761681c15e1f8ca4dc79aa8c7d50596e9 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Mon, 22 Apr 2024 08:57:57 -0600 Subject: [PATCH] bug: fix bosminer fan control for 2.0 versions. --- pyasic/config/fans.py | 47 +++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/pyasic/config/fans.py b/pyasic/config/fans.py index b9970b11..f3ef0679 100644 --- a/pyasic/config/fans.py +++ b/pyasic/config/fans.py @@ -44,11 +44,21 @@ def from_vnish(cls, web_cooling_settings: dict) -> "FanModeNormal": cls_conf["minimum_speed"] = web_cooling_settings["fan_min_duty"] return cls(**cls_conf) + @classmethod + def from_bosminer(cls, toml_fan_conf: dict): + cls_conf = {} + if toml_fan_conf.get("min_fans") is not None: + cls_conf["minimum_fans"] = toml_fan_conf["min_fans"] + return cls(**cls_conf) + def as_am_modern(self) -> dict: return {"bitmain-fan-ctrl": False, "bitmain-fan-pwn": "100"} def as_bosminer(self) -> dict: - return {"temp_control": {"mode": "auto"}} + return { + "temp_control": {"mode": "auto"}, + "fan_control": {"min_fans": self.minimum_fans}, + } def as_epic(self) -> dict: return { @@ -123,7 +133,10 @@ def as_am_modern(self) -> dict: return {"bitmain-fan-ctrl": True, "bitmain-fan-pwm": "0"} def as_bosminer(self) -> dict: - return {"temp_control": {"mode": "disabled"}} + return { + "temp_control": {"mode": "disabled"}, + "fan_control": {"min_fans": 0}, + } def as_auradine(self) -> dict: return {"fan": {"percentage": 0}} @@ -178,20 +191,28 @@ def from_epic(cls, web_conf: dict): @classmethod def from_bosminer(cls, toml_conf: dict): - if toml_conf.get("temp_control") is None: - return cls.default() - if toml_conf["temp_control"].get("mode") is None: + try: + mode = toml_conf["temp_control"]["mode"] + fan_config = toml_conf.get("fan_control", {}) + if mode == "auto": + return cls.normal().from_bosminer(fan_config) + elif mode == "manual": + if toml_conf.get("fan_control"): + return cls.manual().from_bosminer(fan_config) + return cls.manual() + elif mode == "disabled": + return cls.immersion() + except KeyError: + pass + + try: + min_fans = toml_conf["fan_control"]["min_fans"] + except KeyError: return cls.default() - mode = toml_conf["temp_control"]["mode"] - if mode == "auto": - return cls.normal() - elif mode == "manual": - if toml_conf.get("fan_control"): - return cls.manual().from_bosminer(toml_conf["fan_control"]) - return cls.manual() - elif mode == "disabled": + if min_fans == 0: return cls.immersion() + return cls.normal(minimum_fans=min_fans) @classmethod def from_vnish(cls, web_settings: dict):