Author Topic: ALTUI : Plugin development  (Read 5336 times)

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2879
  • Karma: +189/-8
ALTUI : Plugin development
« on: August 08, 2015, 05:45:05 am »
Thread to discuss development of plugins for ALTUI. 
ALTUI displays most of VERA plugin but can go much further in user interface by supporting ALTUI native plugins.
There is a javascript api that plugin author can use,  and there is a LUA configuration api ( Upnp action ) that can be called to register a new plugin

Javascript apis for plugin themselves:
  • drawing a plugin small dashboarb panel
  • drawing a full blown plugin control panel page
  • dynamically chosing an icon to be displayed
  • injecting css style in the page
  • Upnp action to register a device type and the plugin callback functions into ALTUI lua handler

Vera box control apis :
  • Use only the MultiBox object public api, it should cover almost all possible actions on a box and supports multiple box
  • do not query devices by yourself using user_data or equivalent, use MutliBox.getDevices() & others apis
  • device , scene, room etc are object, similar to what user_data provides, with a few extra altui internal fields like altuiid
  • device.id is a single box identificator,  so most of the time, MultiBox object uses device.altuiid which is a universally unique id accross the multiple boxes , or the device object itself

Code: [Select]
MultiBox.getStatus( device, service, variable )
EDIT: Sept 4th 2015 : attaching a tutorial document
« Last Edit: September 04, 2015, 05:55:49 pm by amg0 »

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1276
  • Karma: +72/-30
Re: ALTUI : Plugin development
« Reply #1 on: August 23, 2015, 11:56:42 am »
Hi amg0,

Just updated an other plug in to be support ALTUI.

For reading Smart Meters as used in the Netherlands http://apps.mios.com/plugin.php?id=8342

I did notice one thing. If the json is used on UI5 and UI7 it can have both definitions for the icon so for some cases you do not need to make a UI7 specific one. So this is in the JSON:
   "default_icon": "meter_default.png",
   "flashicon": "icons\/Power_Meter.png",

It seems also on a UI7 system it always uses the flashicon. As in my case I want to use the same icon as a Power device it is two different ones.

Is this a quick fix for you? Else I can make tweak my plugin to have a symbolic link to the correct icon file and use the same name on all platforms.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2879
  • Karma: +189/-8
Re: ALTUI : Plugin development
« Reply #2 on: September 01, 2015, 12:54:54 pm »
Hi amg0,

Just updated an other plug in to be support ALTUI.

For reading Smart Meters as used in the Netherlands http://apps.mios.com/plugin.php?id=8342

I did notice one thing. If the json is used on UI5 and UI7 it can have both definitions for the icon so for some cases you do not need to make a UI7 specific one. So this is in the JSON:
   "default_icon": "meter_default.png",
   "flashicon": "icons\/Power_Meter.png",

It seems also on a UI7 system it always uses the flashicon. As in my case I want to use the same icon as a Power device it is two different ones.

Is this a quick fix for you? Else I can make tweak my plugin to have a symbolic link to the correct icon file and use the same name on all platforms.

Cheers Rene

to be clear, you would like that I use "default_icon" on a UI7 box and "flashicon" on a UI5 box ?
thx to confirm

EDIT: ( changed the order )
EDIT2:  in V 0.67.646,  I use "default_icon" on a UI7 box and "flashicon" on a UI5 box
« Last Edit: September 02, 2015, 01:52:11 am by amg0 »

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1276
  • Karma: +72/-30
Re: ALTUI : Plugin development
« Reply #3 on: September 02, 2015, 07:12:40 am »
Hi amg0,

Just updated an other plug in to be support ALTUI.

For reading Smart Meters as used in the Netherlands http://apps.mios.com/plugin.php?id=8342

I did notice one thing. If the json is used on UI5 and UI7 it can have both definitions for the icon so for some cases you do not need to make a UI7 specific one. So this is in the JSON:
   "default_icon": "meter_default.png",
   "flashicon": "icons\/Power_Meter.png",

It seems also on a UI7 system it always uses the flashicon. As in my case I want to use the same icon as a Power device it is two different ones.

Is this a quick fix for you? Else I can make tweak my plugin to have a symbolic link to the correct icon file and use the same name on all platforms.

Cheers Rene

to be clear, you would like that I use "default_icon" on a UI7 box and "flashicon" on a UI5 box ?
thx to confirm

EDIT: ( changed the order )
EDIT2:  in V 0.67.646,  I use "default_icon" on a UI7 box and "flashicon" on a UI5 box
Thanks amg0, I'll give that version a go soon.
Update: I just looked and works like a charm  :)

Cheers Rene
« Last Edit: September 03, 2015, 05:34:39 pm by reneboer »
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline akbooer

  • Master Member
  • *******
  • Posts: 5812
  • Karma: +249/-69
  • "Less is more"
Re: ALTUI : Plugin development
« Reply #4 on: September 14, 2015, 12:14:35 pm »
V 0.74.689
  • Management of device variable watch as triggers for scene. see notes below

...adding new functionality and extra work to the Vera plugin ... ?!!

No, seriously, I think this is a great way to go.  It's the way I write triggers in openLuup, since I haven't yet implemented them in the standard way... but now I don't have to, since you've given us an interface that can do it for us!

Thanks so much for the continuing amazing work.


3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 4x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2879
  • Karma: +189/-8
Re: ALTUI : Plugin development
« Reply #5 on: September 14, 2015, 02:39:23 pm »
V 0.74.689
  • Management of device variable watch as triggers for scene. see notes below

...adding new functionality and extra work to the Vera plugin ... ?!!

No, seriously, I think this is a great way to go.  It's the way I write triggers in openLuup, since I haven't yet implemented them in the standard way... but now I don't have to, since you've given us an interface that can do it for us!

Thanks so much for the continuing amazing work.
with parsimony
 :)

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2879
  • Karma: +189/-8
Re: ALTUI : Plugin development
« Reply #6 on: September 18, 2016, 12:02:12 pm »
New possibility for plugin authors

now it is possible define plugin callback functions not just for a given device type but for a matching pair of device type and JSON file. some device like the QUbino flush wire for instance report a device type but use a device json file which is for a different device type.

the additional flexibility enables to have different display callback function, even for a given device type. the way it works is to define an entry in the configuration table with device_type","device json like this

+   tbl["urn:schemas-upnp-org:device:DimmableLight:1,D_QubinoFlushPilotWire1.json"]= {
 +      ["ScriptFile"]="J_ALTUI_plugins.js",
 +      ["DeviceDrawFunc"]="ALTUI_PluginDisplays.drawDimmableQubinoFlushPilotWire",
 +   }

it takes precedence over the entry without the "," and json file. so ALTUI tries to find first the complete pair,  then tries to find the device type only, then defaults to default device drawing