-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.picolabs.prowl.krl
More file actions
77 lines (64 loc) · 1.88 KB
/
io.picolabs.prowl.krl
File metadata and controls
77 lines (64 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
ruleset io.picolabs.prowl {
meta {
name "Prowl Module"
description <<
Provide a means of sending prowl notifications to an iPhone
>>
author "Phil Windley"
configure using apikey = "nokey"
providerkey = ""
application = "Pico Labs"
provides notify
shares show_configuration
}
global {
show_configuration = function() {
return {"apikey": ent:apikey,
"providerkey": ent:providerkey,
"application": ent:application
}
}
notify = defaction(title, description, priority = 0, url="") {
http:post("https://api.prowlapp.com/publicapi/add",
form = {
"apikey": ent:apikey,
"providerkey": ent:providerkey,
"application": ent:application,
"priority": priority < -2 || priority > 2 => 0 | priority,
"event": title.klog("Title: "),
"description" : description,
"url": url
}) setting (resp)
return resp
}
}
// to use create a channel that allows the prowl domain; delete channel when done testing and configuring for security
rule save_config {
select when prowl configuration
pre {
apikey = event:attr("apikey")
providerkey = event:attr("providerkey")
application = event:attr("application").defaultsTo("Pico Labs")
}
if not (apikey.isnull()
|| providerkey.isnull()
|| application.isnull()
) then noop()
fired {
log info "Configuring Prowl ";
ent:providerkey := providerkey;
ent:apikey := apikey;
ent:application := application;
}
}
rule test_config {
select when prowl test
pre {
msg = event:attr("msg")
}
notify("Test notification", <<Test message: #{msg}>>) setting(resp)
always {
log info <<Test message sent: #{msg}; #{resp.klog("Response")} >>
}
}
}