Bonjour,
Je suis débutant en Lua et Fibaro (HC3).
J'ai trouvé le code ci-dessous dans ce forum et l'ai inséré dans un Quickapp (binary switch) avec mon user id et mon token.
Le code est bien envoyé. Je reçois ce message sur mon smartphone :
"Par Fibaro le 18/12/2022 à 16:07 {"priority"=>"0"}"
Mais maintenant, je ne sais pas quelle est la prochaine étape.
Comment puis-je maintenant envoyer des notifications push ? (par exemple via une scène bloc)
Merci quand même.
Michel
-----------------
function QuickApp:btn1()
self:debug("binary switch turned on")
self:updateProperty("value", true)
local settings = {
-- Application's API token
token = "xxxx",
-- User key
user = "xxxxx",
--Device (optional)
device = FIB,
--Title (optional)
title = Push_Over_ON,
-- Priority
priority = "0",
-- Pushover sound (default)
sound = "pushover"
}
local http = net.HTTPClient({ timeout = 5000 })
local payload = json.encode(settings)
http:request("https://api.pushover.net/1/messages.json", {
options = {
headers = {
["content-type"] = "application/json;charset=UTF-8"
},
method = "POST",
data = payload
},
success = function(status)
if (tonumber(status.status) == 200) then
print("success")
end
end,
error = function(error)
print(error)
end
})
end
function QuickApp:btn2()
self:debug("binary switch turned off")
self:updateProperty("value", false)
end
function QuickApp:onInit()
self:debug("onInit")
end
-------------------