支持通过环境变量配置温控档位

This commit is contained in:
2026-05-06 10:04:15 +08:00
parent 929652bc00
commit eabc8d8bd2
6 changed files with 158 additions and 15 deletions
+10 -1
View File
@@ -11,6 +11,10 @@ if __name__ == '__main__':
host = os.getenv('HOST')
username = os.getenv('USERNAME')
password = os.getenv('PASSWORD')
# 优先读取新的温控档位变量,并兼容旧别名
fan_speed_steps = os.getenv('FAN_SPEED_STEPS')
if fan_speed_steps is None:
fan_speed_steps = os.getenv('FAN_SPEED_RULES')
if not host:
raise RuntimeError('未设置 HOST 环境变量')
@@ -21,7 +25,12 @@ if __name__ == '__main__':
raise RuntimeError('未设置 PASSWORD 环境变量')
# 复用控制器实例,避免每轮循环丢失上次设置状态
client = FanController(host=host, username=username, password=password)
client = FanController(
host=host,
username=username,
password=password,
fan_speed_steps=fan_speed_steps,
)
while True:
try: