Aller au contenu

Messages recommandés

Posté(e) (modifié)

Je me doute bien qu'il y a déjà des infos pour savoir comment faire, c'est pas faute d'avoir essayer de comprendre

Mais Désolé je n'arrive pas toujours

Pour moi c'est une nouveau chapitre que j'aborde avec la HC3

J'y arrive beaucoup mieux quant j'ai un exemple concret sous les yeux

Après cela me permet de mieux assimiler et de pouvoir adapter en fonction de mes besoins

J'ai déjà regarder tous le week-end comment on fait mais désolé je n'ai pas réussi

 

pour l'exemple ci dessus ok je comprends qu'il ne faut mettre que l'adresse IP et son port dans http:request(), mais du coup que faire du reste?

Ou le placer?

GET /googlehome? annoucement=someone%20at%20the%20door HTTP/1.1

Merci

Modifié par flacon030
Posté(e)

Juste l'URL, comme dans ton navigateur.

Tout simple.

Exemple :

"http://mon.adresse.com/googlehome?annoucement=someone%20at%20the%20door"

 

Pour ton QuickApp, il te suffit de partir d'un QA exemple proposé par Fibaro. Choisi le type qui correspond à ton besoin.

En complément ne pas oublier la doc officielle : https://manuals.fibaro.com/home-center-3-quick-apps/

Il y a un paragraphe sur la création d'un bouton.

  • 3 mois après...
Posté(e) (modifié)

salut à tous

 

J'ai une erreur 400 de mon code ci-dessous, après un bonheur de recherche je ne trouve toujours pas le problème.

Merci d'avance pour votre aide

 

[22.03.2022] [13:25:39] [DEBUG] [SCENE253]: Erreur : status=400

 

https://voicemonkey.io/start

 


local var1 = "Hello%20monkey"

local http = net.HTTPClient()
http:request("https://api.voicemonkey.io/trigger?access_token=xxxxxxxxxxxde15&secret_token=xxxxxxxxxxxxx&monkey=fibaro&announcement="..var1, {
	success = function(response)
		if response.status == 200 then
			print('OK, réponse : '.. response.data)
		else
			print("Erreur : status=" .. tostring(response.status))
		end
	end,
	error = function(err)
		print("Erreur : " .. err)
	end,
	options = {
		method = 'GET'
	}
})

 

 

 

 

 

 

Modifié par 971jmd
Posté(e)

Le code http 400 signifie "bad request".

Jamais facile à débugger... mais tu n'aurais pas un caractère caché, ou autre problème de syntaxe dans l'URL que tu utilises pour ta requête ?

 

Car du point de vue de ta box domotique, ta requête a bien été effectuée, puis c'est la fonction success() qui a été appelée, donc c'est bien le serveur Web qui a reçu puis rejeté ta requête.

  • Lazer a épinglé ce sujet
  • 1 an après...
Posté(e) (modifié)

Hello,

 

Bon, j'ai un truc bizarre.

Je n'ai pas le même comportement avec net.HTTPClient() dans une scène ou dans un QApp.

 

Cela marche bien dans une scène. réponse 302 : login ok donc redirection et je récupère le cookie et je fais la suite, blablabla.

Sur ma Qapp, si je vire pas le CheckCertificate alors je n'ai plus de réponse. Il ne se passe rien.

Si je vire le CheckCertificate, alors j'ai une réponse erreur 404. La même erreur que quand je mets des faux login/password.

 

Dans la scène, ces même logins/ password sont OK.

 

Y a-t-il un comportement différent attendu entre les Scènes et les App ???

 

Merci :)

 

Voici mon code QA qui marche pas (erreur 404) : 

