Skip to content

Commit

Permalink
Merge pull request #35 from SenorSmartyPants/master
Browse files Browse the repository at this point in the history
Add Domoticz Enhanced App
  • Loading branch information
KodeStar authored Feb 16, 2019
2 parents f5f2b5e + 18140de commit bee8f1e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Domoticz/Domoticz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php namespace App\SupportedApps\Domoticz;

class Domoticz 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('type=command&param=getversion'));
echo $test->status;
}

public function livestats()
{
$status = 'inactive';
$res = parent::execute($this->url('type=devices&rid='.$this->config->deviceidx));
$details = json_decode($res->getBody());

$data = [];

if($details) {
$data['today'] = $details->result[0]->CounterToday ?? 0;
$data['usage'] = $details->result[0]->Usage ?? 0;
}

return parent::getLiveStats($status, $data);

}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).'json.htm?'.$endpoint;
return $api_url;
}
}
10 changes: 10 additions & 0 deletions Domoticz/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"appid": "17ea5305bc5cb99da61e121542864bb15e280f30",
"name": "Domoticz",
"website": "https://www.domoticz.com/",
"license": "GNU General Public License v3.0 only",
"description": "Open source Home Automation System",
"enhanced": true,
"tile_background": "dark",
"icon": "domoticz.png"
}
15 changes: 15 additions & 0 deletions Domoticz/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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>Device Idx</label>
{!! Form::text('config[deviceidx]', (isset($item) ? $item->getconfig()->deviceidx : null), array('placeholder' => "Device Idx from Devices page", 'data-config' => 'deviceidx', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

Binary file added Domoticz/domoticz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Domoticz/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Today</span>
<strong>{!! $today !!}</strong>
</li>
<li>
<span class="title">Usage</span>
<strong>{!! $usage !!}</strong>
</li>
</ul>

0 comments on commit bee8f1e

Please sign in to comment.