Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/appconf.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ var config = {
out += "<br>";

for (var z in config.app) {

// Skip any entries that are listed as autogenerate
if (config.app[z].autogenerate!=undefined && config.app[z].autogenerate) continue;

out += "<div class='app-config-box' key='"+z+"'>";
if (config.app[z].type=="feed") {

Expand Down
2 changes: 1 addition & 1 deletion app_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function app_controller()
{
global $mysqli,$redis,$path,$session,$route,$user,$settings,$v;
// Force cache reload of css and javascript
$v = 39;
$v = 41;

$result = false;

Expand Down
754 changes: 529 additions & 225 deletions apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.

---------------------------------------------------------------------
Emoncms - open source energy visualisation
Part of the OpenEnergyMonitor project:
http://openenergymonitor.org
*/

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');

function mysolarpvbattery_app_controller($route,$app,$appconfig,$apikey)
{

global $path, $session, $settings, $mysqli, $redis, $user, $linked_modules_dir;
$v = 2;

// ----------------------------------------------------
// Main app view route
// ----------------------------------------------------
if ($route->action == "view" || $route->action == "") {
$route->format = "html";
$result = "\n<!-- global app css and js -->";
$result .= "\n" . '<link href="' . $path . 'Modules/app/Views/css/app.css?v=' . $v . '" rel="stylesheet">';
$result .= "\n" . '<script src="' . $path . 'Modules/app/Views/js/app.js?v=' . $v . '"></script>';
$result .= "\n\n <!-- app specific view -->\n";

$dir = $appconfig->get_app_dir($app->app);
$result .= view($dir.$app->app.".php",array("id"=>$app->id, "name"=>$app->name, "public"=>$app->public, "appdir"=>$dir, "config"=>$app->config, "apikey"=>$apikey));
return $result;
}

// ----------------------------------------------------
// Trigger post-processor route
// ----------------------------------------------------
else if ($route->action == "process" && $session['write']) {
$route->format = "json";
$userid = $session['userid'];

require_once "Modules/feed/feed_model.php";
$feed = new Feed($mysqli,$redis,$settings['feed']);

include "Modules/postprocess/postprocess_model.php";
$postprocess = new PostProcess($mysqli, $redis, $feed);
$processes = $postprocess->get_processes("$linked_modules_dir/postprocess");
$process_classes = $postprocess->get_process_classes();

$tag = "app_mysolarpvbattery_".$app->id;

$process_conf = (object) array(
"solar" => (int) $app->config->solar,
"use" => (int) $app->config->use,
"grid" => (int) $app->config->grid,
"battery_power" => (int) $app->config->battery_power,

"solar_to_load_kwh" => $feed->exists_tag_name($userid, $tag, "solar_to_load_kwh"),
"solar_to_grid_kwh" => $feed->exists_tag_name($userid, $tag, "solar_to_grid_kwh"),
"solar_to_battery_kwh" => $feed->exists_tag_name($userid, $tag, "solar_to_battery_kwh"),
"battery_to_load_kwh" => $feed->exists_tag_name($userid, $tag, "battery_to_load_kwh"),
"battery_to_grid_kwh" => $feed->exists_tag_name($userid, $tag, "battery_to_grid_kwh"),
"grid_to_load_kwh" => $feed->exists_tag_name($userid, $tag, "grid_to_load_kwh"),
"grid_to_battery_kwh" => $feed->exists_tag_name($userid, $tag, "grid_to_battery_kwh"),

"process_mode" => "all",
"process_start" => 0,
"process" => "solarbatterykwh"
);

// capture and silence any internal prints
ob_start();
$result = $process_classes[$process_conf->process]->process($process_conf);
ob_end_clean();
return $result;
}
}
5 changes: 5 additions & 0 deletions apps/OpenEnergyMonitor/solartemplate/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title" : "Solar PV & Battery Template",
"description" : "A simpler version of the My Solar Battery app, power view only and key calculations",
"order" : 20
}
Loading