summaryrefslogtreecommitdiff
path: root/localwebsite
diff options
context:
space:
mode:
authorEvgeny Sorokin <me@ch1p.io>2024-01-16 03:31:55 +0300
committerEvgeny Sorokin <me@ch1p.io>2024-01-16 03:32:07 +0300
commit8a89dd77be03ca8eb9cdc378ba8e912292494fa9 (patch)
treef2d04c1a6ce8b2731febbf6b66f6127057f9477d /localwebsite
parentde56aa3ae916ac0d51e503648fae8f3fa2d97951 (diff)
inverter page
Diffstat (limited to 'localwebsite')
-rw-r--r--localwebsite/handlers/InverterHandler.php104
-rw-r--r--localwebsite/htdocs/index.php7
-rw-r--r--localwebsite/templates-web/inverter_page.twig20
3 files changed, 0 insertions, 131 deletions
diff --git a/localwebsite/handlers/InverterHandler.php b/localwebsite/handlers/InverterHandler.php
deleted file mode 100644
index 5fa269f..0000000
--- a/localwebsite/handlers/InverterHandler.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-
-class InverterHandler extends RequestHandler
-{
-
- public function __construct() {
- parent::__construct();
- $this->tpl->add_static('inverter.js');
- }
-
- public function GET_status_page() {
- $inv = $this->getClient();
-
- $status = jsonDecode($inv->exec('get-status'))['data'];
- $rated = jsonDecode($inv->exec('get-rated'))['data'];
-
- $this->tpl->set([
- 'status' => $status,
- 'rated' => $rated,
- 'html' => $this->renderStatusHtml($status, $rated)
- ]);
- $this->tpl->set_title('Инвертор');
- $this->tpl->render_page('inverter_page.twig');
- }
-
- public function GET_set_osp() {
- list($osp) = $this->input('e:value(=sub|sbu)');
- $inv = $this->getClient();
- try {
- $inv->exec('set-output-source-priority', [strtoupper($osp)]);
- } catch (Exception $e) {
- die('Ошибка: '.jsonDecode($e->getMessage())['message']);
- }
- redirect('/inverter/');
- }
-
- public function GET_status_ajax() {
- $inv = $this->getClient();
- $status = jsonDecode($inv->exec('get-status'))['data'];
- $rated = jsonDecode($inv->exec('get-rated'))['data'];
- ajax_ok(['html' => $this->renderStatusHtml($status, $rated)]);
- }
-
- protected function renderStatusHtml(array $status, array $rated) {
- $power_direction = strtolower($status['battery_power_direction']);
- $power_direction = preg_replace('/ge$/', 'ging', $power_direction);
-
- $charging_rate = '';
- if ($power_direction == 'charging')
- $charging_rate = sprintf(' @ %s %s',
- $status['battery_charge_current']['value'],
- $status['battery_charge_current']['unit']);
- else if ($power_direction == 'discharging')
- $charging_rate = sprintf(' @ %s %s',
- $status['battery_discharge_current']['value'],
- $status['battery_discharge_current']['unit']);
-
- $html = sprintf('<b>Battery:</b> %s %s',
- $status['battery_voltage']['value'],
- $status['battery_voltage']['unit']);
- $html .= sprintf(' (%s%s, ',
- $status['battery_capacity']['value'],
- $status['battery_capacity']['unit']);
- $html .= sprintf('%s%s)',
- $power_direction,
- $charging_rate);
-
- $html .= "\n".sprintf('<b>Load:</b> %s %s',
- $status['ac_output_active_power']['value'],
- $status['ac_output_active_power']['unit']);
- $html .= sprintf(' (%s%%)',
- $status['output_load_percent']['value']);
-
- if ($status['pv1_input_power']['value'] > 0)
- $html .= "\n".sprintf('<b>Input power:</b> %s %s',
- $status['pv1_input_power']['value'],
- $status['pv1_input_power']['unit']);
-
- if ($status['grid_voltage']['value'] > 0 or $status['grid_freq']['value'] > 0) {
- $html .= "\n".sprintf('<b>AC input:</b> %s %s',
- $status['grid_voltage']['value'],
- $status['grid_voltage']['unit']);
- $html .= sprintf(', %s %s',
- $status['grid_freq']['value'],
- $status['grid_freq']['unit']);
- }
-
- $html .= "\n".sprintf('<b>Priority:</b> %s',
- $rated['output_source_priority']);
-
- return nl2br($html);
- }
-
- protected function getClient(): InverterdClient {
- global $config;
- if (isset($_GET['alt']) && $_GET['alt'] == 1)
- $config['inverterd_host'] = '192.168.5.223';
- $inv = new InverterdClient($config['inverterd_host'], $config['inverterd_port']);
- $inv->setFormat('json');
- return $inv;
- }
-
-
-}
diff --git a/localwebsite/htdocs/index.php b/localwebsite/htdocs/index.php
index d6034e6..eeeaacb 100644
--- a/localwebsite/htdocs/index.php
+++ b/localwebsite/htdocs/index.php
@@ -4,11 +4,6 @@ require_once __DIR__.'/../init.php';
$router = new router;
-// modem
-$router->add('modem/', 'Modem status_page');
-$router->add('modem/verbose/', 'Modem verbose_page');
-$router->add('modem/get.ajax', 'Modem status_get_ajax');
-
$router->add('routing/', 'Modem routing_smallhome_page');
$router->add('routing/switch-small-home/', 'Modem routing_smallhome_switch');
$router->add('routing/{ipsets,dhcp}/', 'Modem routing_${1}_page');
@@ -18,9 +13,7 @@ $router->add('sms/', 'Modem sms');
// $router->add('modem/set.ajax', 'Modem ctl_set_ajax');
// inverter
-$router->add('inverter/', 'Inverter status_page');
$router->add('inverter/set-osp/', 'Inverter set_osp');
-$router->add('inverter/status.ajax', 'Inverter status_ajax');
// misc
$router->add('/', 'Misc main');
diff --git a/localwebsite/templates-web/inverter_page.twig b/localwebsite/templates-web/inverter_page.twig
deleted file mode 100644
index c51e1bf..0000000
--- a/localwebsite/templates-web/inverter_page.twig
+++ /dev/null
@@ -1,20 +0,0 @@
-{% include 'bc.twig' with {
- history: [
- {text: "Инвертор" }
- ]
-} %}
-
-<h6 class="text-primary">Статус</h6>
-<div id="inverter_status">
- {{ html|raw }}
-</div>
-
-<div class="pt-3">
- <a href="/inverter/set-osp/?value={{ rated.output_source_priority == 'Solar-Battery-Utility' ? 'sub' : 'sbu' }}">
- <button type="button" class="btn btn-primary">Переключить на <b>{{ rated.output_source_priority == 'Solar-Battery-Utility' ? 'Solar-Utility-Battery' : 'Solar-Battery-Utility' }}</b></button>
- </a>
-</div>
-
-{% js %}
-Inverter.poll();
-{% endjs %} \ No newline at end of file