Je rencontre un grave probleme, J'essaye depuis 3h de fait un script device avec une difference de temps mais c'est la loose, j'ai une erreur.
L'idee et de convertir une valeur analogique en % comme expliqué ici : http://domotique.web2diz.net/?p=629
Voici le script :
Code : Tout sélectionner
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
if (timedifference(otherdevices_lastupdate['cpt_Hum_ESP']) < 30 and timedifference(otherdevices_lastupdate['Hum_ESP']) > 50)
then
val = tonumber(otherdevices_svalues['cpt_Hum_ESP']);
val1 = math.floor(100*(val/1024));
commandArray['UpdateDevice']='1380|'..val1..'|0';
print('Hum ESP - '..val1..' %'.." "..val)
end
return commandArrayCode : Tout sélectionner
2016-05-03 00:26:29.330 MQTT: Topic: domoticz/in, Message: {"idx":1378,"nvalue":0,"svalue":"476.00"}
2016-05-03 00:26:29.434 Error: EventSystem: in script_device_humesp: [string "function timedifference(s) ..."]:2: bad argument #1 to 'sub' (string expected, got nil)J'ai parcourut les diiferents forum rapidement sans rien trouver, av ez vous une idée ?
Merci