We have moved at community.getvera.com

Author Topic: Plugin - Variable Container  (Read 123518 times)

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Plugin - Variable Container
« on: January 11, 2012, 02:36:04 am »

Plugin has been unpublished by me. I don't want to continue to work for such a company.


I created myself a plugin which creates a device with five string variables, and five string variables to name these variables. These variables can be read and written by luup code or in the device settings tab (advanced). The value of this ten variables is shown in the dashboard too.

As an example the plugin can be used to transfer variables in between scenes or as a configuration window to centralize settings for luup scenes or it could be used to show values of different devices in the dashboard. I use it to see directly in the UI which scene was last used and at what time, when doors were opened etc. I use it for luup logic too, in example I have a variable  for one of my rooms which ?always? knows if lights were last turned on by motion(1) or manually(0), the scene which should turn of lights automatically  (only when they were turned on automatically) therefore can check if lights were manually or automatically turned on. Possibilities are endless, anything is possible.

To integrate with scenes luup code has to be used at the moment (Variables 1-5):
Code: [Select]
luup.variable_set("urn:upnp-org:serviceId:VContainer1","VariableName1","Variable1",lul_device)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable1","value",lul_device)

luup.variable_get("urn:upnp-org:serviceId:VContainer1","VariableName2", lul_device)
luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable2", lul_device)

Setting Values by http: http://forum.micasaverde.com/index.php/topic,9022.msg86354.html#msg86354

A function makes getting and setting variables much easier: http://forum.micasaverde.com/index.php/topic,9022.msg82836.html#msg82836

Installation:

This works on UI4 and UI5, but on UI4 has to be installed manually (http://wiki.micasaverde.com/index.php/Install_LUUP_Plugins).

Through the App Store (UI5):
http://apps.mios.com/plugin.php?id=1458

Manually (UI4):
?   Download the four files from the links below (newest version is recommended).
?   Upload them to your vera (Apps=>Develop Apps=>Luup Files)
?   Create a Device (Apps=>Develop Apps=>Create Device) and set ?D_VContainer.xml? as the Upnp Device Filename.
?   Restart Lua Engine


Version History:

VERSION 1.0
http://apps.mios.com/download-plugin.php?PK_Version=3018

VERSION 1.1
http://forum.micasaverde.com/index.php/topic,9022.msg60420.html#msg60420

VERSION 1.2
http://forum.micasaverde.com/index.php/topic,9022.msg61402.html#msg61402

VERSION 1.3
http://forum.micasaverde.com/index.php/topic,9022.msg62472.html#msg62472

VERSION 1.4
http://forum.micasaverde.com/index.php/topic,9022.msg76193.html#msg76193

VERSION 1.5
http://forum.micasaverde.com/index.php/topic,9022.msg78844.html#msg78844

VERSION 1.6
http://forum.micasaverde.com/index.php?topic=9022.msg92542#msg92542

VERSION 1.7
http://forum.micasaverde.com/index.php/topic,9022.msg103071.html#msg103071

VERSION 1.8
http://forum.micasaverde.com/index.php/topic,9022.msg138136.html#msg138136

VERSION 1.9
http://forum.micasaverde.com/index.php/topic,9022.msg211805.html#msg211805
« Last Edit: January 23, 2015, 08:46:02 am by chixxi »
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #1 on: January 11, 2012, 02:36:54 am »
...some screenshots...
« Last Edit: January 31, 2012, 04:53:27 am by chixxi »
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #2 on: January 12, 2012, 04:20:25 am »
wow, the approval on apps.miso.com only took 13 hours (!!!):

http://apps.mios.com/plugin.php?id=1458
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline rodatboat

  • Newbie
  • *
  • Posts: 10
  • Karma: +1/-0
Re: Plugin - Variable Container
« Reply #3 on: January 12, 2012, 11:40:45 am »
Thanks!

This is exactly what I have been needing for a plugin I'm working on.

Offline kartcon

  • Full Member
  • ***
  • Posts: 158
  • Karma: +7/-0
Re: Plugin - Variable Container
« Reply #4 on: January 12, 2012, 07:09:33 pm »
Chixxi,

Just a few minutes ago I posted a new topic asking if anyone has done this, and then, wow, I find this. I just downloaded and will start playing with it tonight. If it works like I hope, you will have saved me a ton of time and effort! I'll let you know how I make out and if I make any additional changes.

Update: THIS IS EXCELLENT! MCV should build this into the next major upgrade. Wish list: 1) Java or Ajax updates on the variables, so the page changes dynamically as the variables change, 2) 5 more Name/Value pairs, 3) Display Tab1 on dashboard with some text that says "Watching X variables", where x= total of all variables that do not have the default name, hence, are being 'watched'.

Great work,  and thanks again for posting.

kartcon
« Last Edit: January 12, 2012, 10:03:56 pm by kartcon »

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #5 on: January 13, 2012, 02:58:35 am »
I am glad somebody can use it. Its quiet a simple thing but possibilities are endless.

Thanks for the wishlist. I am  working on the next version, but I also have some other plugins which I am working on...
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline smilligan

  • Full Member
  • ***
  • Posts: 108
  • Karma: +0/-0
Re: Plugin - Variable Container
« Reply #6 on: January 13, 2012, 10:17:12 am »
Chixxi,

Thanks for implementing this..  It is so obvious that the VERA UIx needed something like this for support of Scenes, that i think it has simply been overlooked.

I was able to install from app.mios.com onto UI5/Vera2 host and that worked great..

