chenhaiyang před 4 roky
rodič
revize
58b4143699
1 změnil soubory, kde provedl 12 přidání a 4 odebrání
  1. 12 4
      app/controllers/equipment/fcu/on_ratio.py

+ 12 - 4
app/controllers/equipment/fcu/on_ratio.py

@@ -146,15 +146,23 @@ async def start_on_ratio_mode(device_id: str, target: float, period_time: int):
                     logger.debug(f'life count: {life_count}, {device_id}, on time: {on_range}, off time: {off_range}, '
                                  f'on ratio: {on_ratio}, delta_on: {delta_on * 900}, delta_off: {delta_off * 900}')
 
-                    await send_instructions(device_id, switch, speed, water_valve)
-                    await asyncio.sleep(on_range)
-                    await send_instructions(device_id, switch, speed, False)
-                    await asyncio.sleep(off_range)
+                    if 0 < on_ratio < 1:
+                        await send_instructions(device_id, switch, speed, water_valve)
+                        logger.debug(f'{device_id}, {switch}, {speed}, {water_valve}')
+                        await asyncio.sleep(on_range)
+                        await send_instructions(device_id, switch, speed, False)
+                        logger.debug(f'{device_id}, {switch}, {speed}, off')
+                        await asyncio.sleep(off_range)
+                    else:
+                        await send_instructions(device_id, switch, speed, water_valve)
+                        logger.debug(f'{device_id}, {switch}, {speed}, {water_valve}')
+                        await asyncio.sleep(period_time)
 
                     period_num += 1
                     last_on_ratio = on_ratio
                 else:
                     await send_instructions(device_id, switch, speed, water_valve)
+                    logger.debug(f'{device_id}, {switch}, {speed}, {water_valve}')
                     await asyncio.sleep(period_time)
 
                     period_num = 0