function QuickApp:onInit()
    self:debug("onInit")
    -- récupère le token Easee
  
	-- variables locales
	local Debugging = 01
 	local EaseeURLlogin = "https://api.easee.com/api/accounts/login"
		EaseeURLlogin = "https://www.rika-firenet.com/web/login/"
		--EaseeURLlogin = "https://free.fr"
	local http = net.HTTPClient()
	local user = "toto"
	local password = "titi"
	local HTTPdata = '{"email": "'.. user .. '", "password": "' .. password .. '"}'

	if Debugging > 0 then
		fibaro.debug(DebugTag,"EaseeURLlogin : "..EaseeURLlogin)
		fibaro.debug(DebugTag,"HTTPdata : "..HTTPdata)
	end

	http:request(EaseeURLlogin, {
		options = {
			--checkCertificate = false,
			method = 'POST',
			headers = {
				['Accept'] = 'application/json',
				['Content-Type'] = 'application/json',
				},
			data = HTTPdata,
			timeout = 10000
			},

		success = function(response)
			fibaro.debug(DebugTag,'ici')
			fibaro.debug(DebugTag,response.status)
		end,
		
		error = function(err)
			local msg = "Erreur : " .. err
			fibaro.warning(DebugTag,msg)
		end,
		}
	)
end

 

debug Qapp:

[24.01.2025] [13:41:18] [DEBUG] [QUICKAPP345]: onInit
[24.01.2025] [13:41:18] [DEBUG] [TEST]: EaseeURLlogin : https://www.rika-firenet.com/web/login/
[24.01.2025] [13:41:18] [DEBUG] [TEST]: HTTPdata : {"email": "toto", "password": "titi"}
[24.01.2025] [13:41:19] [DEBUG] [TEST]: ici
[24.01.2025] [13:41:19] [DEBUG] [TEST]: 404

 

Voici mon code dans la scène (qui marche bien code 302)

