HNA Posted December 29, 2013 Share Posted December 29, 2013 Hello everybody, I'm just trying to program a C4 driver which can send push notifications to your/my iphone or ipad on certain events. That would be way better than an email as you see the messages instantaneous! For example: "Your rack room is overheating".The push service "http://pnotify.com" offers is pretty nice service. Right now, I'm trying to program an independent Lua script for the HTTP POST request to the pnotify server. But even this first"part" of the C4 driver doesn't behave like I want it to. The only way to do this - I think - is, to use the LuaSocket module by starting the script: require "socket.http" My first question is: Are there any Lua modules installed on my HomeController like "socket"? Is there another way to send HTTP POST requests? Normal HTTP GET requests also work, i.e. for IP cameras. I don't get the script to run and send the request. For more information about the module visit: http://w3.impa.br/~diego/software/luasocket/http.html#request There are two possibilities to use the module: a simple and a generic interface. Both don't work for me. Simple interface: local http require'socket.http'http.request("http://pnotify.com/submit/CODE","title=test&detail=helllloooo") Generic interface: require 'socket.http' local request_body = [[title=test&detail=hello]] local response_body = { } local res, code, response_headers = socket.http.request{ url = "http://pnotify.com/submit/CODE"; method = "POST"; headers = { ["Content-Type"] = "application/x-www-form-urlencoded"; ["Content-Length"] = #request_body; }; source = ltn12.source.string(request_body); sink = ltn12.sink.table(response_body);} My second question is: Where do I put the parameters "title" and "detail"? I've also tried: http://pnotify.com/submit/CODE?title=test&detail=helllloooo My programming skills aren't the best and I don't know much about Lua or HTTP POST requests. I just hope that someone out there is able to help me. In my opinion this would be helpful for lots of people. Thanks in advance and a happy new year to all of you!! FS Link to comment Share on other sites More sharing options...
ILoveC4 Posted December 29, 2013 Share Posted December 29, 2013 Um... There are already several drivers that do exactly that. One of them even uses Push Notify! Unless you want to reinvent it, try one of those. They work great and the work has already been done. Sent from my Droid MAXX via Tapatalk. Link to comment Share on other sites More sharing options...
RyanE Posted December 29, 2013 Share Posted December 29, 2013 In a DriverWorks driver, with a recent enough version, there are 2 calls: C4:urlGet and C4:urlPost that will send URL Get and Post messages. RyanE Link to comment Share on other sites More sharing options...
HNA Posted January 5, 2014 Author Share Posted January 5, 2014 This forum is incredible! Thank you very much ! Link to comment Share on other sites More sharing options...
wappinghigh Posted January 7, 2014 Share Posted January 7, 2014 It's going to be very hard to better "Push Notify". This is the no1 best driver ever written IMHO. Incredibly robust. Never fails. Simple. Cheap. Great value for money. Does what it promises to deliver.... Has Seth ever got an award for this? Link to comment Share on other sites More sharing options...
alanchow Posted January 9, 2014 Share Posted January 9, 2014 Push Notify is Seth's which uses prowl and Notify My Android. Phone Notify is mine which uses phone notify (http://pnotify.com) Both pretty much do the same thing so use whatever one you want. Making it was pretty simple as well so if you want to redevelop then it makes a good first driver to sink your teeth into. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.