Author Topic: MultiString Plugin  (Read 16569 times)

Offline MarkAgain

  • Full Member
  • ***
  • Posts: 128
  • Karma: +3/-0
Re: MultiString Plugin
« Reply #15 on: February 26, 2015, 03:00:09 am »
Thank you Rex!  Thanks to chixxi as well for making this compatible.  I for one will miss him.  One of my main concerns with the upcoming update to UI7 was the loss of this capability.

I am thinking about changing my Variable Container(s) to your MultiString.  I have a good many lines of Lua that reference 6 Variable Container(s).  What would you suggest as the best approach?  I was thinking about copying and pasting all of the Lua code into text files, removing the Variable Container plugin, installing Multistring and pasting the code back in.  With the new dID(s) of course.   ;)

Thanks again!  Mark

Offline akbooer

  • Master Member
  • *******
  • Posts: 5128
  • Karma: +221/-67
  • "Less is more"
Re: MultiString Plugin
« Reply #16 on: February 26, 2015, 04:40:53 am »
A while ago I wrote a bit of code to access VContainers by device name, rather than ID, so that I never had to worry about changing them again (assuming, of course, that you keep the same name!!)

http://forum.micasaverde.com/index.php/topic,9022.msg112744.html#msg112744

...could easily be modified for MultiString devices.

Not sure if this might help in your case @MarkAgain?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #17 on: February 26, 2015, 07:44:32 am »
Thank you Rex!  Thanks to chixxi as well for making this compatible.  I for one will miss him.  One of my main concerns with the upcoming update to UI7 was the loss of this capability.

I am thinking about changing my Variable Container(s) to your MultiString.  I have a good many lines of Lua that reference 6 Variable Container(s).  What would you suggest as the best approach?  I was thinking about copying and pasting all of the Lua code into text files, removing the Variable Container plugin, installing Multistring and pasting the code back in.  With the new dID(s) of course.   ;)

Thanks again!  Mark

The easiest approach would be to convert the existing devices to MultiString so that they retain their device numbers. You then should not need to change any Lua code. First install MultiString to get all the new files loaded. Leave the new device for the moment. This will change the appearance of your existing VC devices but they will not really be MultiString yet.

Convert each VC device to MultiString as follows:

Open the device's Advanced tab. The device-type is already the same. All that should be necessary is to change device_file to D_MString.xml and impl_file to I_MString.xml. Then Save/Reload and refresh the page. There will be a change in appearance but the functionality should be the same.

Vera will still think the devices are using the VC plugin so they will not be listed on the MultiString APP tab. If you keep the new device, this will download any updates which will also be used by the converted devices.

I would convert one device and check it all still works before doing them all.  ;)
« Last Edit: February 26, 2015, 08:13:12 am by RexBeckett »

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9568
  • Karma: +729/-136
    • RTS Services Plugins
Re: MultiString Plugin
« Reply #18 on: February 26, 2015, 09:22:53 am »
You can also change the pluginid in the device (From the advanced tab) ... than it should show up as a MultiString plugin in the APPS menu.
 

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #19 on: February 26, 2015, 09:42:30 am »
You can also change the pluginid in the device (From the advanced tab) ... than it should show up as a MultiString plugin in the APPS menu.

I never tried that. That's a good tip, Richard.

Offline MarkAgain

  • Full Member
  • ***
  • Posts: 128
  • Karma: +3/-0
Re: MultiString Plugin
« Reply #20 on: February 26, 2015, 12:57:24 pm »
@akbooer:  Thanks for the idea.  I will put it in soon...   :)

@RexBecket:  Thanks again!  Just completed the change.  Not much work at all.  Sure glad I asked!  I would have spent hours.   :D

@RichardTSchaefer:  Thank you for the tip.  All containers show up in the Apps area as if there were always there.   :)


Thank you all!

Mark

« Last Edit: February 26, 2015, 02:59:52 pm by MarkAgain »

Offline MarkAgain

  • Full Member
  • ***
  • Posts: 128
  • Karma: +3/-0
Re: MultiString Plugin
« Reply #21 on: February 26, 2015, 03:03:43 pm »
I just used HomeBuddy on my phone.  All of the MultiString(s) show up as before using the new MultiString plugin.  The Variable Container icon is displayed.

Thanks again, Mark

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #22 on: February 26, 2015, 04:58:57 pm »
I just used HomeBuddy on my phone.  All of the MultiString(s) show up as before using the new MultiString plugin.  The Variable Container icon is displayed.

Thanks again, Mark

