Push Notifications Example

Here is an example of sending a push notification from a scene (or anywhere else using luup):

-- enter your automator.app unique device ids here.  if multiple devices  separate by a comma
local devices        = '96........2e'

-- the message to send
local message        = 'Front Door Opened'

-- auto increment the icon's badge number
local badge = "+1"

-- the sound to use.  currently may be an empty string for none or 'default'
local sound = 'default'

-- timeout to use when contacting the automator push web service in seconds
local timeout         = 15

-- utility method to make text URL friendly
function url_encode(str)
  if (str) then
    str = string.gsub (str, "\n", "\r\n")
    str = string.gsub (str, "([^%w ])",
        function (c) return string.format ("%%%02X", string.byte(c)) end)
    str = string.gsub (str, " ", "+")
  end
  return str   
end

-- make the actual call
 luup.inet.wget( 'http://push.automatorapp.com/notify.php?devices='..devices
 	..'&badge='..url_encode(badge)..'&message='..url_encode(message)  
 	.. '&sound=' .. sound, timeout)

More information available at http://push.automatorapp.com/

Is web server logging disabled on push.automatorapp.com? Alternatively, when do you expect to have the POST based mechanism ready?

Using GET like this is a bit dodgy given typical web server logging levels (which you’d want for diagnostics, determining hacks on your infrastructure, etc)

Also have you thought about packaging this into more of a plugin, using some sort of generic message API so it can be declaratively scripted?

[quote=“guessed, post:2, topic:168683”]Is web server logging disabled on push.automatorapp.com? Alternatively, when do you expect to have the POST based mechanism ready?

Using GET like this is a bit dodgy given typical web server logging levels (which you’d want for diagnostics, determining hacks on your infrastructure, etc)

Also have you thought about packaging this into more of a plugin, using some sort of generic message API so it can be declaratively scripted?[/quote]

Web server logging is not disabled, and I completely understand your point. I’m working on the POST interface and will have it up as soon as possible. I’m not very skilled at PHP or lua/luup at this point.

I have talked to the creator of Vera-alert about adding support in that device and he is all for it, I just need to do it. The priority is getting the push.automatorapp.com web service complete (e.g. the POST mechanism) then figuring out the vera-alert integration and/or a automator.app mios device/plugin.

If I do the later I can make things much easier for the end user, for example not having to input your device ids. I’m very welcome to ideas/suggestions from the plugin development crowd.

I added information about using HTTP POST to the documentation on http://push.automatorapp.com/ along with a lua example.

The part that is really not complete is the HTTP POST with JSON data interface.

I just purchased this app this weekend. Great App. Keep up the good work.