Author Topic: Sample luup code for sending an alert?  (Read 4678 times)

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Sample luup code for sending an alert?
« on: February 02, 2012, 07:21:36 pm »
Does anyone have sample code for how to send an alert from inside luup? I have a luup scripted scene and I need to add an alert to the middle of it, so I can't use the standard command window.

Offline JOD

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Sample luup code for sending an alert?
« Reply #1 on: February 02, 2012, 11:26:05 pm »
Have you looked at Ap15e's SND plugin?

Once setup, you would add this part to your code.
Code: [Select]
luup.call_action( "urn:upnp-ap15e-com:serviceId:SND1", "SendMail", { subject = 'Subject message', body = 'Body message' }, SND device # )
JOD.
I'm sorry, my responses are limited. You must ask the right questions.

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: Sample luup code for sending an alert?
« Reply #2 on: February 06, 2012, 03:14:00 pm »
I am specifically looking for the code to send a VeraAlert message. SND uses email which is slower...and gets lost in my Inbox.

I am thinking it would be something like this (but this isn't working for me):
luup.call_action("urn:micasaverde-com:serviceId:HaDevice1", "SendAlert", { lul_settings.alertMessage = "someone unlocked the door" , lul_settings.recipient = "<my unique VeraAlert PIN>" } ,0)

Offline LG

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +2/-0
Re: Sample luup code for sending an alert?
« Reply #3 on: February 06, 2012, 04:23:59 pm »
ChrisAZ,

You can send an alert using this code :


local http = require("socket.http")
http.request("http://vera-alert.appspot.com/stat?msg=YourMessage&recipient=YourVeralertCode")


LG

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10090
  • Karma: +762/-142
Re: Sample luup code for sending an alert?
« Reply #4 on: February 06, 2012, 05:20:20 pm »
I made some improvements on the Android side which have been incorporated.
I have some ideas/work in progress to improve the Vera Server side as well.
These include:
  • Ability to specify multiple target pins (i.e. Android Devices)
  • Ability to specify a default target(s) on the Vera Device. Then Notifiers only need to specify the message and the Vera Device
  • I will keep the luup programmig in mind. I hate to see Server address in lots of places.
  • Option in Device Notifications to use VerAlert
I was going to wait until the UI5 stuff is stable on the Vera2 platform before proceeding. I mentioned to Richard he should change the algorythm for pin ... so that on the same phone if you re-install you get the same pin. You also do not like to have that ID spread out in lots of places on your Vera server.
« Last Edit: February 08, 2012, 09:43:48 am by RichardTSchaefer »

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: Sample luup code for sending an alert?
« Reply #5 on: February 06, 2012, 09:31:07 pm »
LG - thanks for the code. That will fill my needs for now.

Richard - glad to hear you're working on improvements. I'm in a unique situtation where I get a new phone every few months, so having to reprogram my new PIN into all the different scripts is a pain. Not sure if there would be a simple way to keep the same PIN across different phones, but just a centralized PIN in the Vera Device would save me a lot of grunt work. Multiple PINs would also be great.

Glad to see that development has stoppped completely. VeraAlert is a great tool.