Ejemplo n.º 1
0
    def test_time_program_before_first(self) -> None:
        tpds1 = TimePeriodSetting('01:00', 25, SettingModes.ON)
        tpds2 = TimePeriodSetting('02:00', 20, SettingModes.OFF)

        tpds_sunday = TimePeriodSetting('15:00', 15, SettingModes.OFF)

        sunday = TimeProgramDay([tpds_sunday])
        monday = TimeProgramDay([tpds1, tpds2])

        timeprogram = TimeProgram({'monday': monday, 'sunday': sunday})

        current = timeprogram.get_for(datetime(2019, 2, 18, 0, 30))
        self._assert(tpds_sunday, current)
Ejemplo n.º 2
0
    def test_time_program_simple(self) -> None:
        tpds1 = TimePeriodSetting("00:00", 25, SettingModes.ON)
        tpds2 = TimePeriodSetting("02:00", 20, SettingModes.OFF)

        monday = TimeProgramDay([tpds1, tpds2])

        timeprogram = TimeProgram({
            "monday": monday,
            "sunday": TimeProgramDay([])
        })

        current = timeprogram.get_for(datetime(2019, 2, 18, 1, 0))
        self._assert(tpds1, current)
Ejemplo n.º 3
0
    def test_get_next_after_last(self) -> None:
        tpds1 = TimePeriodSetting('01:00', 25, SettingModes.ON)
        tpds2 = TimePeriodSetting('05:00', 20, SettingModes.OFF)
        tpds3 = TimePeriodSetting('08:00', 20, SettingModes.OFF)
        tpds_day_after = TimePeriodSetting('03:00', 20, SettingModes.OFF)

        monday = TimeProgramDay([tpds1, tpds2, tpds3])
        tuesday = TimeProgramDay([tpds_day_after])

        timeprogram = TimeProgram({'monday': monday, 'tuesday': tuesday})

        next_setting = timeprogram.get_next(datetime(2019, 2, 18, 9, 30))

        self._assert(next_setting, tpds_day_after)
Ejemplo n.º 4
0
    def test_get_next_between_same_day(self) -> None:
        tpds1 = TimePeriodSetting("01:00", 25, SettingModes.ON)
        tpds2 = TimePeriodSetting("05:00", 20, SettingModes.OFF)
        tpds3 = TimePeriodSetting("08:00", 20, SettingModes.OFF)
        tpds_day_after = TimePeriodSetting("03:00", 20, SettingModes.OFF)

        monday = TimeProgramDay([tpds1, tpds2, tpds3])
        tuesday = TimeProgramDay([tpds_day_after])

        timeprogram = TimeProgram({"monday": monday, "tuesday": tuesday})

        next_setting = timeprogram.get_next(datetime(2019, 2, 18, 4, 30))

        self._assert(next_setting, tpds2)
Ejemplo n.º 5
0
    def test_time_program_after_last(self) -> None:
        tpds1 = TimePeriodSetting('00:00', 25, SettingModes.ON)
        tpds2 = TimePeriodSetting('02:00', 20, SettingModes.OFF)

        monday = TimeProgramDay([tpds1, tpds2])

        timeprogram = TimeProgram(
            {
                'monday': monday,
                'sunday': TimeProgramDay([])
            }
        )

        current = timeprogram.get_for(datetime(2019, 2, 18, 3, 0))
        self._assert(tpds2, current)
Ejemplo n.º 6
0
def _time_program(mode: Optional[SettingMode] = SettingModes.ON,
                  temperature: Optional[float] = None) -> TimeProgram:
    if mode in [SettingModes.DAY, SettingModes.NIGHT]:
        timeprogram_day_setting = TimePeriodSetting("00:00", None, mode)
    else:
        timeprogram_day_setting = TimePeriodSetting("00:00", temperature, mode)

    timeprogram_day = TimeProgramDay([timeprogram_day_setting])
    timeprogram_days = {
        "monday": timeprogram_day,
        "tuesday": timeprogram_day,
        "wednesday": timeprogram_day,
        "thursday": timeprogram_day,
        "friday": timeprogram_day,
        "saturday": timeprogram_day,
        "sunday": timeprogram_day,
    }
    return TimeProgram(timeprogram_days)
Ejemplo n.º 7
0
    def test_get_active_mode_zone_quick_mode_one_day_home_day(self) -> None:
        """Test get active mode for zone one day home."""

        timeprogram_day_setting_sunday = TimePeriodSetting(
            "00:00", None, SettingModes.DAY)

        timeprogram = _time_program(SettingModes.NIGHT, None)
        timeprogram.days["sunday"] = TimeProgramDay(
            [timeprogram_day_setting_sunday])

        zone = _zone()
        zone.heating.time_program = timeprogram
        system = System(zones=[zone], quick_mode=QuickModes.ONE_DAY_AT_HOME)

        active_mode = system.get_active_mode_zone(zone)

        self.assertEqual(QuickModes.ONE_DAY_AT_HOME, active_mode.current)
        self.assertEqual(zone.heating.target_high, active_mode.target)