diff --git a/terrariumSwitch.py b/terrariumSwitch.py index d7ada2e52..ec3b356bf 100644 --- a/terrariumSwitch.py +++ b/terrariumSwitch.py @@ -178,8 +178,11 @@ def __calculate_time_table(self): stoptime = now.replace(hour=int(stoptime[0]), minute=int(stoptime[1])) logger.debug('Calculating timer \'%s\' stop time: %s',self.get_name(),stoptime) - #if starttime > stoptime: - # starttime -= datetime.timedelta(days=1) + if starttime > stoptime: + if now > stoptime: + stoptime += datetime.timedelta(hours=24) + else: + starttime -= datetime.timedelta(hours=24) while starttime <= stoptime: self.__timer_time_table.append((starttime,starttime + datetime.timedelta(minutes=self.get_timer_on_duration()))) diff --git a/terrariumTranslations.py b/terrariumTranslations.py index 42233cec4..fad282f4d 100644 --- a/terrariumTranslations.py +++ b/terrariumTranslations.py @@ -40,6 +40,11 @@ def __load(self): self.translations['switch_field_name'] = _('Holds the switch name.') self.translations['switch_field_power_wattage'] = _('Holds the switch power usage in Watt when switched on.') self.translations['switch_field_water_flow'] = _('Holds the switch water flow in liters per minute when switched on') + self.translations['switch_field_timer_enabled'] = _('Enable or disable timer functionality. When enabled you can specify the timing below.') + self.translations['switch_field_timer_start'] = _('Holds the timer start time. The timer will run after this start time.') + self.translations['switch_field_timer_stop'] = _('Holds the timer stop time. The timer will stop after this start time.') + self.translations['switch_field_timer_on_duration'] = _('Holds the timer on duration in minutes. This is the amount of minutes that the power is on after being off.') + self.translations['switch_field_timer_off_duration'] = _('Holds the timer off duration in minutes. This is the amount of minutes that the power is off after being on.') self.translations['switch_field_dimmer_duration'] = _('Holds the amount of seconds for the duration in which the dimmer changes to the new value.') self.translations['switch_field_dimmer_on_duration'] = _('Holds the amount of seconds for the duration in which it increases the power.') self.translations['switch_field_dimmer_on_percentage'] = _('Holds the amount in percentage to go to when switched on.') diff --git a/views/switch_settings.tpl b/views/switch_settings.tpl index e02f13c93..f7c4d7788 100644 --- a/views/switch_settings.tpl +++ b/views/switch_settings.tpl @@ -30,6 +30,36 @@
  • {{_('Water flow in L/m')}}: {{translations.get_translation('switch_field_water_flow')}}
  • +
  • + {{_('Timer')}}: {{translations.get_translation('switch_field_timer_enabled')}} +
  • +
  • + {{_('Timer start time')}}: {{!translations.get_translation('switch_field_timer_start')}} +
  • +
  • + {{_('Timer stop time')}}: {{translations.get_translation('switch_field_timer_stop')}} +
  • +
  • + {{_('Timer on duration')}}: {{translations.get_translation('switch_field_timer_on_duration')}} +
  • +
  • + {{_('Timer off duration')}}: {{translations.get_translation('switch_field_timer_off_duration')}} +
  • +
  • + {{_('Dimmer action duration')}}: {{!translations.get_translation('switch_field_dimmer_duration')}} +
  • +
  • + {{_('Dimmer on duration')}}: {{translations.get_translation('switch_field_dimmer_on_duration')}} +
  • +
  • + {{_('Dimmer on percentage')}}: {{translations.get_translation('switch_field_dimmer_on_percentage')}} +
  • +
  • + {{_('Dimmer off duration')}}: {{translations.get_translation('switch_field_dimmer_off_duration')}} +
  • +
  • + {{_('Dimmer off percentage')}}: {{translations.get_translation('switch_field_dimmer_off_percentage')}} +
  • @@ -140,19 +170,19 @@