I have some selector switch (virtual device) who has Off/Hors-Gel/Eco/Confort.
Here is the code :
Code: Select all
-- Script de gestion du chauffage dans l'extension si jours blanc ou rouges
return {
on = {
devices = {
idx_edf_color, -- EDF - Couleur du jour
idx_edf_tarif, -- EDF Tarif en cours
idx_fp_chalet, -- Fil pilote Chalet
},
timer = { 'every minute' },
},
data = {
Etat_Chauffage = { initial = 'dunno'},
},
logging = {
-- level = domoticz.LOG_INFO,
-- level = domoticz.LOG_ERROR,
level = domoticz.LOG_DEBUG,
marker = 'Gestion Chauffage Extension v1.0',
},
execute = function(domoticz)
domoticz.log(" -- Demarrage !", domoticz.LOG_INFO)
-- Recuperation des etats
chauffage_ext = domoticz.devices(idx_fp_chalet).state
edf_tarif = domoticz.devices(idx_edf_tarif).text
edf_color = domoticz.devices(idx_edf_color).text
--
domoticz.log('Valeur du chauffage : '..chauffage_ext, domoticz.LOG_DEBUG)
domoticz.log('EDF : ' ..edf_tarif .. ' / ' .. edf_color, domoticz.LOG_DEBUG)
-- Initialisation de la valeur etat
if (domoticz.data.Etat_Chauffage == 'dunno') then
domoticz.log('Data non initialisé',domoticz.LOG_INFO)
domoticz.data.Etat_Chauffage = chauffage_ext
end
if (((edf_color == '(2) Jour Blanc') or (edf_color == '(3) Jour Rouge')) and (edf_tarif == '(2) Heures Pleines')) then
domoticz.log(' test etat chauffage', domoticz.LOG_DEBUG)
if (chauffage_ext ~= 'Off') then
domoticz.log(' -> pas off, on sauvegarde puis on met a off', domoticz.LOG_INFO)
domoticz.data.Etat_Chauffage = chauffage_ext
domoticz.devices(idx_fp_chalet).switchOff()
end
else
-- remise du FP a son ancienne valeur
if (domoticz.data.Etat_Chauffage ~= chauffage_ext) then
domoticz.log(' -> Heures Creuse, etat ancien : '.. domoticz.data.Etat_Chauffage, domoticz.LOG_INFO)
domoticz.devices(idx_fp_chatlet).setState(domoticz.data.Etat_Chauffage)
--domoticz.data.Etat_Chauffage = chauffage_ext
end
end
domoticz.log(" -- Fin !", domoticz.LOG_INFO)
end
}
Code: Select all
domoticz.devices(idx_fp_chalet).setState(domoticz.data.Etat_Chauffage)
Code: Select all
domoticz.devices(idx_fp_chalet).state
I have already tried :
Code: Select all
domoticz.devices(idx_fp_chalet).level
domoticz.devices(idx_fp_chalet).setLevel(domoticz.data.Etat_Chauffage)
Any good hints?