Page 1 of 1

Domoticz status widget

Posted: Friday 19 July 2019 19:40
by Hydci
Hello,

I would like to know if it was possible in Dzvent to have a check of the widget domoticz and applied to the light the command corresponding to the status of the widget domoticz because of times a light and lit following a breakdown of electricity and I would like that domoticz turn off the light if this one and I use a lua script that I found but I would like a Dzvent

Any help to write the Dzvent would be welcome thank you

Dzvent
Every 2 mins
Check domoticz status (off)
check light bulb (on)
Command off

Code: Select all

commandArray = {}

--recupere les minutes
time=os.time()
minutes=tonumber(os.date('%M',time))
hours=tonumber(os.date('%H',time))

print('!*!*!*!*!*!*!*!*!Lancement du check à '..hours..'h'..minutes)


-------Toutes les 15 minutes
------------------------------------------------------------------------

if( (minutes==5) or (minutes==10) or (minutes==15) or (minutes==20) or (minutes==25) or (minutes==30) or (minutes==35) or (minutes==40) or (minutes==45) or (minutes==50) or (minutes==55) ) then
	-- Put your script code here that shall run every 5 minutes



 --------Renforcement des envois de signal-------------------------------------
 ------------------------------------------------------------------------------
   print('check de tous les materiels rfxcom (sans retour d\'etat)');


   local check={}
   --Chauffage
   check['0']='SAM'

   --Parcours le Tableau
   for key, valeur in pairs(check) do
      print ('CHECK : '..valeur.. ' -> ' ..otherdevices[valeur])
      commandArray[valeur]=otherdevices[valeur]
   end
 --------FIN Renforcement des envois de signal-------------------------------------
 ------------------------------------------------------------------------------
end 
return commandArray

Re: Domoticz status widget

Posted: Saturday 20 July 2019 12:15
by waaren
Hydci wrote: Friday 19 July 2019 19:40 Dzvent
Every 2 mins
Check domoticz status (off)
check light bulb (on)
Command off
My understanding from your Lua script is that you want to resend the current state of all switch devices.
so if a device.state == "On" , you want to send device.switchOn() and vice versa.

Is my understanding correct ?

Re: Domoticz status widget

Posted: Sunday 21 July 2019 11:31
by Hydci
Hello, that's fine you understand my request unfortunately I do not know how to take it I would like to do that if the widget says off and the light on and then turn it off if possible

Re: Domoticz status widget  [Solved]

Posted: Sunday 21 July 2019 12:36
by waaren
Hydci wrote: Sunday 21 July 2019 11:31 Hello, that's fine you understand my request unfortunately I do not know how to take it I would like to do that if the widget says off and the light on and then turn it off if possible
I don't know how to do that either. Below script just resends the current state of switch like devices.

Code: Select all

return
{
    on  = { timer = { 'every 2 minutes' }},
        
    execute = function(dz)
        
        dz.devices().
            filter(function(dv)
                    return (dv.switchType == 'On/Off' and dv.deviceType == 'Light/Switch' )
            end).
            forEach(function(dv)
                if dv.active then
                    dv.switchOn().silent()
                    dz.log('Resending On command to ' .. dv.name )
                else
                    dv.switchOff().silent()
                    dz.log('Resending Off command to ' .. dv.name )
                end
            end)
    end
}