I did install from apps.mios.com on UI4 VERA2 and it seemed to install, but name on plugin was incorrect (testsilviu) as well as name on Device (_Tv) were incorrect.  Also variables did not show up for the device that was created by plugin.  So i removed it.   I will download your source code and see if installing it manually helps.

I will post my results on UI4 installation at later date

Thanks again for "good idea" and implementation thereof.

Kind Regards
« Last Edit: January 13, 2012, 10:32:03 am by smilligan »

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #7 on: January 16, 2012, 11:28:31 am »
I think apps.mios.com is not compatible with UI4. And since I didn't get my Vera3 yet I can not test on UI4, I need UI5 for the Aeon Labs Minimote on my Vera2. Did you have any success with manual installation on UI4?

I am working on the javascript version. Expecting a basic update in 1-2 weeks.

@kartcon: If you need more variables just create a second device, then you get five more.  ::)
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline kartcon

  • Full Member
  • ***
  • Posts: 158
  • Karma: +7/-0
Re: Plugin - Variable Container
« Reply #8 on: January 18, 2012, 10:34:18 am »
Chixxi,

Since this was so useful to me I decided to update your code to add 5 more variables. I also wanted to be able to know which scenes had run recently so I added some code to do that as well. The last run scene goes into Variable 6 and any current data in Variables 7 - 10 get pushed down the list eventually pushing #10 off the list. This has worked extremely well for me and it allows me to confirm that silent scenes (not visually obvious) ran as planned. I'm still working on the code to update the dashboard which says "Watching x variables". Currently it is a static number entered in the advanced tab.

To reduce to code overhead, I wrote a function that gets added to Startup Lus tab, and a small calling routine that updated the variables. All the code and updated files included below.

Thanks again for a great tool - and the motivation to start learning how to program my Vera make it do what I want.

Here's a screenshot from this morning.
http://www.quartermidgets.org/temp/VarConScreenShot.gif

Place this in the Startup Lua tab:
Code: [Select]
function log_last_scene (last_scene)
local lul_Var9 = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable9", 34)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable10",lul_Var9,34)
local lul_Var8 = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable8", 34)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable9",lul_Var8,34)
local lul_Var7 = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable7", 34)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable8",lul_Var7,34)
local lul_Var6 = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable6", 34)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable7",lul_Var6,34)
luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable6",last_scene,34)
end

Next add this to the Luup tab of the Scene you want to log:

Code: [Select]
log_last_scene("Your_Scene_Name")

Lastly, update the 4 files:
D_VarCon.json, D_VarCon.xml, I_VarCon.xml & S_VarCon.xml

Hope someone can use this.

kartcon
« Last Edit: January 18, 2012, 10:41:45 am by kartcon »

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #9 on: January 18, 2012, 12:17:50 pm »
very very nice! is it ok if I implement some of your ideas (and code) in the next update for apps.mios.com?

It would be kind of nice to publish your "Last Scene Run Counter" as a separate plugin...

Going to take a closer look sometime on the weekend.
« Last Edit: January 18, 2012, 12:22:57 pm by chixxi »
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline kartcon

  • Full Member
  • ***
  • Posts: 158
  • Karma: +7/-0
Re: Plugin - Variable Container
« Reply #10 on: January 19, 2012, 12:10:40 am »
Chixxi,

Yes, please do. Feel free to use any of my code in your development process. The ultimate goal is a better product for everyone.
BTW, I'm using a Vera 2 on UI4 (build 1.1.1362) and it works just fine.

kartcon

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #11 on: January 22, 2012, 08:36:15 am »
VERSION 1.1

I uploaded version 1.1 of the plugin VariableContainer to apps.mios.com.

For UI4 / manual installation download files here and install as described in the first post of this thread:
http://apps.mios.com/download-plugin.php?PK_Version=3178

This update includes a new tab based on java-script to edit the variables. See screenshot attached.
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline mcvflorin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1755
  • Karma: +11/-3
Re: Plugin - Variable Container
« Reply #12 on: January 23, 2012, 09:37:30 am »
@chixxi

I couldn't approve the version you submitted because the plugin didn't install correctly. There is a bug in the release version of the firmware: it cannot install uncompressed files. This has been fixed in the latest beta.

Until then, I modified your plugin to use a web based icon, and published this version.

* Unfortunately the current page layout cannot handle long version comments properly, you'll see what I'm talking about when you visit the Version page. :) We'll fix this by the end of the week.


Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #13 on: January 23, 2012, 12:31:58 pm »
WOW, thank you for the quick fix! I love problems which resolve themselves automatically  ;D

I must have done something wrong when publishing since I was aware of that problem and didn't want to release a version with custom icon. But thank you very very much again!

By the way, I have two wishes for apps.mios.com: 1. Please add a delete button to the versions. 2. Add something like "Downloaded XXXXX times" in the app store for each plugin.
 
And I am glad to hear about some nice fixes in the next beta...
« Last Edit: January 23, 2012, 12:43:20 pm by chixxi »
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin - Variable Container
« Reply #14 on: January 31, 2012, 04:47:34 am »
VERSION 1.2

I uploaded version 1.2 of the plugin VariableContainer to apps.mios.com.

For UI5 let the plugin automatically be installed from apps.mios.com:
http://apps.mios.com/plugin.php?id=1458

For UI4 / manual installation download files here and install as described in the first post of this thread:
http://apps.mios.com/download-plugin.php?PK_Version=3438

This update includes a new save-button which allows changing the variables on the flow without having to restart the luup engine on each change.
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.