dzvents in domoticz

hmjgriffon

Known around here
Joined
Mar 30, 2014
Messages
3,386
Reaction score
979
Location
North Florida
Anyone know dzvents at all? Trying to re-write my first script from the old horrible lua to the new dzvents lua, whatever you wanna call it. Can someone tell me if this looks good? See any issues? Thanks.



Code:
return {
    active = true,
    on = {
        devices = {
            'Front Door',
            'Back Door'
        },
    },
    execute = function(domoticz, door)
        if (door.state == 'Open') and domoticz.security('Armed Home') or domoticz.security('Armed Away') then
            domoticz.devices('Siren').switchOn()
            domoticz.log('The '..door..' was opened!')
            domoticz.notify('The '..door..' was opened!', domoticz.PRIORITY_EMERGENCY, domoticz.SOUND_SIREN)
            local BiLogin = 'user=USERNAME&pw=PASSWORD'
            domoticz.openURL('http://10.0.0.124/admin?camera=Kitchen&trigger&'..BiLogin..'')
        end

    end
}
 

randytsuch

Pulling my weight
Joined
Oct 1, 2016
Messages
495
Reaction score
176
I wrote some simple dzvents scripts a while ago.
I can take a look when I get home and see if I notice anything
You might need more parenthesis in your if statement, maybe like this
if ( (door.state == 'Open') and (domoticz.security('Armed Home') or domoticz.security('Armed Away')) ) then

I'm not quite sure if domoticz.security('Armed Home') will do what you want, I haven't played with dzvents for a bit and was never very good at it, just kept trying until I got it to work lol

The dzvents wiki says this
security = { ... }
A list of one or more of these security states:

  • domoticz.SECURITY_ARMEDAWAY,
  • domoticz.SECURITY_ARMEDHOME,
  • domoticz.SECURITY_DISARMED
If the security state in Domoticz changes and it matches with any of the states listed here, the script will be executed. See /path/to/domoticz/scripts/dzVents/examples/templates/security.lua for an example see Security Panel for information about how to create a security panel device.

And this
Security changes
Suppose you have a group holding all the lights in your house, and you want to switch it off as soon as the alarm is activated:

return {
on = {
security = { domoticz.SECURITY_ARMEDAWAY }
},
execute = function(domoticz, security)
domoticz.groups('All lights').switchOff()
end
}


I also think there may be examples of home alarm scripts in the dzvents sub forum at the domoticz forum.

Randy
 

hmjgriffon

Known around here
Joined
Mar 30, 2014
Messages
3,386
Reaction score
979
Location
North Florida
I wrote some simple dzvents scripts a while ago.
I can take a look when I get home and see if I notice anything
You might need more parenthesis in your if statement, maybe like this
if ( (door.state == 'Open') and (domoticz.security('Armed Home') or domoticz.security('Armed Away')) ) then

I'm not quite sure if domoticz.security('Armed Home') will do what you want, I haven't played with dzvents for a bit and was never very good at it, just kept trying until I got it to work lol

The dzvents wiki says this
security = { ... }
A list of one or more of these security states:

  • domoticz.SECURITY_ARMEDAWAY,
  • domoticz.SECURITY_ARMEDHOME,
  • domoticz.SECURITY_DISARMED
If the security state in Domoticz changes and it matches with any of the states listed here, the script will be executed. See /path/to/domoticz/scripts/dzVents/examples/templates/security.lua for an example see Security Panel for information about how to create a security panel device.

And this
Security changes
Suppose you have a group holding all the lights in your house, and you want to switch it off as soon as the alarm is activated:

return {
on = {
security = { domoticz.SECURITY_ARMEDAWAY }
},
execute = function(domoticz, security)
domoticz.groups('All lights').switchOff()
end
}


I also think there may be examples of home alarm scripts in the dzvents sub forum at the domoticz forum.

Randy

Just to help others, I found some more examples and played around once I got home and I've got it working, and I'm pretty damned proud of it too lol, this script will cover all doors and windows, and will not need to be modified when devices are added as long as they follow the naming convention. I didn't add the wildcard for windows because I haven't come up with the naming convention yet.


Code:
return {
    active = true,
    on = {
        devices = {
            '*Door',
        },
    },
    execute = function(domoticz, device)
        if (device.state == 'Open') and (domoticz.security ~= domoticz.SECURITY_DISARMED) then
            domoticz.devices('Siren').switchOn()
            domoticz.log('The '..device.name..' was opened!')
            domoticz.notify('The '..device.name..' was opened!', domoticz.PRIORITY_EMERGENCY, domoticz.SOUND_SIREN)
            local BiLogin = 'user=USERNAME&pw=PASSWORD'
            domoticz.openURL('http://10.0.0.124/admin?camera=Kitchen&trigger&'..BiLogin..'')
        end

    end
}
 
Top