Domoticz status widget  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Domoticz status widget

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz status widget

Post 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 ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Domoticz status widget

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Domoticz status widget  [Solved]

Post 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
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest