Author Topic: Passing a url to a VeraAlerts PushOver profile (Lua scene code in openLuup)  (Read 291 times)

Offline ChrisTheC

  • Full Member
  • ***
  • Posts: 139
  • Karma: +3/-1
Hello group.

I just factory reset my Vera 3 (UI5) and re-installed Vera Alerts 6.43

I'm also running openLuup on a RPi 3 and I'm able to send actions to the my Vera's VeraAlerts service pretty easily.
Trying to learn some simple Lua scene code for triggering VeraAlerts messages for various tasks. I'm having a syntax problem with passing a variable to the luup.call_action. I've been reading the "Scene Scripting" folder (since this is a new area) but I thought I would ask this question here first.

I'm trying to pass the iPhone Locator variable "MapUrl" to a PushOver API variable {url=xxx} but can't figure the right way.

In vb or vba it would be something like  theURL = "{url=" & strURL & "}" but . . . sigh

On my scene's "Lua scene code:" I have the below:

Code: [Select]
local strURL = luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1","MapUrl",27)
local PushOverSound = "{sound=bike}" --Proper syntax for sending PushOver Variable (Works properly)
--local theURL = "{strURL}" --Can't find proper syntax
--local theURL = "({strURL})" --Can't find proper syntax
--local theURL = "strURL" --Can't find proper syntax

local theURL = "{url=http://MyWellFormedURL.com}" --PROPER SYNTAX FOR SENDING PUSHOVER URL LINK
luup.call_action("urn:richardgreen:serviceId:VeraAlert1","SendAlert",{Message = "Location " ..PushOverSound ..theURL , Recipients="Pushover-ChrisFace"}, 10029)

In the above test, I can't make the luup.call_action include a clickable link in PushOver {url=www.maps.google.com-whatever local strURL returns------}

I can encode clickable url's sending my alert to my android device profile, but not my pushover profile.

Of course, I'm reading more every day, but still pretty blind & this is my first fail.

Would someone care to set me right?

Thanks,
Chris

Offline ChrisTheC

  • Full Member
  • ***
  • Posts: 139
  • Karma: +3/-1
Got It! ding ding ding ding ding

No, not really ding X5 . . . I didn't figure it out, I just kept guessing until it worked.  ???
However, it worked  ;D

It IS (sort of) like using the concentation & symbol from vb

The below code works the way I envisioned

Code: [Select]
local strURL = luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1","MapUrl",27)
local PushOverSound = "{sound=bike}"
local theURL = "{url=" .. strURL .. "}"
luup.call_action("urn:richardgreen:serviceId:VeraAlert1","SendAlert",{Message = "Location " ..PushOverSound ..theURL , Recipients="Pushover-ChrisFace"}, 10029)

Heck, maybe I don't even need that additional local variable "theURL", will experiment further. Double dots on the front, double dots on the back, I've seen examples using them, I can guess their meaning, just haven't found written explanation yet looking around here & on the wiki.

Thanks for reading.
Chris


Offline akbooer

  • Master Member
  • *******
  • Posts: 6129
  • Karma: +275/-69
  • "Less is more"
Worth reading this...

Programming in Lua

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

Offline ChrisTheC

  • Full Member
  • ***
  • Posts: 139
  • Karma: +3/-1
Worth reading this...

Programming in Lua

...for the basic syntax of Lua.

I finished reading @RexBeckett's sticky thread last night "Conditional Scene Execution: Some Examples", and saw several references for the link you just posted.

I put it on my todo list, but now it's on my prioritized list for right now!

Again, thanks for the push.

Chris

Offline akbooer

  • Master Member
  • *******
  • Posts: 6129
  • Karma: +275/-69
  • "Less is more"
That's great.  Do be aware, though, that Vera uses Lua v5.1, which is a bit out of date now, but the official reference manual online is available here:

https://www.lua.org/manual/5.1/



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