Skip to content

Commit

Permalink
Update timer functionality. #72
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Jan 27, 2018
1 parent 83d7d92 commit 7c45467
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
7 changes: 5 additions & 2 deletions terrariumSwitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Expand Down
5 changes: 5 additions & 0 deletions terrariumTranslations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
38 changes: 34 additions & 4 deletions views/switch_settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,36 @@
<li>
<strong>{{_('Water flow in L/m')}}</strong>: {{translations.get_translation('switch_field_water_flow')}}
</li>
<li>
<strong>{{_('Timer')}}</strong>: {{translations.get_translation('switch_field_timer_enabled')}}
</li>
<li>
<strong>{{_('Timer start time')}}</strong>: {{!translations.get_translation('switch_field_timer_start')}}
</li>
<li>
<strong>{{_('Timer stop time')}}</strong>: {{translations.get_translation('switch_field_timer_stop')}}
</li>
<li>
<strong>{{_('Timer on duration')}}</strong>: {{translations.get_translation('switch_field_timer_on_duration')}}
</li>
<li>
<strong>{{_('Timer off duration')}}</strong>: {{translations.get_translation('switch_field_timer_off_duration')}}
</li>
<li>
<strong>{{_('Dimmer action duration')}}</strong>: {{!translations.get_translation('switch_field_dimmer_duration')}}
</li>
<li>
<strong>{{_('Dimmer on duration')}}</strong>: {{translations.get_translation('switch_field_dimmer_on_duration')}}
</li>
<li>
<strong>{{_('Dimmer on percentage')}}</strong>: {{translations.get_translation('switch_field_dimmer_on_percentage')}}
</li>
<li>
<strong>{{_('Dimmer off duration')}}</strong>: {{translations.get_translation('switch_field_dimmer_off_duration')}}
</li>
<li>
<strong>{{_('Dimmer off percentage')}}</strong>: {{translations.get_translation('switch_field_dimmer_off_percentage')}}
</li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -140,19 +170,19 @@
<div class="row timer" style="display:none;">
<div class="col-md-3 col-sm-3 col-xs-12 form-group">
<label for="switch_[nr]_timer_start">{{_('Timer start time')}}</label>
<input class="form-control" name="switch_[nr]_timer_start" placeholder="{{_('Timer start time')}}" type="text" pattern="[0-9\.:]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_start')}}">
<input class="form-control" name="switch_[nr]_timer_start" placeholder="{{_('Timer start time')}}" type="text" pattern="[0-9:APM]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_start')}}">
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group">
<label for="switch_[nr]_timer_stop">{{_('Timer stop time')}}</label>
<input class="form-control" name="switch_[nr]_timer_stop" placeholder="{{_('Timer stop time')}}" type="text" pattern="[0-9\.:]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_stop')}}">
<input class="form-control" name="switch_[nr]_timer_stop" placeholder="{{_('Timer stop time')}}" type="text" pattern="[0-9:APM]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_stop')}}">
</div>
<div class="col-md-3 col-sm-2 col-xs-12 form-group">
<label for="switch_[nr]_timer_on_duration">{{_('Timer on duration')}}</label>
<input class="form-control" name="switch_[nr]_timer_on_duration" placeholder="{{_('Timer on duration')}}" type="text" pattern="[0-9\.]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_on_duration')}}">
<input class="form-control" name="switch_[nr]_timer_on_duration" placeholder="{{_('Timer on duration in minutes')}}" type="text" pattern="[0-9]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_on_duration')}}">
</div>
<div class="col-md-3 col-sm-2 col-xs-12 form-group">
<label for="switch_[nr]_timer_off_duration">{{_('Timer off duration')}}</label>
<input class="form-control" name="switch_[nr]_timer_off_duration" placeholder="{{_('Timer off duration')}}" type="text" pattern="[0-9\.]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_off_duration')}}">
<input class="form-control" name="switch_[nr]_timer_off_duration" placeholder="{{_('Timer off duration in minutes')}}" type="text" pattern="[0-9]+" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{translations.get_translation('switch_field_timer_off_duration')}}">
</div>
</div>
</div>
Expand Down

0 comments on commit 7c45467

Please sign in to comment.