diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-05-21 01:45:56 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-05-21 01:45:56 +0300 |
commit | 6f53e6e997c9f4647a667bd58b11bc622fa3b47f (patch) | |
tree | 226bd65a04576de4f41bf8396af97cd43ca27829 /localwebsite/handlers/MiscHandler.php | |
parent | 902a3bfbe2c4645e6725fb7583500d1a28026fad (diff) |
move local website to homekit's tree
Diffstat (limited to 'localwebsite/handlers/MiscHandler.php')
-rw-r--r-- | localwebsite/handlers/MiscHandler.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php new file mode 100644 index 0000000..4f35981 --- /dev/null +++ b/localwebsite/handlers/MiscHandler.php @@ -0,0 +1,52 @@ +<?php + +class MiscHandler extends RequestHandler +{ + + public function GET_main() { + $this->tpl->set_title('Главная'); + $this->tpl->render_page('index.twig'); + } + + public function GET_phpinfo() { + phpinfo(); + exit; + } + + public function GET_sensors_page() { + global $config; + + $clients = []; + foreach ($config['si7021d_servers'] as $key => $params) { + $cl = new Si7021dClient(...$params); + $clients[$key] = $cl; + + $cl->readSensor(); + } + + $this->tpl->set(['sensors' => $clients]); + $this->tpl->set_title('Датчики'); + $this->tpl->render_page('sensors.twig'); + } + + public function GET_pump_page() { + global $config; + + list($set) = $this->input('set'); + $client = new GPIORelaydClient($config['pump_host'], $config['pump_port']); + + if ($set == GPIORelaydClient::STATUS_ON || $set == GPIORelaydClient::STATUS_OFF) { + $client->setStatus($set); + redirect('/pump/'); + } + + $status = $client->getStatus(); + + $this->tpl->set([ + 'status' => $status + ]); + $this->tpl->set_title('Насос'); + $this->tpl->render_page('pump.twig'); + } + +}
\ No newline at end of file |