iPhone Push Notification from Vera

This is not for me, however I thought someone out there with a little experience in python, or other programming languages, or the devs should and could include this in to the Vera frame work. Let me begin:

Prowl is a push notification service for the iPhone, it uses a simple API to send instant (push) notifications to a users iPhone through their servers. Now most people are using it to send growl notifications from a Mac or Windows pc right now, however other users are using the API they provide to push other events, such as webserver down reports, and new email notifications. The possibilities are endless.

So here is what I envision Vera to be used with.

The end user would need to generate a API key from the prowl website (http://prowl.weks.net) and enter this in a setup screen. they would need to download and install the prowl app from the app store and link it to their account on http://prowl.weks.net.

In the vera settings you could create a “Push to iPhone” check box next to events, so when say a motion sensor went off, it would push this notice to the Prowl server, and of course send the event to the persons iphone. The user would receive a notice like “Living room motion detected” or similar.

The API seems to be easy to implement, Prowl - API, and there are great examples of the code in the forums - Prowl - cocoaforge.

Its got me thinking of some cool uses for sure, and would love to see someone hack this in to Vera. Anyhow, thought I would share.

Cheers

Scott

It would be pretty easy to implement this as a Luup plugin.

Would rather it send to Growl instead. Growl would then fwd to Prowl/iPhone. I’m sure that’s not too difficult to do either.

It can be done quite easily now, see this thread:
http://forum.micasaverde.com/index.php?topic=4508.0

Would be nice though to have this included as part of the normal notification system!

It can be done quite easily now, see this thread:
http://forum.micasaverde.com/index.php?topic=4508.0

Would be nice though to have this included as part of the normal notification system![/quote]

I ended up creating this myself. The other thread skipped Growl and communicated directly with Prowl.

http://growlwebbridge.codeplex.com/

I would like to use this too, but how do i use it? Sorry you have a “for dummies” version? Haha

Also, I am on a Mac. It would be nice to have growl BOTH display on screen and to prowl when screen saver is away (for my work laptop)

I use GrowlForWindows so I wrote this to work on windows w/ IIS. Not sure what would be comparable on a Mac. I think you need someone who knows XCode. Or perhaps it could be done in python I guess. Or run Windows in a VM on your Mac? :slight_smile:

The other possibility, is if someone who knows LUUP (or is it Lua??) real well, they might be able to use it to get the Vera to speak the growl language (GNTP) directly.

I whipped this up tonight. I will clean it up later and make documentation, but it “works”. Set the receiving Mac to Listen For Incoming Notifications, Allow Remote Application Registration, and no password.

[code]-- growlnotify.lua (place in /usr/lib/lua)

socket = require(‘socket’);

local GrowlNotify = {}
local Notification = {}

GrowlNotify.__index = GrowlNotify
Notification.__index = Notification

– Transmit a UDP packet to a given host and port.
local function sendMessage(message, host, port)
local s = socket.udp()
s:sendto(message, host, port)
s:close()
end

– Consrtuct a Growl Notifier object.
function GrowlNotify.new(app, host, port)
local o = {}
setmetatable(o, GrowlNotify)
o.app = app
o.host = host
o.port = port or 9887
return o
end

– Construct n Notifications for this Notifier, and send the registration
– packet to the registered server.
function GrowlNotify:register(…)
local result = {}
for i,v in ipairs({…}) do
local n = {}
setmetatable(n, Notification)
n.app = self.app
n.host = self.host
n.port = self.port
n.notification = v
table.insert(result, n)
end
local message = “”
message = message … “\001” – GROWL_PROTOCOL_VERSION
message = message … “\004” – GROWL_TYPE_REGISTRATION_NOAUTH
local l = self.app:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – app name length
message = message … string.char(#result) – nall
message = message … string.char(#result) – ndef
message = message … self.app
for i,n in ipairs(result) do
l = n.notification:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – notification length
message = message … n.notification
end
for i,n in ipairs(result) do
message = message … string.char(i-1) – default
end
sendMessage(message, self.host, self.port)
return unpack(result)
end

– Send a notification packet.
function Notification:notify(title, description, priority, sticky)
local message = “”
message = message … “\001” – GROWL_PROTOCOL_VERSION
message = message … “\005” – GROWL_TYPE_NOTIFICATION_NOAUTH
message = message … “\000”
local priorityByte = 0
if (priority ~= nil) then
local priorityBitfield = { 96, 112, 0, 16, 32 }
priorityByte = priorityBitfield[priority + 3]
end
if (sticky) then
priorityByte = priorityByte + 128
end
message = message … string.char(priorityByte)
l = self.notification:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – notification length
l = title:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – title length
l = description:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – description length
l = self.app:len()
message = message … string.char(math.floor(l/256)) … string.char( l % 256 ) – app name length
message = message … self.notification
message = message … title
message = message … description
message = message … self.app
sendMessage(message, self.host, self.port)
end

return[/code]

Use like this:

gn = require("growlnotify") instance = gn.new("VeraGrowlNotifier", '192.168.77.88') -- Your Mac here. notifier, notifier2 = instance:register("SampleNotification", "SampleNotification2") -- Example has two notifications, but any number >= 1 allowed. notifier:notify("Sample Title", "Sample Description", 2, true) -- Send notification.

Wow, I have no idea how to read it but I’m excited to try it put once you finish the documentation soon can figure out how to set it up. Nice work.

I whipped this up tonight. I will clean it up later and make documentation, but it “works”. Set the receiving Mac to Listen For Incoming Notifications, Allow Remote Application Registration, and no password.[/quote]

Very nice! I’ll give a try tonight. Thanks!!

Any documentation on this? Would love to try it out, but am LUUP illiterate.

You’ll need to know your computer’s IP address.

Setup for Growl server on your computer:
(X) Listen for incoming notifications
(X) Allow remote application registration
Server password: empty
Note the UDP port number (default is 9887)

Allow the UDP port through your computer’s firewall, if you use one.

Transfer the growlnotify.lua file from above onto your Vera, into the /usr/lib/lua directory. Discussion about transferring files to Vera

Then make a scene in UI4 that is triggered by whatever event you are interested in reporting. In the Luup tab, paste code:

gn = require("growlnotify") instance = gn.new("Vera", '192.168.77.88', 9887) -- Your computer and port here. notifier = instance:register("Event Occurred") notifier:notify("My Device", "Did Something")

Save. That’s all.

You’ll need to know your computer’s IP address.

Setup for Growl server on your computer:
(X) Listen for incoming notifications
(X) Allow remote application registration
Server password: empty
Note the UDP port number (default is 9887)

Allow the UDP port through your computer’s firewall, if you use one.

Transfer the growlnotify.lua file from above onto your Vera, into the /usr/lib/lua directory. Discussion about transferring files to Vera

Then make a scene in UI4 that is triggered by whatever event you are interested in reporting. In the Luup tab, paste code:

gn = require("growlnotify") instance = gn.new("Vera", '192.168.77.88', 9887) -- Your computer and port here. notifier = instance:register("Event Occurred") notifier:notify("My Device", "Did Something")

Save. That’s all.[/quote]
I am almost embarrassed to ask for more directions but here goes:
I am using Growl for windows, so how do I setup the growl server? I do not see anywhere the 2 checked options you listed above.

Setup for Growl server on your computer: (X) Listen for incoming notifications (X) Allow remote application registration Server password: empty

A bit more details for us less tech-savvy folks would be appreciated. BTW, I am currently using growl for windows along with Prowl on the iPhone for notifications that are kind of hit or miss!! Thanks…

I don’t use Windows, so I assumed it was the same as on Mac OS. Clearly not. I did some Googling: Growl-for-Windows uses a different notification protocol than Growl-for-Mac. So my code is useless for Windows users. Sorry, I didn’t know.

I don’t use Windows, so I assumed it was the same as on Mac OS. Clearly not. I did some Googling: Growl-for-Windows uses a different notification protocol than Growl-for-Mac. So my code is useless for Windows users. Sorry, I didn’t know.[/quote]
No problem mate. I am sure this code will help some MAC users.

Futzle, will this still works for UI5?, i installed the prowl plugin, but i would like to have the growl notifications on my mac.

It’ll work fine on UI5, but the Growl protocol on Mac OS X has changed too, so you need to be using the old free Growl, not the new one from the App Store.

Updating the code for the new Growl protocol is non-trivial, because you need cryptographic hashing.

Futzle, thanks for the info. Will you able to provide a more detailed instruction on how to do this, ive been spending some time with no luck.

Transfer the growlnotify.lua file from above onto your Vera, into the /usr/lib/lua directory

Im stuck here, a little help will be appreciated.

Thanks

A little detail will be helpful. Did you follow the link and learn about WinSCP?