fix: v1.5.2 изменил логику нагрева, теперь нагрев включается по датчику qingping а не тион. Если он недоступен то по тиону.

This commit is contained in:
2026-09-27 21:28:31 +03:00
parent cea2637ec8
commit 328182e1b4
8 changed files with 1469 additions and 31 deletions
+248
View File
@@ -0,0 +1,248 @@
from app.auto.controller import AutoController
def print_state(
title: str,
controller: AutoController,
) -> None:
print()
print(title)
print(
{
"enabled": (
controller.manual_heater_enabled
),
"target_temp": (
controller.manual_target_temperature
),
"heating": (
controller._manual_heating
),
}
)
def main() -> None:
controller = object.__new__(
AutoController
)
controller._manual_heater_enabled = None
controller._manual_target_temperature = None
controller._manual_heating = None
# ==================================================
# 1. Исходное состояние.
# ==================================================
print_state(
"1. Initial:",
controller,
)
assert (
controller.manual_heater_enabled
is None
)
assert (
controller.manual_target_temperature
is None
)
assert controller._manual_heating is None
# ==================================================
# 2. Пользователь входит в ручной режим.
#
# Представим, что на момент перехода:
# heater был выключен,
# пользовательская температура = 23.
# ==================================================
controller.set_manual_heater_enabled(
False
)
controller.set_manual_target_temperature(
23
)
print_state(
"2. Enter manual mode:",
controller,
)
assert (
controller.manual_heater_enabled
is False
)
assert (
controller.manual_target_temperature
== 23
)
# ==================================================
# 3. Пользователь включает обогрев.
# ==================================================
controller.set_manual_heater_enabled(
True
)
print_state(
"3. Heater ON:",
controller,
)
assert (
controller.manual_heater_enabled
is True
)
assert (
controller.manual_target_temperature
== 23
)
# Пока реальный регулятор Qingping ещё
# не реализован, heating остаётся None.
assert controller._manual_heating is False
# ==================================================
# 4. Пользователь увеличивает температуру.
#
# 23 -> 24.
# ==================================================
controller.set_manual_target_temperature(
24
)
print_state(
"4. Temperature 23 -> 24:",
controller,
)
assert (
controller.manual_target_temperature
== 24
)
assert (
controller.manual_heater_enabled
is True
)
# ==================================================
# 5. Пользователь уменьшает температуру.
#
# 24 -> 23.
# ==================================================
controller.set_manual_target_temperature(
23
)
print_state(
"5. Temperature 24 -> 23:",
controller,
)
assert (
controller.manual_target_temperature
== 23
)
assert (
controller.manual_heater_enabled
is True
)
# ==================================================
# 6. Пользователь выключает обогрев.
# ==================================================
controller.set_manual_heater_enabled(
False
)
print_state(
"6. Heater OFF:",
controller,
)
assert (
controller.manual_heater_enabled
is False
)
# Уставка пользователя должна сохраниться.
assert (
controller.manual_target_temperature
== 23
)
# При явном выключении heater мы уже
# установили manual_heating=False.
assert controller._manual_heating is False
# ==================================================
# 7. Пользователь снова включает heater.
#
# Проверяем, что сохранённая температура 23
# не потерялась.
# ==================================================
controller.set_manual_heater_enabled(
True
)
print_state(
"7. Heater ON again:",
controller,
)
assert (
controller.manual_heater_enabled
is True
)
assert (
controller.manual_target_temperature
== 23
)
# ==================================================
# 8. Resume расписания.
#
# API при resume вызывает
# clear_manual_heater_control().
# ==================================================
controller.clear_manual_heater_control()
print_state(
"8. Resume schedule:",
controller,
)
assert (
controller.manual_heater_enabled
is None
)
assert (
controller.manual_target_temperature
is None
)
assert controller._manual_heating is None
print()
print("TEST PASSED")
if __name__ == "__main__":
main()