ajout heimdall
This commit is contained in:
54
heimdall/config/www/SupportedApps/AlarmPI/AlarmPI.php
Executable file
54
heimdall/config/www/SupportedApps/AlarmPI/AlarmPI.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php namespace App\SupportedApps\AlarmPI;
|
||||
|
||||
class AlarmPI extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
|
||||
public $config;
|
||||
|
||||
//protected $login_first = true; // Uncomment if api requests need to be authed first
|
||||
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
|
||||
|
||||
function __construct() {
|
||||
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
// $test = parent::appTest($this->url('getSensors.json'), $this->attrs);
|
||||
$res = parent::execute($this->url('getSensors.json'), $this->attrs);
|
||||
echo $res->getBody();
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
|
||||
$res = parent::execute($this->url('getSensors.json'), $this->attrs);
|
||||
$details = json_decode($res->getBody());
|
||||
$activesensors = 0;
|
||||
|
||||
foreach ($details->sensors as $key => $value) {
|
||||
if ($value->enabled && $value->alert){
|
||||
$activesensors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($details->triggered){
|
||||
$alarmstatus = 'Intruder';
|
||||
} else if ($details->alarmArmed){
|
||||
$alarmstatus = 'Armed';
|
||||
} else {
|
||||
$alarmstatus = 'Disarmed';
|
||||
}
|
||||
$data['alarm_status'] = $alarmstatus;
|
||||
$data['alarm_sensors'] = $activesensors;
|
||||
return parent::getLiveStats($status, $data);
|
||||
|
||||
}
|
||||
public function url($endpoint)
|
||||
{
|
||||
$this->attrs = ['auth'=> [$this->config->username, $this->config->password, 'Basic']];
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
BIN
heimdall/config/www/SupportedApps/AlarmPI/alarmpi.png
Executable file
BIN
heimdall/config/www/SupportedApps/AlarmPI/alarmpi.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
10
heimdall/config/www/SupportedApps/AlarmPI/app.json
Executable file
10
heimdall/config/www/SupportedApps/AlarmPI/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "4a1349c03398a3e66f6efdf6395fb689d80f83fa",
|
||||
"name": "AlarmPI",
|
||||
"website": "https://github.com/bkbilly/AlarmPI",
|
||||
"license": "MIT License",
|
||||
"description": "AlarmPI is a home security system based on Raspberry PI. It supports wired sensors (PIR, Magnetic etc.) and wireless through MQTT or Hikvision.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "alarmpi.png"
|
||||
}
|
||||
19
heimdall/config/www/SupportedApps/AlarmPI/config.blade.php
Executable file
19
heimdall/config/www/SupportedApps/AlarmPI/config.blade.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.username') }}</label>
|
||||
{!! Form::text('config[username]', (isset($item) ? $item->getconfig()->username : null), array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.password') }}</label>
|
||||
{!! Form::text('config[password]', null, array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
10
heimdall/config/www/SupportedApps/AlarmPI/livestats.blade.php
Executable file
10
heimdall/config/www/SupportedApps/AlarmPI/livestats.blade.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Status</span>
|
||||
<strong>{!! $alarm_status !!}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Sensors</span>
|
||||
<strong>{!! $alarm_sensors !!}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user