Page 2 sur 4
Re: Automatisation Hue + Fibaro eye motion
Publié : 11 févr. 2017, 21:14
par vil1driver
Dans mon script
'mv salon' est le détecteur de mouvement
'lumino salon' est un switch qui passe à On lorsqu'il fait noir
'la porte' est le capteur de porte
'absence' indique à quand remonte la dernière détection de mouvement
Re: Automatisation Hue + Fibaro eye motion
Publié : 11 févr. 2017, 21:17
par plouf34
Du coup comment j'adapte ton script avec plusieurs détecteurs de mouvement et d'ouverture de porte? Je sèche.
Re: Automatisation Hue + Fibaro eye motion
Publié : 11 févr. 2017, 22:32
par vil1driver
essai ceci
Code : Tout sélectionner
-- script_device_porte.lua
function lastSeen(device)
t1 = os.time()
s = otherdevices_lastupdate[device]
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
return (os.difftime (t1, t2))
end
commandArray = {}
local porteOuverte = devicechanged['Porte Entrée Salon'] == 'Open' or devicechanged['Porte Entrée Terrasse'] == 'Open' or devicechanged['Porte Veranda'] == 'Open'
local pieceVide = lastSeen('Œil de chat SAM') > 1200 and lastSeen('Œil de chat Entrée') > 1200 and lastSeen('Œil de chat Salon') > 1200
local pieceNoire = otherdevices['Lux Sensor Entrée'] < '50' and otherdevices['Lux Sensor SAM'] < '50' and otherdevices['Lux Porte Salon'] < '50' and otherdevices['Lux Sensor Salon'] < '50'
if (porteOuverte and pieceVide and pieceNoire) then
commandArray['Lumiere lampe SAM'] =' On'
commandArray['Lumiere lampe salon'] = 'On'
end
return commandArray
Automatisation Hue + Fibaro eye motion
Publié : 11 févr. 2017, 23:37
par plouf34
Merci. T'es un chef. J'essaye cela demain et te dis ce qu'il en est.
Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 15:37
par plouf34
J'ai copié cela dans la partie événement de Domoticz, et enregistré en tant que script LUA:
Code : Tout sélectionner
function lastSeen(device)
t1 = os.time()
s = otherdevices_lastupdate[device]
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
return = (os.difftime (t1, t2))
end
commandArray = {}
local porteOuverte = devicechanged['Porte Entrée Salon'] == 'Open' or devicechanged['Porte Entrée Terrasse'] == 'Open' or devicechanged['Porte Veranda'] == 'Open'
local pieceVide = lastSeen('Œil de chat SAM') > 1200 and lastSeen('Œil de chat Entrée') > 1200 and lastSeen('Œil de chat Salon') > 1200
local pieceNoire = otherdevices['Lux Sensor Entrée'] < 51 and otherdevices['Lux Sensor SAM'] < 51 and otherdevices['Lux Sensor Salon'] < 51
if (porteOuverte and pieceVide and pieceNoire) then
CommandArray['Lumiere lampe SAM'] = 'On'
CommandArray['Lumiere lampe salon'] = 'On'
end
J'ai malheureusement une erreur dans les logs toutes les secs:
Error: EventSystem: in script_device_porte: [string "function lastSeen(device) ..."]:11: unexpected symbol near '='
Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 16:32
par vil1driver
Ah oui désolé, supprimes le = après return
Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 16:46
par plouf34
Nouvelle erreur:
Code : Tout sélectionner
2017-02-12 16:42:46.058 Error: EventSystem: in Lumiere_Nuit_Porte: [string "function lastSeen(device) ..."]:20: attempt to compare string with number
Rappel du code; la ligne 20 est pour local PieceNoire
Code : Tout sélectionner
function lastSeen(device)
t1 = os.time()
s = otherdevices_lastupdate[device]
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
return (os.difftime (t1, t2))
end
commandArray = {}
local porteOuverte = devicechanged['Porte Entrée Salon'] == 'Open' or devicechanged['Porte Entrée Terrasse'] == 'Open' or devicechanged['Porte Veranda'] == 'Open'
local pieceVide = lastSeen('Œil de chat SAM') > 1200 and lastSeen('Œil de chat Entrée') > 1200 and lastSeen('Œil de chat Salon') > 1200
local pieceNoire = otherdevices['Lux Sensor Entrée'] < 51 and otherdevices['Lux Sensor SAM'] < 51 and otherdevices['Lux Sensor Salon'] < 51
if (porteOuverte and pieceVide and pieceNoire) then
CommandArray['Lumiere lampe SAM'] = 'On'
CommandArray['Lumiere lampe salon'] = 'On'
end
Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 17:38
par vil1driver
Ah et bien transforme 51 en string comme ceci '51'

Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 18:13
par plouf34
vil1driver a écrit :Ah et bien transforme 51 en string comme ceci '51'

J'ai maintenant cette erreur toutes les 1 minutes. Y'a du mieux, avant c'était une erreur toutes les secondes
Code : Tout sélectionner
2017-02-12 18:11:00.411 Error: EventSystem: in Lumiere_Nuit_Porte: [string "function lastSeen(device) ..."]:18: attempt to index global 'devicechanged' (a nil value)
Re: Automatisation Hue + Fibaro eye motion
Publié : 12 févr. 2017, 18:14
par vil1driver
le script doit être de type device !!!
un peu de lecture pour toi aussi alors
https://easydomoticz.com/point-scripts-lua/