Exemplo n.º 1
0
def holiday_mode_from_json(str_json) -> HolidayMode:
    """Convert json to holiday mode."""
    if str_json:
        return HolidayMode(
            str_json["active"],
            datetime.strptime(str_json["start_date"], _DATE_FORMAT).date(),
            datetime.strptime(str_json["end_date"], _DATE_FORMAT).date(),
            str_json["target"],
        )
    return HolidayMode(False)
Exemplo n.º 2
0
 def test_is_active_active_not_between(self) -> None:
     """Test active today not between start and end dates."""
     today = date.today()
     start_date = today - timedelta(days=today.weekday() - 2)
     end_date = today - timedelta(days=today.weekday() - 1)
     mode = HolidayMode(True, start_date, end_date, 15)
     self.assertFalse(mode.is_applied)
Exemplo n.º 3
0
 def test_is_active_active_between(self) -> None:
     """Test active today between start and end dates."""
     today = date.today()
     start_date = today - timedelta(days=1)
     end_date = today + timedelta(days=1)
     mode = HolidayMode(True, start_date, end_date, 15)
     self.assertTrue(mode.is_applied)
Exemplo n.º 4
0
    async def _remove_holiday_mode_no_refresh(self):
        removed = False

        if self.system.holiday is not None and self.system.holiday.is_applied:
            removed = True
            await self._manager.remove_holiday_mode()
            self.system.holiday = HolidayMode(False)
        return removed
Exemplo n.º 5
0
    def test_get_active_mode_room_holiday_mode(self) -> None:
        """Test active mode room with holiday mode."""
        holiday = HolidayMode(True, datetime.date.today(),
                              datetime.date.today(), 10)

        room = _room()
        system = System(rooms=[room], holiday=holiday)

        active_mode = system.get_active_mode_room(room)

        self.assertEqual(QuickModes.HOLIDAY, active_mode.current)
        self.assertEqual(holiday.target, active_mode.target)
Exemplo n.º 6
0
    def test_get_active_mode_ventilation_holiday(self) -> None:
        """Test get active mode for ventilation."""
        holiday = HolidayMode(True, datetime.date.today(),
                              datetime.date.today(), 10)
        ventilation = Ventilation(operating_mode=OperatingModes.NIGHT,
                                  target_high=5)
        system = System(ventilation=ventilation, holiday=holiday)

        active_mode = system.get_active_mode_ventilation()

        self.assertEqual(QuickModes.HOLIDAY, active_mode.current)
        self.assertEqual(Ventilation.MIN_LEVEL, active_mode.target)
Exemplo n.º 7
0
    def test_get_active_mode_zone_holiday_mode(self) -> None:
        """Test get active mode for zone with holiday mode."""
        holiday = HolidayMode(True, datetime.date.today(),
                              datetime.date.today(), 10)

        zone = _zone()
        system = System(holiday=holiday, zones=[zone])

        active_mode = system.get_active_mode_zone(zone)

        self.assertEqual(QuickModes.HOLIDAY, active_mode.current)
        self.assertEqual(holiday.target, active_mode.target)
Exemplo n.º 8
0
    def test_get_active_mode_hot_water_holiday_mode(self) -> None:
        """Test get active mode for hot water with holiday mode."""
        holiday = HolidayMode(True, datetime.date.today(),
                              datetime.date.today(), 10)

        dhw = Dhw(hotwater=_hotwater())

        system = System(holiday=holiday, dhw=dhw)

        active_mode = system.get_active_mode_hot_water()

        self.assertEqual(QuickModes.HOLIDAY, active_mode.current)
        self.assertEqual(constants.FROST_PROTECTION_TEMP, active_mode.target)
Exemplo n.º 9
0
    def test_get_active_mode_circulation_holiday(self) -> None:
        """Test get active mode for circulation with holiday mode."""
        dhw = Dhw(circulation=_circulation())

        holiday = HolidayMode(True, datetime.date.today(),
                              datetime.date.today(), 10)

        system = System(holiday=holiday, dhw=dhw)

        active_mode = system.get_active_mode_circulation()

        self.assertEqual(QuickModes.HOLIDAY, active_mode.current)
        self.assertIsNone(active_mode.target)
        self.assertIsNone(active_mode.sub)
Exemplo n.º 10
0
 async def set_holiday_mode(self, start_date, end_date, temperature):
     """Set holiday mode."""
     await self._manager.set_holiday_mode(start_date, end_date, temperature)
     self.data.holiday = HolidayMode(True, start_date, end_date,
                                     temperature)
     await self._refresh_entities()
Exemplo n.º 11
0
 def test_is_active_false(self) -> None:
     """Test non active."""
     mode = HolidayMode(False, None, None, None)
     self.assertFalse(mode.is_applied)
Exemplo n.º 12
0
 def test_is_active_active_no_dates(self) -> None:
     """Test active without dates."""
     mode = HolidayMode(True, None, None, None)
     self.assertFalse(mode.is_applied)
Exemplo n.º 13
0
 async def _remove_holiday_mode_no_refresh(self):
     await self._manager.remove_holiday_mode()
     self._holiday_mode = HolidayMode(False)
     return True