switch.py 828 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. from loguru import logger
  3. from app.models.domain.devices import ACVTSFSwitchSetRequest
  4. from app.controllers.equipment.switch import Switch, SwitchSet
  5. from app.schemas.equipment import VentilationFan
  6. class VentilationFanSwitch(Switch):
  7. def __init__(self, equipment: VentilationFan):
  8. super(VentilationFanSwitch, self).__init__(equipment)
  9. @logger.catch()
  10. async def build_acvtsf_switch_set(params: ACVTSFSwitchSetRequest) -> SwitchSet:
  11. vrf = VentilationFan(
  12. running_status=params.running_status,
  13. in_cloud_status=params.in_cloud_status,
  14. on_time=params.on_time,
  15. off_time=params.off_time,
  16. )
  17. action = await VentilationFanSwitch(vrf).build_next_action(params.is_workday)
  18. if not params.is_workday:
  19. action = SwitchSet.off
  20. return action