Hallo,
hier ist eine Pushover Szene:
- Variable pushStatus anlegen.
Mit folgendem Code kannst Du die Nachrichten triggern. (In deine Szenen einbauen)
fibaro:setGlobal(“pushStatus”, “HEADER,MESSAGE,PRIORITY,SOUND”)
Bsp. fibaro:setGlobal(“pushStatus”, “Fibaro,Alarm im Wohnzimmer,1,siren”)
Bsp. fibaro:setGlobal(“pushStatus”, “Fibaro,Tür offen Schlafzimmer,0,cosmic”)
Hier ist die Szene, app token und user bekommst du von pushbullet wenn du dich registrierst.
Die App ist einmalig pro Betriebssystem zu kaufen. (Wenige Euros)
--[[
%% properties
%% globals
pushStatus
--]]
if (tonumber(fibaro:getGlobalValue("pushStatus")) == 0) then
fibaro:abort();
end
local selfhttp = net.HTTPClient({timeout=2000})
local parameters = fibaro:getGlobalValue("pushStatus")
local token = "XXX" -- your application token
local user = "XXX" -- your user key
-- -------------------------------------------------------
-- no edit below this point
-- -------------------------------------------------------
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
function explode(str)
local pos,arr = 0,{}
for match in string.gmatch(str, '[^,]+') do
table.insert(arr, match)
end
return arr
end
--
if string.len(parameters) > 0 then
--fibaro:setGlobal("pushover","")
parameters = explode(parameters)
local title = tostring(parameters[1]) or ""
local message = url_encode(parameters[2])
local device = ""
local priority = tostring(parameters[3])
local sound = tostring(parameters[4]) -- see other sounds bellow
local requestBody = "token=" .. token .. "&user=" .. user .. "&title=" .. title .. "&device=" .. device .. "&priority=" .. priority .. "&sound=" .. sound .."&message=" .. message
--'token=' ..token ..'&user=' ..user ..'&title=FIBARO' ..'&message='..message
--print(requestBody);
selfhttp:request('https://api.pushover.net/1/messages.json', {
options={
headers = selfhttp.controlHeaders,
data = requestBody,
method = 'POST',
timeout = 5000
},
success = function(status)
local result = json.decode(status.data);
--print("status");
if result.status == 1 then
print("successful");
--print("Request: " ..result.request);
else
print ("failed");
print(status.data);
end
end,
error = function(error)
print "ERROR"
print(error)
end
})
fibaro:setGlobal("pushStatus", "0")
end
--pushover - Pushover (default)
--bike - Bike
--bugle - Bugle
--cashregister - Cash Register
--classical - Classical
--cosmic - Cosmic
--falling - Falling
--gamelan - Gamelan
--incoming - Incoming
--intermission - Intermission
--magic - Magic
--mechanical - Mechanical
--pianobar - Piano Bar
--siren - Siren
--spacealarm - Space Alarm
--tugboat - Tug Boat
--alien - Alien Alarm (long)
--climb - Climb (long)
--persistent - Persistent (long)
--echo - Pushover Echo (long)
--updown - Up Down (long)
--none - None (silent)