Pour monitorer la consommation du lave linge et du sèche linge, j’ai acheté des prises zwave type Fibaro et néo coolcam. Chacune a ses qualités et ses défauts
succinctement les voila listés :
néo coolcam :
les plus => prix, informations de tension et courant.
les moins => puissance limitée notamment en commutation, fiabilité (3 prises HS suite à coupure de courant)
Fibaro :
les plus => fiabilité
les moins => le prix, pas d’information de courant ni de tension.
J’utilisais auparavant deux scripts lua distincts pour surveiller la fin de cycle de mon lave linge, et de mon sèche linge.
ils m’apportaient entière satisfaction mais je souhaitais les réunir en un seul script, en simplifiant notamment la déclaration des infos.
Puis j’ai suivi la conception d’un script DZvents par Wizzard72 faisant exactement la même chose sans création de variables utilisateur.
en utilisant la capacité de DZvents à historiser les données et à calculer une moyenne sur ces données, L’auteur se sert de ce script pour éteindre ses équipements.
Mais ce n’est pas tout à fait l’usage que je souhaitais en faire, les prises que j’utilise étant fragile en commutation. Je ne souhaitais pas non plus une action supplémentaire pour allumer l’équipement.
j’ai donc adapté ce script pour mon usage personnel, en ajoutant notamment :
les notifications lors de la mise en marche des équipements,
la simplification de la déclaration des paramètres de chaque équipement.
la gestion éventuelle des notifications sur xiaomi gateway
dans le tableau DEVICES vous devait associer le device qui surveille la consommation de l’équipement au dummy device que vous aurez préalablement créé
local DEVICES = { -- [device consommation] = switch associé, ['Lave Linge (Consommation)'] = 'Lave Linge', -- You need to have a inline wall plug that measures energy, and make the link between the energy device and the device switch. ['Sèche Linge (Consommation)'] = 'Sèche Linge'--, -- Adjust to your needs. Between every line you need to add a ",". }
Dans le tableau parametres vous devez déclarer les paramètres pour chacun de vos équipements
TimeOut = Temps d’inactivité avant mise à l’arrêt
MinWatt = seuil en dessous duquel l’équipement peut être considéré à l’arrêt
Maxwatt = Seuil en dessus duquel l’équipement peut être considéré en marche
Notify = ‘Yes’ pour être notifié de l’état de l’équipement, ‘No’ pour ne pas l’être
Notify_On = ‘Yes’ pour être notifié de la mise en marche de l’équipement, ‘No’ pour ne pas l’être
MidValue = pour les notifications sur xiaomi gateway via un switch selector, chaque numéro correspond à un fichier son pré enregistré. nil si inutilisé
subSystem = subSystem de notification, nil pour l’ensemble des notifications paramétrées dans domoticz
les subsystem disponible sont (précédés de domoticz.) : NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
local parametres = { ['Lave Linge'] = {['TimeOut'] = 4, ['MinWatt'] = 4, ['MaxWatt'] = 15, ['Notify'] = 'Yes', ['Notify_On'] = 'No', ['MidValue'] = 1, ['SubSystem'] = domoticz.NSS_HTTP}, ['Sèche Linge'] = {['TimeOut'] = 8, ['MinWatt'] = 3, ['MaxWatt'] = 100, ['Notify'] = 'Yes', ['Notify_On'] = 'No', ['MidValue'] = 2, ['SubSystem'] = domoticz.NSS_HTTP} }
Déclarez l’éventuel selector switch pilotant les notifications sur xiaomi gateway dans la variable SelectorMid
local SelectorMid = 'Mid Value' --nom du Selector Switch correspondant à la gateway Xiaomi
ensuite dans le tableau devices déclarez l’ensemble des devices utilisés
devices = { -- Make sure that the devices are the same as above 'Lave Linge (Consommation)', 'Lave Linge', 'Sèche Linge (Consommation)', 'Sèche Linge' },
enfin dans le tableau data déclarez et paramétrez les devices remontant la consommation des équipements pour permettre le calcul d’une moyenne sur un temps déterminé (maxMinutes)
data = { -- use exact device names to match USAGE_DEVICES ['Lave Linge (Consommation)'] = { history = true, maxMinutes = 6 }, ['Sèche Linge (Consommation)'] = { history = true, maxMinutes = 10 }--, },
le script complet
--[[ This script switches off a device after it has consumed no or almost no power for a certain period of time. it switches On Prerequisits ================================== Domoticz v3.8837 or later (dzVents version 2.3 or later) CHANGE LOG: See https://www.domoticz.com/forum/viewtopic.php?f=72&t=23363 -- Authors ---------------------------------------------------------------- V1.0 - Wizzard72 with the help of dannybloe V1.1 - papoo ]]-- function lesparametres(tableau) for t, i in pairs(tableau) do if t == "Switch" then Switch = i end if t == "TimeOut" then TimeOut = i end if t == "MinWatt" then MinWatt = i end if t == "MaxWatt" then MaxWatt = i end if t == "Notify" then Notify = i end if t == "Notify_On" then Notify_On = i end if t == "MidValue" then MidValue = i end if t == "SubSystem" then SubSystem = i end end return Switch,TimeOut,MinWatt,MaxWatt,Notify,SubSystem end -- create a lookup table that matches a usage -- device to the accompanying switch local DEVICES = { -- [device consommation)] = switch associé, ['Lave Linge (Consommation)'] = 'Lave Linge', -- You need to have a inline wall plug that measures energy, ['Sèche Linge (Consommation)'] = 'Sèche Linge'--, -- here you make the link between the energy device and the wall plug. -- Adjust to your needs. Between every line you need to add a ",". } -- TimeOut = Temps d'inactivité avant mise à l'arrêt -- MinWatt = seuil en dessous duquel l'équipement peut être considéré à l'arrêt -- Maxwatt = Seuil en dessus duquel l'équipement peut être considéré en marche -- Notify = 'Yes' pour être notifié de l'état de l'équipement, 'No' pour ne pas l'être -- Notify_On = 'Yes' pour être notifié de la mise en marche de l'équipement, 'No' pour ne pas l'être -- MidValue = pour les notifications sur xiaomi gateway via un switch selector, chaque numéro correspond à un fichier son pré enregistré. nil si inutilisé -- subSystem = subSystem de notification, nil pour l'ensemble des notifications paramétrées dans domoticz --les subsystem disponible sont (précédé de domoticz.) : NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM local parametres = { ['Lave Linge'] = {['TimeOut'] = 4, ['MinWatt'] = 4, ['MaxWatt'] = 15, ['Notify'] = 'Yes', ['Notify_On'] = 'No', ['MidValue'] = 1, ['SubSystem'] = domoticz.NSS_HTTP}, ['Sèche Linge'] = {['TimeOut'] = 8, ['MinWatt'] = 3, ['MaxWatt'] = 100, ['Notify'] = 'Yes', ['Notify_On'] = 'No', ['MidValue'] = 2, ['SubSystem'] = domoticz.NSS_HTTP} } local SelectorMid = 'Mid Value' --nom du Selector Switch correspondant à la gateway Xiaomi return { active = true, -- active (true) ou désactive (false) le script logging = { -- level = domoticz.LOG_INFO, -- Max. one level can be active; comment the others -- level = domoticz.LOG_ERROR, level = domoticz.LOG_DEBUG, -- level = domoticz.LOG_MODULE_EXEC_INFO, marker = 'FIN DE CYCLE v1.1 ' }, on = { devices = { -- Make sure that the devices are the same as above 'Lave Linge (Consommation)', 'Lave Linge', 'Sèche Linge (Consommation)', 'Sèche Linge' }, }, data = { -- use exact device names to match USAGE_DEVICES ['Lave Linge (Consommation)'] = { history = true, maxMinutes = 6 }, ['Sèche Linge (Consommation)'] = { history = true, maxMinutes = 10 }--, }, execute = function(domoticz, device) if (DEVICES[device.name] ~= nil) then -- we have a usage sensor here lesparametres(parametres[DEVICES[device.name]]) local switch = domoticz.devices(DEVICES[device.name]) local history = domoticz.data[device.name] domoticz.log("moyenne = " .. history.avg(), domoticz.LOG_DEBUG) domoticz.log("timeout = " .. TimeOut, domoticz.LOG_DEBUG) domoticz.log("délai = " .. switch.lastUpdate.minutesAgo, domoticz.LOG_DEBUG) domoticz.log("MinWatt = " .. MinWatt, domoticz.LOG_DEBUG) domoticz.log("MaxWatt = " .. MaxWatt, domoticz.LOG_DEBUG) domoticz.log("MidValue = " .. MidValue, domoticz.LOG_DEBUG) domoticz.log("Notify = " .. Notify, domoticz.LOG_DEBUG) domoticz.log("Notify_On = " .. Notify_On, domoticz.LOG_DEBUG) history.add(device.WhActual) if switch.active and (history.avg() <= MinWatt) and (switch.lastUpdate.minutesAgo >= TimeOut) then switch.switchOff().checkFirst() end if (history.avg() >= MaxWatt) then switch.switchOn().checkFirst() end else -- device is a switch lesparametres(parametres[device.name]) if (device.active and Notify == 'Yes' and Notify_On == 'Yes') then domoticz.notify( device.name .. ' Début de cycle', 'le '.. device.name .. ' commence son cycle, Je vous préviendrais lorsqu\'il sera terminé', domoticz.PRIORITY_EMERGENCY, '',--Sound '',--Extra SubSystem--domoticz.NSS_HTTP ) elseif (Notify == 'Yes') and (device.lastUpdate.minutesAgo >= TimeOut) then domoticz.log("MidValue = " .. MidValue, domoticz.LOG_DEBUG) domoticz.log("Notify = " .. Notify, domoticz.LOG_DEBUG) domoticz.log("Notify_On = " .. Notify_On, domoticz.LOG_DEBUG) domoticz.notify( device.name .. ' Cycle Terminé', --subject --'Cycle Terminé : '.. device.name ..'# 'Le '.. device.name ..' vient de se terminer', -- Message domoticz.PRIORITY_EMERGENCY, --Priority '',--Sound '',--Extra SubSystem-- domoticz.NSS_HTTP ) if (MidValue ~= nil) then domoticz.devices(SelectorMid).switchSelector(MidValue) domoticz.log("MidValue = " .. MidValue, domoticz.LOG_DEBUG) end -- notification via xiaomi gateway end end end }
retrouver la dernière version de ce script sur [homepage]https://github.com/papo-o/domoticz_scripts/blob/master/dzVents/scripts/fin2cycle.lua[/homepage]