Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from upstream #13

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions demandshaper-module/Views/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<div class="heatpumpmonitor hide">
<div class="row" style="max-width:700px; margin: 0 auto;">
<div class="row" style="max-width:720px; margin: 0 auto;">
<div class="span4 offset2" style="margin-bottom:20px"><br>
<p>Flow Temperature <span id="heatpump_flowT"></span>C<br><span style="font-weight:normal; font-size:12px">Heat Output <span id="heatpump_heat">0</span>W</span></p>
</div>
Expand All @@ -50,7 +50,7 @@
<!---------------------------------------------------------------------------------------------------------------------------->
<div class="smart">

<div class="row" style="max-width:700px; margin: 0 auto;">
<div class="row" style="max-width:720px; margin: 0 auto;">
<div class="span4" style="margin-bottom:8px">
<div id="run_period">
<p>Run period:</p>
Expand Down Expand Up @@ -89,7 +89,7 @@
</div>
<!---------------------------------------------------------------------------------------------------------------------------->
<div class="timer hide">
<div class="row" style="max-width:700px; margin: 0 auto;">
<div class="row" style="max-width:720px; margin: 0 auto;">
<div class="span2">
<br><br>
<p>Timer 1</p>
Expand All @@ -110,7 +110,7 @@

<br>

<div class="row timer hide" style="max-width:700px; margin: 0 auto;">
<div class="row timer hide" style="max-width:720px; margin: 0 auto;">
<div class="span2">
<br><br>
<p>Timer 2</p>
Expand Down
15 changes: 10 additions & 5 deletions demandshaper-module/demandshaper_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function demandshaper_controller()



if ($session['userid']) $timezone = $user->get_timezone($session['userid']);
if ($session['userid']) {
$timezone = $user->get_timezone($session['userid']);
} else {
$timezone = "Europe/London";
}

$forecast_list = $demandshaper->get_forecast_list();

Expand Down Expand Up @@ -92,14 +96,14 @@ function demandshaper_controller()
case "forecast":
if (isset($_POST['config'])) {
$config = json_decode($_POST['config']);
return $demandshaper->get_combined_forecast($config);
return $demandshaper->get_combined_forecast($config,$timezone);
}
break;

case "schedule":
if (isset($_POST['config'])) {
$config = json_decode($_POST['config']);
$combined = $demandshaper->get_combined_forecast($config);
$combined = $demandshaper->get_combined_forecast($config,$timezone);

$period = (int) post('period'); // period in seconds
$end = (int) post('end'); // end timestamp
Expand All @@ -108,10 +112,11 @@ function demandshaper_controller()
// Run schedule
require_once "$linked_modules_dir/demandshaper/lib/scheduler2.php";
$combined = forecast_calc_min_max($combined);

if ($interruptible) {
return schedule_interruptible($combined,$period,$end,"Europe/London");
return schedule_interruptible($combined,$period,$end,$timezone);
} else {
return schedule_block($combined,$period,$end,"Europe/London");
return schedule_block($combined,$period,$end,$timezone);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions demandshaper-module/demandshaper_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ public function get_forecast_list() {
return $forecast_list;
}

public function get_combined_forecast($config) {
public function get_combined_forecast($config,$timezone) {

$params = new stdClass();
$params->timezone = "Europe/London";
$params->timezone = $timezone;

// 1. Set desired forecast interval
// This will downsample or upsample original forecast
Expand Down
2 changes: 1 addition & 1 deletion demandshaper-module/module.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name" : "DemandShaper",
"version" : "2.0.0"
"version" : "2.0.1"
}
2 changes: 1 addition & 1 deletion demandshaper_run.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
$schedule = $device_class[$device_type]->auto_update_timeleft($schedule);

// 1. Compile combined forecast
$combined = $demandshaper->get_combined_forecast($schedule->settings->forecast_config);
$combined = $demandshaper->get_combined_forecast($schedule->settings->forecast_config,$timezone);
// 2. Calculate forecast min/max
$combined = forecast_calc_min_max($combined);
// 3. Calculate schedule
Expand Down