Aller au contenu

Capteur Http Eedomus -> HC3


Messages recommandés

Posté(e)

Super, merci beaucoup!!

Si je peux me permettre (je ne veux pas abuser!), tu aurais une idée sur ce qui ne va pas là-dedans:

 

local requestBody = {
        action = "create",
        params = {
            --type = "local",
            data = 'lIHUqzUSmWfiC9n',
            description = description
        }
}

self.http = net.HTTPClient({timeout=3000})

self.http:request("http://192.168.0.11/api/eedomushue/groups/0/action", {
        options = {
            data = json.encode(requestBody),
            method = "PUT",
        },
})

 

Posté(e)

 

[{"error":{"type":6,"address":"/groups/0/action/action","description":"parameter, action, not available"}},{"error":{"type":6,"address":"/groups/0/action/params","description":"parameter, params, not available"}}]

 

Posté(e)

j'ai déjà testé en remplacant "data" par "scene" et j'obtenais cette erreur :

[QUICKAPP275]: [{"error":{"type":6,"address":"/groups/0/params","description":"parameter, params, not available"}},{"error":{"type":6,"address":"/groups/0/action","description":"parameter, action, not available"}}]

 

Posté(e)

ouais, bon j'ai fait pas mal de test mais je n'arrive pas à grand chose. Je vais essayer de trouver. En tout cas merci de ton aide!

Posté(e)

C'est pas grave, merci déjà pour tout ton aide.

Apparemment c'est le format de ma requête qui ne va pas, je vais essayer de trouver pourquoi:

[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: requestbody = {"scene":"lIHUqzUSmWfiC9n","method":"PUT"}
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: 200
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: {"name":"Lightset 0","lights":["1","13","15","19","20","21","22","25","26","27","28","29","30","31","32","33","34","35","36","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62"],"sensors":["1","7","8","9","10","13","14","15","16","17","18","19","30","31","32","33","34","35"],"type":"LightGroup","state":{"all_on":false,"any_on":true},"presence":{"state":{"presence":false,"presence_all":false,"lastupdated":"2020-12-26T20:14:16"}},"lightlevel":{"state":{"dark":true,"dark_all":true,"daylight":false,"daylight_any":false,"lightlevel":0,"lightlevel_min":0,"lightlevel_max":0,"lastupdated":"2020-12-26T20:19:16"}},"recycle":false,"action":{"on":false,"bri":127,"hue":54718,"sat":150,"effect":"none","xy":[0.3775,0.2460],"ct":366,"alert":"none","colormode":"ct"}}
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: response status: 200
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: headers: application/json
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: any_on = false
[26.12.2020] [21:26:11] [DEBUG] [QUICKAPP275]: all_on = false

 

Posté(e)

j'avais oublié un /action derrière la requête, je dois zapper quelque chose car quand je lance (avec l'outil développeur Hue) ce genre de commande ça fonctionne :

image.thumb.png.8643b1c2fc581312ff2c21203f245fa3.png

Mon code est le suivant :

local requestBody = {
        --action = "create",
        --params = {
        --    type = "local",
            scene = "lIHUqzUSmWfiC9n",
            method = "PUT",
         --   description = description
    --    }
}
self:debug("requestbody =", json.encode(requestBody))
self.http = net.HTTPClient({timeout=3000})

self.http:request("http://192.168.0.11/api/eedomushue/groups/0/action", {
        options = {
            data = json.encode("requestBody"),
            
        },
        success = function(response) 
            self:debug(response.status)
            self:debug(response.data)
        end,
        error = function(message)
            self:debug("error:", message)
        end
})

et mon debug :

onAction: {"deviceId":275,"actionName":"turnOn","args":[275,"turnOn"]}
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: requestbody = {"method":"PUT","scene":"lIHUqzUSmWfiC9n"}
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: 200
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: [{"error":{"type":2,"address":"/groups/0/action","description":"body contains invalid json"}}]
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: response status: 200
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: headers: application/json
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: any_on = true
[26.12.2020] [21:42:49] [DEBUG] [QUICKAPP275]: all_on = false

J'ai l'impression de ne plus être très loin!!

Posté(e)

Il fallait juste que que mette le method="put" dans les options de la requête, et non dans les paramètres.. Level Up! Merci infiniment de m'avoir aidé!! Trop content!!

Un coup de nettoyage, pour ceux que ça intéresse :

local requestBody = {
        --action = "create",
        --params = {
        --    type = "local",
            scene = "lIHUqzUSmWfiC9n",
            --method = "PUT",
         --   description = description
    --    }
}
self:debug("requestbody =", json.encode(requestBody))
self.http = net.HTTPClient({timeout=3000})

self.http:request("http://192.168.0.11/api/eedomushue/groups/0/action", {
        options = {
            data = json.encode(requestBody),
            method = "PUT"
        },
        success = function(response) 
            self:debug(response.status)
            self:debug(response.data)
        end,
        error = function(message)
            self:debug("error:", message)
        end
})
onAction: {"deviceId":275,"actionName":"turnOn","args":[275,"turnOn"]}
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: requestbody = {"scene":"lIHUqzUSmWfiC9n"}
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: 200
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: [{"success":{"/groups/0/action/scene":"lIHUqzUSmWfiC9n"}}]
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: response status: 200
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: headers: application/json
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: any_on = true
[26.12.2020] [21:46:46] [DEBUG] [QUICKAPP275]: all_on = false

C'est à ce moment qu'on doit faire un petit tuto?!?

  • 2 semaines après...
Posté(e)

Mais je l'ai vu avant toi ;-)

 

en tout cas merci de ton aide, je n'y serai jamais arrivé sans toi!

PS1 : désolé pour la réponse tardive!

PS2 : Meilleurs voeux pour cette nouvelle année!

×
×
  • Créer...