Page 2 of 2

Re: DZvents and security

Posted: Sunday 25 February 2024 11:46
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

Re: DZvents and security

Posted: Sunday 25 February 2024 12:44
by Kedi
So there is still an error in your script. Just post your last working script.

Re: DZvents and security

Posted: Sunday 25 February 2024 16:17
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
 }

Re: DZvents and security

Posted: Sunday 25 February 2024 17:17
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.

Re: DZvents and security

Posted: Sunday 25 February 2024 17:20
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?

Re: DZvents and security

Posted: Sunday 25 February 2024 19:10
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?

Re: DZvents and security

Posted: Monday 26 February 2024 10:46
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

Re: DZvents and security

Posted: Monday 26 February 2024 14:44
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
 }

Re: DZvents and security

Posted: Monday 26 February 2024 18:52
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
 }