|
|
楼主 |
发表于 2025-10-3 23:22:08
|
显示全部楼层
我这里正常,就是有点慢。切换要等好几秒才能生效。另外切换防冻模式比较特殊,要改假期计划, : elif entity == "mode":
# 先获取当前模式
current_mode = self.api.get_current_mode(device_id)
logger.info(msg=f"Current mode: {current_mode}")
# 设置运行模式
if payload in MODE_MAP_REVERSE and current_mode:
current_mode: int = int(float(current_mode))
target_mode = MODE_MAP_REVERSE[payload]
# 同一模式下不执行,防冻模式要设置假期计划,非防冻模式要解除假期计划
if current_mode == target_mode:
logger.info("Current mode is already set, skipping")
return
elif MODE_MAP[current_mode] == "antifreeze":
self.api.close_holiday_plan(device_id)
else:
self.api.change_holiday_plan(physics_id=device_id, last_mode=current_mode)
result = self.api.set_mode(device_id, target_mode)
logger.info(f"Set mode to {payload} ({target_mode}): {result}")
else:
logger.warning(f"Unknown mode: {payload} or current mode get failed")
return
time.sleep(5) |
|