Aller au contenu

Télécommande De Couleurs Wallplug


Domotique-Home

Recommended Posts

Ben voila je comprend mieux ;)

L'ordre des priorités a changés dans la v4

 

v3.X = {"id":62,"size":1,"value":8,"lastSetValue":8}

 

v4.X = {"id":62,"lastSetValue":8,"size":1,"value":8}

 

essaie le code suivant pour Position Off bouton Red et dit moi si ça marche.

local deviceID = fibaro:getGlobal("IdWallPlug") --ID de Wallplug
local IpHC2 = fibaro:get(fibaro:getSelfId(), "IPAddress") -- IP HC2
local LoginHC2 = fibaro:getGlobal("LoginHC2") -- login
local MdpHC2 = fibaro:getGlobal("MdpHC2") -- mot de passe
local mycolor = '2'; -- choix de la couleur
json = "";
response = "";

  
HC2 = Net.FHttp(IpHC2);
HC2:setBasicAuthentication(LoginHC2, MdpHC2); 
 
response ,status, errorCode = HC2:GET("/api/devices?id="..deviceID);
 
--fibaro:debug("status = " .. status); 
fibaro:sleep(1000);
--fibaro:debug(response);
debut = string.find(response, "\"id\":62,\"lastSetValue\":8,\"size\":1,\"value\":")   
total = string.len(response)
fin = debut + 42
remplace = string.sub(response,debut,fin)
fibaro:debug(remplace)

response = string.gsub(response, remplace, "\"id\":62,\"lastSetValue\":" .. mycolor .. ",\"size\":1,\"value\":" .. mycolor)
fibaro:debug("---------------")  
fibaro:debug(response)
fibaro:debug("---------------")
--json = json.encode(response);
response3 ,status3, errorCode3 = HC2:PUT("/api/devices?id="..deviceID, response)
fibaro:debug("---------------")
Lien vers le commentaire
Partager sur d’autres sites

en fait, ca me donne plutot ca ds le debug:

 

