|
@@ -1,8 +1,6 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
-from loguru import logger
|
|
|
-
|
|
|
-
|
|
|
+from app.api.errors.iot import MissingIOTDataError
|
|
|
from app.controllers.equipment.controller import EquipmentController
|
|
|
from app.models.domain.devices import ACATVIModeRequest
|
|
|
from app.schemas.season import Season
|
|
@@ -16,36 +14,39 @@ class VRFModeController(EquipmentController):
|
|
|
self._new_mode = "hold"
|
|
|
|
|
|
def run(self) -> None:
|
|
|
- if self._season == Season.cooling:
|
|
|
- cold_space_count, hot_space_count = 0, 0
|
|
|
- for item in self._space_temperature:
|
|
|
- if item < 22.0:
|
|
|
- cold_space_count += 1
|
|
|
- if item > 26.0:
|
|
|
- hot_space_count += 1
|
|
|
- if (
|
|
|
- cold_space_count / len(self._space_temperature) > 0.6
|
|
|
- and hot_space_count < 1
|
|
|
- ):
|
|
|
- new_mode = "ventilation"
|
|
|
- else:
|
|
|
- new_mode = "cooling"
|
|
|
- elif self._season == Season.transition:
|
|
|
- new_mode = "ventilation"
|
|
|
- else:
|
|
|
- cold_space_count, hot_space_count = 0, 0
|
|
|
- for item in self._space_temperature:
|
|
|
- if item < 22.0:
|
|
|
- cold_space_count += 1
|
|
|
- if item > 25.0:
|
|
|
- hot_space_count += 1
|
|
|
- if (
|
|
|
- hot_space_count / len(self._space_temperature) > 0.6
|
|
|
- and cold_space_count < 1
|
|
|
- ):
|
|
|
+ try:
|
|
|
+ if self._season == Season.cooling:
|
|
|
+ cold_space_count, hot_space_count = 0, 0
|
|
|
+ for item in self._space_temperature:
|
|
|
+ if item < 22.0:
|
|
|
+ cold_space_count += 1
|
|
|
+ if item > 26.0:
|
|
|
+ hot_space_count += 1
|
|
|
+ if (
|
|
|
+ cold_space_count / len(self._space_temperature) > 0.6
|
|
|
+ and hot_space_count < 1
|
|
|
+ ):
|
|
|
+ new_mode = "ventilation"
|
|
|
+ else:
|
|
|
+ new_mode = "cooling"
|
|
|
+ elif self._season == Season.transition:
|
|
|
new_mode = "ventilation"
|
|
|
else:
|
|
|
- new_mode = "heating"
|
|
|
+ cold_space_count, hot_space_count = 0, 0
|
|
|
+ for item in self._space_temperature:
|
|
|
+ if item < 22.0:
|
|
|
+ cold_space_count += 1
|
|
|
+ if item > 25.0:
|
|
|
+ hot_space_count += 1
|
|
|
+ if (
|
|
|
+ hot_space_count / len(self._space_temperature) > 0.6
|
|
|
+ and cold_space_count < 1
|
|
|
+ ):
|
|
|
+ new_mode = "ventilation"
|
|
|
+ else:
|
|
|
+ new_mode = "heating"
|
|
|
+ except ZeroDivisionError:
|
|
|
+ raise MissingIOTDataError
|
|
|
|
|
|
self._new_mode = new_mode
|
|
|
|
|
@@ -53,7 +54,6 @@ class VRFModeController(EquipmentController):
|
|
|
return self._new_mode
|
|
|
|
|
|
|
|
|
-@logger.catch()
|
|
|
async def build_acatvi_mode(params: ACATVIModeRequest) -> str:
|
|
|
controller = VRFModeController(params.season, params.space_temperature_list)
|
|
|
controller.run()
|