function APIGetInfo(URLBase, user ,password, Stove, parametre, value)

	-- variables locales
	local DebugTag = "SC_RIKA_107_APIGetInfo"	
	local Debugging = 0
	local URLLogin = "/web/login"
	local URLAPI = "/api/client/"..Stove.."/status?nocache="
	local Cookie = "vide"
	local Revision = "vide" -- à virer ??????????

	local URL = URLBase..URLLogin
	local HTTPdata = '{"email": "'.. user .. '", "password": "' .. password .. '"}'

	if Debugging > 0 then
		fibaro.debug(DebugTag,"**************** Login ****************")
		fibaro.debug(DebugTag,"URL = " .. URL)
		fibaro.debug(DebugTag,"HTTPdata : "..HTTPdata)
	end

	http:request(URL, {
		options = {
			method = 'POST',
			headers = {
				['Accept'] = 'application/json',
				['Content-Type'] = 'application/json',
				},
			data = HTTPdata,
			timeout = 10000
			},

		success = function(response)
		
			if Debugging > 0 then
				fibaro.debug(DebugTag,"status : "..response.status)
				fibaro.debug(DebugTag,"response : " ..json.encode(response))
				fibaro.debug(DebugTag,"response.data : " ..json.encode(response.data))
				fibaro.debug(DebugTag,"Cookie : "..response.headers["Set-Cookie"])
			end
			
			if response.status == 302 or response.status == 200 or response.status == 201 then
			
				fibaro.trace(DebugTag,"Login Firenet OK.")
				Cookie = response.headers["Set-Cookie"]
          
          --[... suite du code]

 

debug scène :

[24.01.2025] [13:43:09] [DEBUG] [SC_RIKA_107]: **************** Start ****************
[24.01.2025] [13:43:09] [DEBUG] [SC_RIKA_107_APIGETINFO]: **************** Login ****************
[24.01.2025] [13:43:09] [DEBUG] [SC_RIKA_107_APIGETINFO]: URL = https://www.rika-firenet.com/web/login
[24.01.2025] [13:43:09] [DEBUG] [SC_RIKA_107_APIGETINFO]: HTTPdata : {"email": "XXX", "password": "YYY"}
[24.01.2025] [13:43:10] [DEBUG] [SC_RIKA_107_APIGETINFO]: status : 302
[24.01.2025] [13:43:10] [DEBUG] [SC_RIKA_107_APIGETINFO]: response : {"data":"","headers":{"Strict-Transport-Security":"max-age=15552000; includeSubDomains","........

 

Modifié par stipower
Posté(e)

Il est fort possible que la version des librairies utilisées par Fibaro soit différente entre les Scènes et les QuickApps... car même la version du moteur d'exécution LUA diffère !

Par ailleurs, certaines libraires et fonctions sont carrément présentes/absentes selon si on est dans une Scène ou un QuickApp... voir mon topic dédié à l'exploration :

 

S'il s'agit d'un comportement anormal, bug, ou changement de comportement apporté par une mise à jour récente, le mieux est de remonter le problème directement à Fibaro en passant par le forum officiel.

 

Posté(e)

Rha la loose.

Merci pour ton retour.

J'ai ouvert un case au support.

 

Obligé en attendant de faire tourner une scène toutes  les 10 secondes en allant chercher de variables globales. Ca me rappelle ma HC2 ...:blink:

  • 8 mois après...
Posté(e) (modifié)

Je suis en cour de réalisation d'une télécommande pour un équipement de mon home cinéma

J'ai tous une liste de requête http pour chaque fonction de la télécommande

 

J'ai testé cela dans un QA et cela fonctionne

local http = net.HTTPClient()
http:request("http://192.168.1.111/cgi-bin/do?cmd=ir_code&ir_code=AC534040", {
	success = function(response)
		if response.status == 200 then
			print('OK, réponse : '.. response.data)
		else
			print("Erreur : status=" .. tostring(response.status))
		end
	end,
	error = function(err)
		print("Erreur : " .. err)
	end,
	options = {
		method = 'GET'
	}
}) 

A présent comment associer cette commande a un bouton virtuel?

Merci

 

Voici la liste des commandes en pièce jointe

IP Control for R_volution Amlogic based media players.pdf

Modifié par flacon030
Posté(e)

Dans ton code LUA il faut créer une fonction qui sera appelée par le bouton (configuré dans le champ onReleased), un peu sur ce modèle là :

 

large.Screenshot-HC3-QuickApp-Xiaomi-Rob

 

Pour info, le topic d'où provient cette capture d'écran :

 

 

Posté(e)

Merci pour ce liens

 

J'ai déjà un QA télécommande pour ma TV bravia (voir code ci dessous)

il semble que le code soit presque similaire...

 

Pour chaque bouton, seul la fin du liens change (exemple ci dessous)

http://192.168.1.111/cgi-bin/do?cmd=ir_code&ir_code=AC534040
code=AC534040

est'il possible d'avoir une liste comme ci dessous ?


 

---IRCC code for the bouton

Self. playPause = 'AC534040' ect...

 

De créer chaque bouton comme ci dessous

 

-- Configuration of the buttons
--playPause
function QuickApp:uibutton1_1(event)
    self.args = self.playPause
    self:remoteCode()
end

 

Mais que faut'il modifier dans ce code pour que la requête HTTP puisse fonctionner avec chaque bouton?

Merci

 

local http = net.HTTPClient()
http:request("http://192.168.1.111/cgi-bin/do?cmd=ir_code&ir_code=AC534040", {
	success = function(response)
		if response.status == 200 then
			print('OK, réponse : '.. response.data)
		else
			print("Erreur : status=" .. tostring(response.status))
		end
	end,
	error = function(err)
		print("Erreur : " .. err)
	end,
	options = {
		method = 'GET'
	}
}) 

 

Voici le QA de ma télécommande pour TV bravia

unction QuickApp:onInit()
    self.args = "SMURF" --variable to send to TV, will be updated when a button is pressed

    --IRCC codes for the buttons
    self.source = 'AAAAAQAAAAEAAAAlAw=='
    self.powerOn = 'AAAAAQAAAAEAAAAuAw=='
    self.powerOff = 'AAAAAQAAAAEAAAAvAw=='
    self.powerbutton = 'AAAAAQAAAAEAAAAVAw=='
    self.diAna = 'AAAAAgAAAHcAAAANAw=='
    self.tvRad = 'AAAAAgAAABoAAABXAw=='
    self.sync = 'AAAAAgAAABoAAABYAw=='
    self.exit = 'AAAAAQAAAAEAAABjAw=='
    self.num1 = 'AAAAAQAAAAEAAAAAAw=='
    self.num2 = 'AAAAAQAAAAEAAAABAw=='
    self.num3 = 'AAAAAQAAAAEAAAADAw=='
    self.num4 = 'AAAAAQAAAAEAAAADAw=='
    self.num5 = 'AAAAAQAAAAEAAAAEAw=='
    self.num6 = 'AAAAAQAAAAEAAAAFAw=='
    self.num7 = 'AAAAAQAAAAEAAAAGAw=='
    self.num8 = 'AAAAAQAAAAEAAAAHAw=='
    self.num9 = 'AAAAAQAAAAEAAAAIAw=='
    self.info = 'AAAAAQAAAAEAAAA6Aw=='
    self.zero = 'AAAAAQAAAAEAAAAJAw=='
    self.teletext = 'AAAAAQAAAAEAAAA/Aw=='
    self.googlePlay = 'AAAAAgAAAMQAAABGAw=='
    self.red = 'AAAAAgAAAJcAAAAlAw=='
    self.green = 'AAAAAgAAAJcAAAAmAw=='
    self.yellow = 'AAAAAgAAAJcAAAAnAw=='
    self.blue = 'AAAAAgAAAJcAAAAkAw=='
    self.tv = 'AAAAAQAAAAEAAAAkAw=='
    self.actionMenu = 'AAAAAgAAAJcAAAA2Aw=='
    self.epg = 'AAAAAQAAAAEAAAAOAw=='
    self.arrowUp = 'AAAAAQAAAAEAAAB0Aw=='
    self.arrowLeft = 'AAAAAQAAAAEAAAA0Aw=='
    self.enter = 'AAAAAQAAAAEAAABlAw=='
    self.arrowRight = 'AAAAAQAAAAEAAAAzAw=='
    self.arrowDown = 'AAAAAQAAAAEAAAB1Aw=='
    self.back = 'AAAAAgAAAJcAAAAjAw=='
    self.discover = 'AAAAAgAAABoAAABzAw=='
    self.home = 'AAAAAQAAAAEAAABgAw=='
    self.cycle = 'AAAAAQAAAAEAAAA7Aw=='
    self.chUp = 'AAAAAQAAAAEAAAAQAw=='
    self.mute = 'AAAAAQAAAAEAAAAUAw=='
    self.audio = 'AAAAAQAAAAEAAAAXAw=='
    self.rewind = 'AAAAAgAAAJcAAAAbAw=='
    self.play = 'AAAAAgAAAJcAAAAaAw=='
    self.fastforward = 'AAAAAgAAAJcAAAAcAw=='
    self.subtitle = 'AAAAAgAAAJcAAAAoAw=='
    self.skipBack = 'AAAAAgAAAJcAAAA8Aw=='
    self.pause = 'AAAAAgAAAJcAAAAZAw=='
    self.skipForward = 'AAAAAgAAAJcAAAA9Aw=='
    self.help = 'AAAAAgAAABoAAAB7Aw=='
    self.rec = 'AAAAAgAAAJcAAAAgAw=='
    self.stop = 'AAAAAgAAAJcAAAAYAw=='
    self.title = 'AAAAAgAAABoAAABlAw=='
    self.chDown = 'AAAAAQAAAAEAAAARAw=='
    self.netflix = 'AAAAAgAAABoAAAB8Aw=='
    self.volumeUp = 'AAAAAQAAAAEAAAASAw=='
    self.volumeDown = 'AAAAAQAAAAEAAAATAw=='
    self.pictureOff = 'AAAAAQAAAAEAAAA+Aw=='
    self.hdmi1 = 'AAAAAgAAABoAAABaAw=='
    self.hdmi2 = 'AAAAAgAAABoAAABbAw=='
    self.hdmi3 = 'AAAAAgAAABoAAABcAw=='
    self.hdmi4 = 'AAAAAgAAABoAAABdAw=='
end

-- function for sending the IRCC codes to the TV
function QuickApp:remoteCode(args)
    self:debug ("function IRCC called")
    local sonyip = self:getVariable("ip");
    local sonypsk = self:getVariable("psk"); 
 function putMethod(requestUrl, data, successCallback, errorCallback)
    local http = net.HTTPClient()
    http:request(requestUrl, {
        options = {
        method = 'POST',
        headers = {
         ["Content-Type"] = "text/xml";
         ["soapaction"] = '"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"';
            ["x-auth-psk"] = '' .. sonypsk .. '';
         },
        data = data
        },
        success = successCallback,
        error = errorCallback
     })
     return args
  end


local url = 'http://' .. sonyip .. '/sony/IRCC'
local data = [[
<?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
      <u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
        <IRCCCode>]] .. self.args .. [[</IRCCCode>
      </u:X_SendIRCC>
    </s:Body>
</s:Envelope>
]]

putMethod(
  url,
  data,
  function(resp)
    print('Status: ' .. resp.status)
  end,
  function(err)
    print('error' .. err)
  end
)
end

-- Configuration of the buttons
--Source
function QuickApp:uibutton1_1(event)
    self.args = self.source
    self:remoteCode()
end

--mic
function QuickApp:uibutton1_2(event)
    self.debug ("no key (microphone)")
    --self:remoteCode()
end

--PowerCycle
function QuickApp:uibutton1_3(event)
    self:debug ("power button pressed")
    self:debug (self.powerbutton)
    self.args = self.powerbutton
    self:remoteCode() 
end

-- Digital/Analog
function QuickApp:uibutton2_1(event)
    self.args = self.diAna
    self:remoteCode()
end

-- TV/Radio
function QuickApp:uibutton2_2(event)
    self.args = self.tvRadio
    self:remoteCode()
end

-- Sync Menu
function QuickApp:uibutton2_3(event)
    self.args = self.sync
    self:remoteCode()
end

-- exit
function QuickApp:uibutton2_4(event)
    self.args = self.exit
    self:remoteCode()
end

-- Num 1
function QuickApp:uibutton3_1(event)
    self.args = self.num1
    self:remoteCode()
end
-- Num 2
function QuickApp:uibutton3_2(event)
    self.args = self.num2
    self:remoteCode()
end

-- Num 3
function QuickApp:uibutton3_3(event)
    self.args = self.num3
    self:remoteCode()
end

-- Num 4
function QuickApp:uibutton4_1(event)
    self.args = self.num4
    self:remoteCode()
end

-- Num 5
function QuickApp:uibutton4_2(event)
    self.args = self.num5
    self:remoteCode()
end

-- Num 6
function QuickApp:uibutton4_3(event)
    self.args = self.num6
    self:remoteCode()
end

-- Num 7
function QuickApp:uibutton5_1(event)
    self.args = self.num7
    self:remoteCode()
end

-- Num 8
function QuickApp:uibutton5_2(event)
    self.args = self.num8
    self:remoteCode()
end

-- Num 9
function QuickApp:uibutton5_3(event)
    self.args = self.num9
    self:remoteCode()
end

-- info
function QuickApp:uibutton6_1(event)
    self.args = self.info
    self:remoteCode()
end

-- Num 0
function QuickApp:uibutton6_2(event)
    self.args = self.num0
    self:remoteCode()
end

-- Subtitle
function QuickApp:uibutton6_3(event)
    self.args = self.subtitle
    self:remoteCode()
end

--Google Play
function QuickApp:uibutton7_1(event)
    self.args = self.googlePlay
    self:remoteCode() 
end

--Netflix
function QuickApp:uibutton7_2(event)
    self.args = self.netflix
    self:remoteCode() 
end

-- Red
function QuickApp:uibutton8_1(event)
    self.args = self.red
    self:remoteCode()
end

-- Green
function QuickApp:uibutton8_2(event)
    self.args = self.green
    self:remoteCode()
end

-- Yellow
function QuickApp:uibutton8_3(event)
    self.args = self.yellow
    self:remoteCode()
end

-- Blue
function QuickApp:uibutton8_4(event)
    self.args = self.blue
    self:remoteCode()
end

-- TV
function QuickApp:uibutton9_1(event)
    self.args = self.tv
    self:remoteCode()
end

-- Action Menu
function QuickApp:uibutton9_2(event)
    self.args = self.action
    self:remoteCode()
end

-- EPG
function QuickApp:uibutton9_3(event)
    self.args = self.epg
    self:remoteCode()
end

-- Arrow up
function QuickApp:uibutton10_1(event)
    self.args = self.arrowUp
    self:remoteCode()
end

-- Arrow Left
function QuickApp:uibutton10_2(event)
    self.args = self.arrowLeft
    self:remoteCode()
end

-- OK/Enter button
function QuickApp:uibutton10_3(event)
    self.args = self.enter
    self:remoteCode()
end

-- Arrow Right
function QuickApp:uibutton10_4(event)
    self.args = self.arrowRight
    self:remoteCode()
end

-- Arrow Down
function QuickApp:uibutton10_5(event)
    self.args = self.arrowDown
    self:remoteCode()
end

-- Back
function QuickApp:uibutton11_1(event)
    self.args = self.back
    self:remoteCode()
end

-- Disover
function QuickApp:uibutton11_2(event)
    self.args = self.diwscover
    self:remoteCode()
end

-- Home
function QuickApp:uibutton11_3(event)
    self.args = self.home
    self:remoteCode()
end

-- Volume up
function QuickApp:uibutton12_1(event)
    self.args = self.volumeUp
    self:remoteCode()
end

-- Cycle channel
function QuickApp:uibutton12_2(event)
    self.args = self.diAna
    self:remoteCode()
end

-- Channel Up
function QuickApp:uibutton12_3(event)
    self.args = self.channelUp
    self:remoteCode()
end

--volume down
function QuickApp:uibutton13_1(event)
    self.args = self.volumeDown
    self:remoteCode()
end

-- Mute
function QuickApp:uibutton13_2(event)
    self.args = self.mute
    self:remoteCode()
end

-- Channel Down
function QuickApp:uibutton13_3(event)
    self.args = self.channelDown
    self:remoteCode()
end

-- Audio
function QuickApp:uibutton14_1(event)
    self.args = self.audio
    self:remoteCode()
end

-- Rewind
function QuickApp:uibutton14_2(event)
    self.args = self.rewind
    self:remoteCode()
end

-- Play
function QuickApp:uibutton14_3(event)
    self.args = self.play
    self:remoteCode()
end

-- Fast forward
function QuickApp:uibutton14_4(event)
    self.args = self.fastForward
    self:remoteCode()
end

-- Subtitle
function QuickApp:uibutton15_1(event)
    self.args = self.subtitle
    self:remoteCode()
end

-- Skip Back
function QuickApp:uibutton15_2(event)
    self.args = self.skipBack
    self:remoteCode()
end

-- Pause
function QuickApp:uibutton15_3(event)
    self.args = self.pause
    self:remoteCode()
end

-- Skip forward
function QuickApp:uibutton15_4(event)
    self.args = self.skipForward
    self:remoteCode()
end

-- Help
function QuickApp:uibutton16_1(event)
    self.args = self.help
    self:remoteCode()
end

-- Record
function QuickApp:uibutton16_2(event)
    self.args = self.record
    self:remoteCode()
end

-- Stop
function QuickApp:uibutton16_3(event)
    self.args = self.stop
    self:remoteCode()
end

-- Title list
function QuickApp:uibutton16_4(event)
    self.args = self.title
    self:remoteCode()
end

-- HDMI1
function QuickApp:uibutton17_1(event)
    self.args = self.hdmi1
    self:remoteCode()
end

-- HDMI2
function QuickApp:uibutton17_2(event)
    self.args = self.hdmi2
    self:remoteCode()
end

-- HDMI3
function QuickApp:uibutton17_3(event)
    self.args = self.hdmi3
    self:remoteCode()
end

-- HDMI4
function QuickApp:uibutton17_4(event)
    self.args = self.hdmi4
    self:remoteCode()
end

-- Power On
function QuickApp:uibutton18_1(event)
    self.args = self.powerOn
    self:remoteCode()
end

-- Power Off
function QuickApp:uibutton18_2(event)
    self.args = self.powerOff
    self:remoteCode()
end

 

×
×
  • Créer...