Adding a new device type

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
m (Main logic)
m (Main logic)
Line 69: Line 69:
 
=== Main logic ===
 
=== Main logic ===
 
File name: devices/wake_on_lan/agowake_on_lan.py
 
File name: devices/wake_on_lan/agowake_on_lan.py
Finally, a device driver that uses the new device type. This is a plain vanilla task as outlined in [[Example device]].
+
Finally, a device driver that uses the new device type. This is a plain vanilla task as outlined in [[Example Device]].
 
     client.addDevice(deviceId, "computer")
 
     client.addDevice(deviceId, "computer")
  

Revision as of 17:03, 22 January 2014

Contents

Tutorial for adding a new device type

This tutorial will take you through all steps and files needed to add a new device type to aGo control. As an example the "Computer" device type used by Wake-on-LAN (WOL) will be used.

Add to schema - conf/schema.yaml

 computer:
   name: General computer (for WOL)
   description: A computer
   commands: ["on"]


Add to main web script

File name: core/rpc/html/js/app.js Change the following:

var supported_devices = [ "switch", "dimmer", "binarysensor", "dimmerrgb", "multilevelsensor",
"scenario", "drapes", "brightnesssensor", "powermeter", "energysensor", "humiditysensor", "phone",
"pushbutton", "placeholder", "temperaturesensor", "energymeter", "squeezebox", "computer" ];

HTLM template for device

File name: core/rpc/html/templates/devices/computer.in.html

<ko opts="if: room ">

</ko>

<ko opts="if: state() == 0"> <_span data-translateable="true">OFF</_span> </ko> <ko opts="if: state() == 255"> <_span data-translateable="true">ON</_span> </ko>

<ko opts="if: state ">

               <_div data-translateable="true" class="cmd-btn pretty medium default btn btn-full grid-command" data-bind="click: turnOn" data-value="on">ON</_div>
           </ko>
           <ko opts="ifnot: state ">
               <_div data-translateable="true" class="cmd-btn pretty medium primary btn btn-full grid-command" data-bind="click: turnOn" data-value="on">ON</_div>
           </ko>

debian install script

File name: debian/agocontrol-wake_on_lan.install

Update makefile

File name: devices/Makefile

New make file

File name: devices/wake_on_lan/Makefile


Device driver

Main logic

File name: devices/wake_on_lan/agowake_on_lan.py Finally, a device driver that uses the new device type. This is a plain vanilla task as outlined in Example Device.

    client.addDevice(deviceId, "computer")

Config file

File name: devices/wake_on_lan/wake_on_lan.conf


Service definition

File name: conf/systemd/agowake_on_lan.service

Personal tools