DZvents and security

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

Moderator: leecollings

remko2000
Posts: 167
Joined: Thursday 28 December 2017 14:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: DZvents and security

Post by remko2000 »

thanks for your explanation. Bright. I adjusted it and now I no longer have an error.
What strikes me is that this script is now triggered every second. This gives a lot of messages in my log. Is there any way to limit this traffic?
2024-02-25 11:46:18.098 Status: dzVents: Info: ------ Start internal script: testbeveil5: Security: "Disarmed", trigger: "Disarmed"
2024-02-25 11:46:18.117 Status: dzVents: Info: Security was triggered by Disarmed
2024-02-25 11:46:18.117 Status: dzVents: Info: ------ Finished testbeveil5
2024-02-25 11:46:18.118 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2024-02-25 11:46:18.440 Status: dzVents: Info: ------ Start internal script: testbeveil5: Security: "Disarmed", trigger: "Disarmed"
2024-02-25 11:46:18.460 Status: dzVents: Info: Security was triggered by Disarmed
2024-02-25 11:46:18.460 Status: dzVents: Info: ------ Finished testbeveil5
Kedi
Posts: 569
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: DZvents and security

Post by Kedi »

So there is still an error in your script. Just post your last working script.
Logic will get you from A to B. Imagination will take you everywhere.
remko2000
Posts: 167
Joined: Thursday 28 December 2017 14:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: DZvents and security

Post by remko2000 »

I'm sorry, this is:

Code: Select all

return {
    on = {
        security = { domoticz.SECURITY_DISARMED, domoticz.SECURITY_ARMEDAWAY }
        },
        execute = function(domoticz, item)
        if item.state == domoticz.SECURITY_ARMEDAWAY then
            domoticz.devices('Beveiliging buttonplus schakelen').switchOn()
            domoticz.executeShellCommand ('mosquitto_pub -h 10.0.1.122 -p 1883 -t domoticz/out/buttonplus/wk1/button/1r/ledrgb -m 8323072')
            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        elseif item.state == domoticz.SECURITY_DISARMED then
            domoticz.devices('Beveiliging buttonplus schakelen').switchOff()
            domoticz.executeShellCommand ('mosquitto_pub -h 10.0.1.122 -p 1883 -t domoticz/out/buttonplus/wk1/button/1r/ledrgb -m 0')
            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        end
 end
 }
HvdW
Posts: 599
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: DZvents and security

Post by HvdW »

What if you change your elseif into an if?
The elseif is dependent from the prior if, a second if if's on it's own.
Last edited by HvdW on Sunday 25 February 2024 18:16, edited 3 times in total.
Bugs bug me.
User avatar
waltervl
Posts: 5735
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: DZvents and security

Post by waltervl »

The script seems OK now.
So there must be something else sending disarm signal to the Domoticz security panel. Do you have the Domoticz security panel open all the time somewhere? Some other test script still running?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Kedi
Posts: 569
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: DZvents and security

Post by Kedi »

I tested the script and it works fine.
This behavior is only possible if the button "Beveiliging buttonplus schakelen" triggers the security panel again.
You wrote that that button is a dummy. Is there a script that triggers on that dummy that switches the security panel?
Or is there a 'link' between the domoticz/out/buttonplus/wk1/button/1r/ledrgb topic and the security panel?
Logic will get you from A to B. Imagination will take you everywhere.
remko2000
Posts: 167
Joined: Thursday 28 December 2017 14:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: DZvents and security

Post by remko2000 »

After some research I understand. With the dummy I had 'on' and 'off' commands for my security panel (e.g. http://10.0.1.122:8080/json.htm?type=co ... ode=xxxxxx). I had set this up this way because I want to switch my security on or off from my button plus panel with 1 button (with the toggle of my dummy). In principle I could also overcome this in the script, but I suspect that with the current script my dummy only switches along, but I also want my security panel to switch along when I switch my dummy (via my plus button). So both ways. So I want to be able to switch my security with both my dummy and the security panel.

How could I supplement my script with this or should it be a separate script?

Code: Select all

return {
    on = {
        security = { domoticz.SECURITY_DISARMED, domoticz.SECURITY_ARMEDAWAY }
        },
        execute = function(domoticz, item)
        if item.state == domoticz.SECURITY_ARMEDAWAY then
            domoticz.devices('Beveiliging buttonplus schakelen').switchOn()
            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        elseif item.state == domoticz.SECURITY_DISARMED then
            domoticz.devices('Beveiliging buttonplus schakelen').switchOff()
            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        end
 end
 }
For simplicity's sake, I have removed switching the LED from the script
Kedi
Posts: 569
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: DZvents and security

Post by Kedi »

It should be something like this. I could not test it, I hope I did not make typos.

Code: Select all

return {
    on = {
    	devices = { 'Beveiliging buttonplus schakelen' },
        security = { domoticz.SECURITY_DISARMED, domoticz.SECURITY_ARMEDAWAY }
        },
        execute = function(domoticz, item)
        if item.isSecurity then
	        if item.state == domoticz.SECURITY_ARMEDAWAY then
        	    domoticz.devices('Beveiliging buttonplus schakelen').switchOn().silent()
	            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        	elseif item.state == domoticz.SECURITY_DISARMED then
	            domoticz.devices('Beveiliging buttonplus schakelen').switchOff().silent()
        	    domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
	        end
	 else
	 	if item.state == 'On' then
	 		domoticz.devices(<Security Panel Name>).armAway().silent()
	 	else
	 		domoticz.devices(<Security Panel Name>).disarm().silent()
	 	end
	 end
 end
 }
Logic will get you from A to B. Imagination will take you everywhere.
remko2000
Posts: 167
Joined: Thursday 28 December 2017 14:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: DZvents and security

Post by remko2000 »

Many thx, this works great. A little adjustment in the name 'security panel' and it works! This is my endscript:

Code: Select all

return {
    on = {
    	devices = { 'Beveiliging buttonplus schakelen' },
        security = { domoticz.SECURITY_DISARMED, domoticz.SECURITY_ARMEDAWAY }
        },
        execute = function(domoticz, item)
        if item.isSecurity then
	        if item.state == domoticz.SECURITY_ARMEDAWAY then
        	    domoticz.devices('Beveiliging buttonplus schakelen').switchOn().silent()
	            domoticz.executeShellCommand ('mosquitto_pub -h 10.0.1.122 -p 1883 -t domoticz/out/buttonplus/wk1/button/1r/ledrgb -m 8323072')
	            domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
        	elseif item.state == domoticz.SECURITY_DISARMED then
	            domoticz.devices('Beveiliging buttonplus schakelen').switchOff().silent()
	            domoticz.executeShellCommand ('mosquitto_pub -h 10.0.1.122 -p 1883 -t domoticz/out/buttonplus/wk1/button/1r/ledrgb -m 0')
        	    domoticz.log('Security was triggered by ' .. item.trigger, domoticz.LOG_INFO)
	        end
	 else
	 	if item.state == 'On' then
	 		domoticz.devices('Security Panel').armAway().silent()
	 	else
	 		domoticz.devices('Security Panel').disarm().silent()
	 	end
	 end
 end
 }
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest