Skip to content

Commit

Permalink
feature to turn device on,off or reschedule at end of current schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed Oct 26, 2020
1 parent a15c2fb commit 4020087
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion demandshaper-module/Views/main.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php global $path; $v=11; ?>
<?php global $path; $v=12; ?>
<link rel="stylesheet" href="<?php echo $path; ?>Modules/demandshaper/demandshaper.css?v=<?php echo $v; ?>">

<script language="javascript" type="text/javascript" src="<?php echo $path; ?>Lib/flot/jquery.flot.min.js"></script>
Expand Down Expand Up @@ -181,6 +181,13 @@
<tr class="ovms-options hide"><td>OVMS Car Password:</td><td><input class="input" name="ovms_carpass" type="text" style="width:80px"/></td></tr>
</table>
</div>

<div class="general" style="border: 1px solid #ccc; padding:10px; margin-top:10px; background-color:#f0f0f0">
<p><b>General Settings</b></p>
<table class="table" style="margin:0">
<tr><td>At end of smart schedule:</td><td><select class="input" id="on_completion"><option value="smart">Reschedule</option><option value="off">Turn off</option><option value="on">Turn on</option></select></td></tr>
</table>
</div>

</div>
</div> <!-- scheduler-inner -->
Expand Down
1 change: 1 addition & 0 deletions demandshaper-module/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"end_timestamp":0,
"interruptible": 0,
"runone":0,
"on_completion":"smart",
"forecast_config": [{"name":"energylocal","club":"bethesda","weight":1.0}],
"forecast_units":"generic",
"timer":[{"start":0,"end":0},{"start":0,"end":0}],
Expand Down
8 changes: 8 additions & 0 deletions demandshaper-module/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ function update_input_UI() {
$("#timer_stop1 input[type=time]").val(timestr(schedule.settings.timer[0].end,false));
$("#timer_start2 input[type=time]").val(timestr(schedule.settings.timer[1].start,false));
$("#timer_stop2 input[type=time]").val(timestr(schedule.settings.timer[1].end,false));

// General settings
$("#on_completion").val(schedule.settings.on_completion)

var fn_name = "update_input_UI_"+schedule.settings.device_type;
if (window[fn_name]!=undefined) window[fn_name]();
Expand Down Expand Up @@ -346,6 +349,11 @@ $(".input-time button").click(function() {
on_UI_change();
});

$("#on_completion").change(function() {
schedule.settings.on_completion = $(this).val();
on_UI_change();
});

$(".scheduler-checkbox").click(function(){
var name = $(this).attr('name');
var state = 1; if ($(this).attr('state')==true) state = 0;
Expand Down
7 changes: 7 additions & 0 deletions demandshaper_run.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@
unset($schedule->runtime->started);

schedule_log("$device schedule complete");

if ($schedule->settings->ctrlmode=="smart") {
if (in_array($schedule->settings->on_completion,array("on","off","smart"))) {
$schedule->settings->ctrlmode = $schedule->settings->on_completion;
schedule_log("$device next ctrlmode: ".$schedule->settings->on_completion);
}
}
}

if ($schedule->settings->ctrlmode=="smart") {
Expand Down

0 comments on commit 4020087

Please sign in to comment.