[DEBUG] 14:39:04: "id":62,"lastSetValue":8,"size":1,"value":8
[DEBUG] 14:39:04: ---------------
[DEBUG] 14:39:04: {"id":7,"name":"Prise aquarium","roomID":8,"type":"com.fibaro.FGWP101","baseType":"com.fibaro.binarySwitch","enabled":true,"visible":true,"isPlugin":false,"parentId":103,"remoteGatewayId":0,"interfaces":["energy","power","zwave","zwaveAlarm"],"properties":{"parameters":[{"id":1,"lastSetValue":1,"size":1,"value":1},{"id":16,"lastSetValue":1,"size":1,"value":1},{"id":34,"lastSetValue":63,"size":1,"value":63},{"id":35,"lastSetValue":0,"size":1,"value":0},{"id":39,"lastSetValue":600,"size":2,"value":600},{"id":40,"lastSetValue":80,"size":1,"value":80},{"id":42,"lastSetValue":15,"size":1,"value":15},{"id":43,"lastSetValue":30,"size":1,"value":30},{"id":45,"lastSetValue":10,"size":1,"value":10},{"id":47,"lastSetValue":3600,"size":2,"value":3600},{"id":49,"lastSetValue":0,"size":1,"value":0},{"id":50,"lastSetValue":300,"size":2,"value":300},{"id":51,"lastSetValue":500,"size":2,"value":500},{"id":52,"lastSetValue":6,"size":1,"value":6},{"id":60,"lastSetValue":25000,"size":2,"value":25000},{"id":61,"lastSetValue":9,"size":1,"value":9},{"id":62,"lastSetValue":2,"size":1,"value":2},{"id":63,"lastSetValue":1,"size":1,"value":1},{"id":70,"lastSetValue":65535,"size":2,"value":65535}],"associationSet":[{"devices":[1],"groupID":1},{"devices":[1],"groupID":2},{"devices":[1],"groupID":3}],"associationView":[{"devices":[1],"groupID":1},{"devices":[1],"groupID":2},{"devices":[1],"groupID":3}],"zwaveCompany":"Fibar Group","zwaveInfo":"3,3,52","zwaveVersion":"","pollingTimeSec":0,"alarmLevel":"0","alarmType":"0","color":"off","configured":"true","dead":"false","deviceControlType":"12","deviceIcon":"2","emailNotificationID":"1","emailNotificationType":"0","endPointId":"0","energy":"0.08","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"2","parametersTemplate":"225","power":"2.10","productInfo":"","pushNotificationID":"1","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","useTemplate":"true","userDescription":"Le module es relié à  la prise pour aquaium.","value":"true"},"actions":{"reconfigure":0,"reset":0,"turnOff":0,"turnOn":0},"created":1425492419,"modified":1425492419,"sortOrder":8}
[DEBUG] 14:39:04: ---------------
[DEBUG] 14:39:04: ---------------

Lien vers le commentaire
Partager sur d’autres sites

oui je suis sure.

 

J'ai aussi remplacé les autres boutons de couleur par ton code en changeant le numéro de couleur, et rien a faire, ca fonctionne pas:-(

 

Dois je refaire mes 3 variables global par hasard?

 

edit: pour les boutons ON, c est quoi le code? peut etre qu'il ne faut pas d'erreur dans tout le VD ??

Lien vers le commentaire
Partager sur d’autres sites

quand je rajoute à  la fin du code du bouton RED

fibaro:debug(response3);
fibaro:debug(status3);
fibaro:debug(errorCode3);

cela donne:

 

[ERROR] 16:11:19: line 25: attempt to perform arithmetic on global 'debut' (a nil value)

Lien vers le commentaire
Partager sur d’autres sites

  • 3 weeks later...

Bonjour

Pour ma part en v3.6 j'avis le meme message d'erreur alors que cela fonctionnait en v3.59

J'ai refait un setting sur chacun de mes WallPjug (couleur + setting)

puis tout refonctionne que cela soit en Module Wallplug individuel ou via mes scenes

Lien vers le commentaire
Partager sur d’autres sites

avec le code ci-dessous pour le bouton red quand OFF

 
local deviceID = fibaro:getGlobal("IdWallPlug") --ID de Wallplug
local IpHC2 = fibaro:get(fibaro:getSelfId(), "IPAddress") -- IP HC2
local LoginHC2 = fibaro:getGlobal("LoginHC2") -- login
local MdpHC2 = fibaro:getGlobal("MdpHC2") -- mot de passe
local mycolor = '2'; -- choix de la couleur
json = "";
response = "";
 
 
HC2 = Net.FHttp(IpHC2);
HC2:setBasicAuthentication(LoginHC2, MdpHC2); 
 
response ,status, errorCode = HC2:GET("/api/devices?id="..deviceID);
 
--fibaro:debug("status = " .. status); 
fibaro:sleep(1000);
--fibaro:debug(response);
debut = string.find(response, "\"id\":62,\"lastSetValue\":8,\"size\":1,\"value\":")   
total = string.len(response)
fin = debut + 42
remplace = string.sub(response,debut,fin)
fibaro:debug(remplace)
 
response = string.gsub(response, remplace, "\"id\":62,\"lastSetValue\":" .. mycolor .. ",\"size\":1,\"value\":" .. mycolor)
fibaro:debug("---------------")  
fibaro:debug(response)
fibaro:debug("---------------")
--json = json.encode(response);
response3 ,status3, errorCode3 = HC2:PUT("/api/devices?id="..deviceID, response)
fibaro:debug("---------------")
Lien vers le commentaire
Partager sur d’autres sites

j obtiens dans le debug, apres avoir appuyé sur le bouton setting:

[DEBUG] 23:37:43: "id":62,"lastSetValue":8,"size":1,"value":8
[DEBUG] 23:37:43: ---------------
[DEBUG] 23:37:43: {"id":8,"name":"Prise multimedia","roomID":9,"type":"com.fibaro.FGWP101","baseType":"com.fibaro.binarySwitch","enabled":true,"visible":true,"isPlugin":false,"parentId":105,"remoteGatewayId":0,"interfaces":["energy","power","zwave","zwaveAlarm"],"properties":{"parameters":[{"id":1,"lastSetValue":1,"size":1,"value":1},{"id":16,"lastSetValue":1,"size":1,"value":1},{"id":34,"lastSetValue":63,"size":1,"value":63},{"id":35,"lastSetValue":0,"size":1,"value":0},{"id":39,"lastSetValue":600,"size":2,"value":600},{"id":40,"lastSetValue":80,"size":1,"value":80},{"id":42,"lastSetValue":15,"size":1,"value":15},{"id":43,"lastSetValue":30,"size":1,"value":30},{"id":45,"lastSetValue":10,"size":1,"value":10},{"id":47,"lastSetValue":3600,"size":2,"value":3600},{"id":49,"lastSetValue":0,"size":1,"value":0},{"id":50,"lastSetValue":300,"size":2,"value":300},{"id":51,"lastSetValue":500,"size":2,"value":500},{"id":52,"lastSetValue":6,"size":1,"value":6},{"id":60,"lastSetValue":25000,"size":2,"value":25000},{"id":61,"lastSetValue":9,"size":1,"value":9},{"id":62,"lastSetValue":2,"size":1,"value":2},{"id":63,"lastSetValue":1,"size":1,"value":1},{"id":70,"lastSetValue":65535,"size":2,"value":65535}],"associationSet":[{"devices":[1],"groupID":1},{"devices":[1],"groupID":2},{"devices":[1],"groupID":3}],"associationView":[{"devices":[1],"groupID":1},{"devices":[1],"groupID":2},{"devices":[1],"groupID":3}],"zwaveCompany":"Fibar Group","zwaveInfo":"3,3,52","zwaveVersion":"","pollingTimeSec":0,"alarmLevel":"0","alarmType":"0","color":"off","configured":"true","dead":"false","deviceControlType":"12","deviceIcon":"2","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","energy":"7.07","liliOffCommand":"éteindre prise","liliOnCommand":"allumer prise","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"3","parametersTemplate":"225","power":"0.00","productInfo":"","pushNotificationID":"1","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","showEnergy":"true","smsNotificationID":"0","smsNotificationType":"0","useTemplate":"true","userDescription":"Le module est relié à  la prise murale de la chambre 2.","value":"false"},"actions":{"reconfigure":0,"reset":0,"turnOff":0,"turnOn":0},"created":1427698595,"modified":1427698595,"sortOrder":10}
[DEBUG] 23:37:43: ---------------
[DEBUG] 23:37:43: ---------------

 Mais cela ne marche tjs pas, le wallplug est bien sur off  

Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...