Thanks for the report, Mark. The icon is probably linked to the device-type in most mobile Apps so it will likely not change.

Offline jjwalker

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +0/-0
Re: MultiString Plugin
« Reply #23 on: March 02, 2015, 05:59:46 pm »
I'm still really new to luup so I just wanna check to see if this is the correct way in getting a variable per the VC thread.

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

"V1" being variable 1 in multstring. 


Thanks

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #24 on: March 02, 2015, 06:03:11 pm »
I'm still really new to luup so I just wanna check to see if this is the correct way in getting a variable per the VC thread.

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

"V1" being variable 1 in multstring. 


Thanks

Nearly. Try this:

Code: [Select]
x = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", lul_device)
This assumes that lul_device is a variable containing the device number of the MultiString.

« Last Edit: March 02, 2015, 06:04:59 pm by RexBeckett »

Offline jjwalker

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +0/-0
Re: MultiString Plugin
« Reply #25 on: March 02, 2015, 06:15:25 pm »
I'm still really new to luup so I just wanna check to see if this is the correct way in getting a variable per the VC thread.

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

"V1" being variable 1 in multstring. 


Thanks

Nearly. Try this:

Code: [Select]
x = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", lul_device)
This assumes that lul_device is a variable containing the device number of the MultiString.

Awesome!  Thank you.  I'm getting a very strange result though.  I'm working on implementing AutoVoice with AutoVera to send a string to Multistring. 

This is my code in PLEG/LUUP

Code: [Select]
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local sayText = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", lul_device)


luup.call_action(LS_SID, "Say", {Text = sayText, Language="en", Volume=50}, 72)

I'm getting Sonos saying "The monkey is on the branch and the mouse is under the table".  But I had autovoice capture "testing+one+two+three".  I just tried doing this..

Code: [Select]
local sayText = string.format(luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", lul_device))

But Sonos didn't even say anything with string.format call.  I don't know where the monkey message came from, sounds like some kind of default test message.

Or perhaps I wrote the string.format call wrong. 


Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #26 on: March 02, 2015, 06:22:21 pm »
Quote
Or perhaps I wrote the string.format call wrong.

You provided string.format(...) with a string but where's the format? See http://www.lua.org/manual/5.1/manual.html#pdf-string.format

You are setting a value into lul_device, aren't you?

Offline jjwalker

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +0/-0
Re: MultiString Plugin
« Reply #27 on: March 02, 2015, 08:07:43 pm »
Quote
Or perhaps I wrote the string.format call wrong.

You provided string.format(...) with a string but where's the format? See http://www.lua.org/manual/5.1/manual.html#pdf-string.format


Woops, I didn't think about what string.format really is before putting it into code.  For my situation, I wouldn't need string.format.

Quote
You are setting a value into lul_device, aren't you?

Yeah I believe so.  In devices in UI5, Multistring shows V1 with a value of testing + 123.


Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +477/-10
Re: MultiString Plugin
« Reply #28 on: March 02, 2015, 08:21:16 pm »
Quote
Woops, I didn't think about what string.format really is before putting it into code.  For my situation, I wouldn't need string.format.

Probably not. luup.variable_get(...) returns a string anyway. You really only need string.format(...) if you want to convert numbers to a string with leading zeros, decimal places, etc.

Quote
Yeah I believe so.  In devices in UI5, Multistring shows V1 with a value of testing + 123.

I am gently trying to make the point that lul_device does not have its value magically provided unless your code is running in a plugin. In scene Lua code, you need to have set this variable to the device ID of your MultiString otherwise the luup.variable_get(...) will return nil which, I think, will get your Sonos to speak of monkeys.


Offline jjwalker

  • Jr. Member
  • **
  • Posts: 91
  • Karma: +0/-0
Re: MultiString Plugin
« Reply #29 on: March 02, 2015, 09:01:40 pm »
Quote
I am gently trying to make the point that lul_device does not have its value magically provided unless your code is running in a plugin. In scene Lua code, you need to have set this variable to the device ID of your MultiString otherwise the luup.variable_get(...) will return nil which, I think, will get your Sonos to speak of monkeys.

Ok I'm a bit dense with lua code.  Bare with me while I try to understand it.  So in scene Lua code, I can't get a variable from Multistring Variable 1 if it's not set within the code?  I see in the Multistring device that V1 has a value of "testing+123", which was directly set by AutoVera.   Again please be patient with me, this is all very new to me.   In my case, how can I get the variable?  Have AutoVera set the variable in another device and then in lua code, set the variable to the device ID of Multistring?