switch.py 970 B

12345678910111213141516171819202122232425262728
  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, fetch_data, send_switch_command
  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 ventilation_fan_switch_control(project_id: str, equipment_id: str) -> None:
  11. equip_params, day_type = await fetch_data(project_id, equipment_id)
  12. action = await VentilationFanSwitch(VentilationFan(**equip_params)).build_next_action(day_type.get('day_type'))
  13. if day_type.get('day_type') != 'WeekDay':
  14. action = 'off'
  15. logger.debug(f'VTSF-{equipment_id}: {action}')
  16. await send_switch_command(project_id, equipment_id, action)
  17. @logger.catch()
  18. def build_acvtsf_switch_set(params: ACVTSFSwitchSetRequest) -> str:
  19. pass