Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/device-integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Jul 11, 2018
2 parents b8226eb + 89c9c6b commit 7ae08aa
Show file tree
Hide file tree
Showing 28 changed files with 2,800 additions and 816 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ Click save to continue.

![3.png](files/3.png)

With the device created the next step is to initialize the device, click on the cycling arrows 'refresh icon' to bring up the initialization window.
When a new device is created, it will automatically be initialized and all input processes and feeds will be created, according to the pre-defined template. If the template needs to be applied again, as e.g. a process list was experimented on and altered, or single feeds deleted, it may be re-initialized. Clicking the cycling arrows 'refresh icon' will bring up the initialization window.

![4.png](files/4.png)

Click 'Initialize' to initialize the device which will create the input processes and feeds according to the pre-defined template.
Click 'Initialize' to re-initialize the device and to confirm the creation of missing feeds and inputs, as well as the reset of configured processes to their original state.

![5.png](files/5.png)

Expand Down
42 changes: 26 additions & 16 deletions Views/device.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
var device = {
'list':function()
{
'list':function() {
var result = {};
$.ajax({ url: path+"device/list.json", dataType: 'json', async: false, success: function(data) {result = data;} });
return result;
},

'set':function(id, fields)
{
'get':function(id) {
var result = {};
$.ajax({ url: path+"device/get.json", data: "id="+id, async: false, success: function(data) {result = data;} });
return result;
},

'set':function(id, fields) {
var result = {};
$.ajax({ url: path+"device/set.json", data: "id="+id+"&fields="+JSON.stringify(fields), async: false, success: function(data) {result = data;} });
return result;
},

'remove':function(id)
{
$.ajax({ url: path+"device/delete.json", data: "id="+id, async: false, success: function(data){} });
'setNewDeviceKey':function(id) {
var result = {};
$.ajax({ url: path+"device/setnewdevicekey.json", data: "id="+id, async: false, success: function(data) {result = data;} });
return result;
},

'remove':function(id) {
var result = {};
$.ajax({ url: path+"device/delete.json", data: "id="+id, async: false, success: function(data) {result = data;} });
return result;
},

'create':function(id)
{
$.ajax({ url: path+"device/create.json", data: "id="+id, async: false, success: function(data){} });
'create':function(nodeid, name, description, type) {
var result = {};
$.ajax({ url: path+"device/create.json", data: "nodeid="+nodeid+"&name="+name+"&description="+description+"&type="+type, async: false, success: function(data) {result = data;} });
return result;
},

'listtemplates':function()
{
'init':function(id, template) {
var result = {};
$.ajax({ url: path+"device/listtemplates.json", dataType: 'json', async: false, success: function(data) {result = data;} });
$.ajax({ url: path+"device/init.json?id="+id, type: 'POST', data: "template="+JSON.stringify(template), dataType: 'json', async: false, success: function(data) {result = data;} });
return result;
},

'inittemplate':function(id)
{
'prepareTemplate':function(id) {
var result = {};
$.ajax({ url: path+"device/inittemplate.json", data: "id="+id, dataType: 'json', async: false, success: function(data) {result = data;} });
$.ajax({ url: path+"device/template/prepare.json", data: "id="+id, dataType: 'json', async: false, success: function(data) {result = data;} });
return result;
}
}
29 changes: 20 additions & 9 deletions Views/device_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,30 @@
<table class="table">
<tr><td><?php echo _('List devices'); ?></td><td><a href="<?php echo $path; ?>device/list.json"><?php echo $path; ?>device/list.json</a></td></tr>
<tr><td><?php echo _('Get device details'); ?></td><td><a href="<?php echo $path; ?>device/get.json?id=1"><?php echo $path; ?>device/get.json?id=1</a></td></tr>
<tr><td><?php echo _('Add a device'); ?></td><td><a href="<?php echo $path; ?>device/create.json"><?php echo $path; ?>device/create.json</a></td></tr>
<tr><td><?php echo _('Delete device'); ?></td><td><a href="<?php echo $path; ?>device/delete.json?id=0"><?php echo $path; ?>device/delete.json?id=0</a></td></tr>
<tr><td><?php echo _('Update device'); ?></td><td><a href="<?php echo $path; ?>device/set.json?id=0&fields={%22name%22:%22Test%22,%22description%22:%22Room%22,%22nodeid%22:%22House%22,%22type%22:%22test%22}"><?php echo $path; ?>device/set.json?id=0&fields={"name":"Test","description":"Room","nodeid":"House","type":"test"}</a></td></tr>
<tr><td><?php echo _('List templates'); ?></td><td><a href="<?php echo $path; ?>device/listtemplates.json"><?php echo $path; ?>device/listtemplates.json</a></td></tr>
<tr><td><?php echo _('Initialize device'); ?></td><td><a href="<?php echo $path; ?>device/inittemplate.json?id=0"><?php echo $path; ?>device/inittemplate.json?id=0</a></td></tr>
<tr><td><?php echo _('Add a device'); ?></td><td><a href="<?php echo $path; ?>device/create.json?nodeid=Test&name=Test"><?php echo $path; ?>device/create.json?nodeid=Test&name=Test</a></td></tr>
<tr><td><?php echo _('Delete device'); ?></td><td><a href="<?php echo $path; ?>device/delete.json?id=1"><?php echo $path; ?>device/delete.json?id=1</a></td></tr>
<tr><td><?php echo _('Update device'); ?></td><td><a href="<?php echo $path; ?>device/set.json?id=1&fields={%22name%22:%22Test%22,%22description%22:%22Room%22,%22nodeid%22:%22House%22,%22type%22:%22test%22}"><?php echo $path; ?>device/set.json?id=1&fields={"name":"Test","description":"Room","nodeid":"House","type":"test"}</a></td></tr>
<tr><td><?php echo _('Initialize device'); ?></td><td><a href="<?php echo $path; ?>device/init.json?id=1"><?php echo $path; ?>device/init.json?id=1</a></td></tr>
</table>

<p><b><?php echo _('Device MQTT authentication'); ?></b></p>
<table class="table">
<tr><td><?php echo _('Request authentication'); ?></td><td><a href="<?php echo $path; ?>device/auth/request.json"><?php echo $path; ?>device/auth/request.json</a></td></tr>
<tr><td><?php echo _('Check authentication request'); ?></td><td><a href="<?php echo $path; ?>device/auth/check.json"><?php echo $path; ?>device/auth/check.json</a></td></tr>
<tr><td><?php echo _('Allow authentication request'); ?></td><td><a href="<?php echo $path; ?>device/auth/allow.json?ip=127.0.0.1"><?php echo $path; ?>device/auth/allow.json?ip=127.0.0.1</a></td></tr>
</table>

<p><b><?php echo _('Template actions'); ?></b></p>
<table class="table">
<tr><td><?php echo _('List template metadata'); ?></td><td><a href="<?php echo $path; ?>device/template/listshort.json"><?php echo $path; ?>device/template/listshort.json</a></td></tr>
<tr><td><?php echo _('List templates'); ?></td><td><a href="<?php echo $path; ?>device/template/list.json"><?php echo $path; ?>device/template/list.json</a></td></tr>
<tr><td><?php echo _('Reload templates'); ?></td><td><a href="<?php echo $path; ?>device/template/reload.json"><?php echo $path; ?>device/template/reload.json</a></td></tr>
<tr><td><?php echo _('get template details'); ?></td><td><a href="<?php echo $path; ?>device/template/get.json?type=example"><?php echo $path; ?>device/template/get.json?type=example</a></td></tr>
<tr><td><?php echo _('Prepare device initialization'); ?></td><td><a href="<?php echo $path; ?>device/template/prepare.json?id=1"><?php echo $path; ?>device/template/prepare.json?id=1</a></td></tr>
</table>

<a class="anchor" id="expression"></a>
<h3><?php echo _('Devices templates documentation'); ?></h3>
<p><?php echo _('Template files are located at <b>\'\\Modules\\device\\data\\*.json\'</b>'); ?></p>
<p><?php echo _('Each file defines a device type and provides the default inputs and feeds configurations for that device.'); ?></p>
<p><?php echo _('A device should only need to be initialized once on instalation. Initiating a device twice will duplicate its default inputs and feeds.'); ?></p>




Loading

0 comments on commit 7ae08aa

Please sign in to comment.