Script to disable/enable events

Moderator: leecollings

Post Reply
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Script to disable/enable events

Post by Slinkos »

Hi all,

I'm thinking to make a virtual switch named "Vacation" for whenever I will be gone from home for a while. My purpose of this switch that when it's on, it will disable the blocky events that I specify in the script), and enable all those events again when I turn the vacation swithc off.

Offcourse I could also rebuild al this events with the statement that "Vacation" has to be off, but I think this is a more clean solution.
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Script to disable/enable events

Post by Slinkos »

Is there no script to do this?
User avatar
Domosapiens
Posts: 232
Joined: Wednesday 20 August 2014 12:08
Target OS: Windows
Domoticz version: V3.5981
Location: NL
Contact:

Re: Script to disable/enable events

Post by Domosapiens »

Did you look for the possibilities of "Timer Plan" under Setup - Other?
Win Vista&7; 1#Aeon Z-Stick S2; 1#Aeotec Z-Sick Gen5, 6#Fib.FGBS001; 24#DS18B20; 8#Everspr.AN158-2; 3#Philio PAN04; 1#Philio PAN06, 1#YouLess El; 1#Fib.FGWPE; 1#ZME_RC2; 2#FAK_ZWS230, 2#Quib.ZMNHCDx, 1#Quib.ZMNHDD1, 7#EM6555
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Script to disable/enable events

Post by Slinkos »

No... I also can't find the menu you are suggesting.
User avatar
Domosapiens
Posts: 232
Joined: Wednesday 20 August 2014 12:08
Target OS: Windows
Domoticz version: V3.5981
Location: NL
Contact:

Re: Script to disable/enable events

Post by Domosapiens »

Update your version?
Win Vista&7; 1#Aeon Z-Stick S2; 1#Aeotec Z-Sick Gen5, 6#Fib.FGBS001; 24#DS18B20; 8#Everspr.AN158-2; 3#Philio PAN04; 1#Philio PAN06, 1#YouLess El; 1#Fib.FGWPE; 1#ZME_RC2; 2#FAK_ZWS230, 2#Quib.ZMNHCDx, 1#Quib.ZMNHDD1, 7#EM6555
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: Script to disable/enable events

Post by toreandre »

One way would be to make your events check for the vacation switch status.

If the vacation switch is OFF then execute events, if its ON do nothing.
lukcinek
Posts: 29
Joined: Saturday 19 March 2016 23:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Script to disable/enable events

Post by lukcinek »

Slinkos wrote:Hi all,

I'm thinking to make a virtual switch named "Vacation" for whenever I will be gone from home for a while. My purpose of this switch that when it's on, it will disable the blocky events that I specify in the script), and enable all those events again when I turn the vacation swithc off.

Offcourse I could also rebuild al this events with the statement that "Vacation" has to be off, but I think this is a more clean solution.
Hi
You should add uservariable in Settings-->More Options-->User variables

Put some name of Your Variable --> MyScriptRun
Type of Variable --> Integer
Variable --> 1

You must add some LUA code to Your Events.

I paste my code that turns off my lights automatically when some time elapses and no motion is discovered.

Code: Select all

script_time_nomotion.lua

local motion_switch = 'PiR - Kitchen'
local nomotion_uservar = 'nomotionCounter'
local status_switch = 'Lamp - ON'
local noRun = uservariables["MyScriptRun"]
local no_motion_minutes = tonumber(uservariables[nomotion_uservar])

commandArray = {}
          if (otherdevices[motion_switch] == 'Off') then
               no_motion_minutes = no_motion_minutes + 1
               --print('<font color="red">No motion has been detected for: ' ..no_motion_minutes.. ' minutes</font>')
          else 
               no_motion_minutes = 0 
          end 
          
          if tonumber(noRun) == 1 then
               if otherdevices[status_switch] == 'On' and no_motion_minutes > 10 then --change the 30 to the amount of minutes you prefer
                    nomotion_uservar= "0"
                    commandArray[status_switch]='Off'
               end
          end 
commandArray['Variable:' .. nomotion_uservar] = tostring(no_motion_minutes)
return commandArray
You must modify this script...sorry I don't know nothing about programming:(

You should make virtual switch (Vacation) and in field:

--> Enable action put something like this:

Code: Select all

 http://192.168.0.15:8080/json.htm?type=command&param=updateuservariable&vname=MyScriptRun&vtype=integer&vvalue=1
--> Disable action put something like this:

Code: Select all

 http://192.168.0.15:8080/json.htm?type=command&param=updateuservariable&vname=MyScriptRun&vtype=integer&vvalue=0 
Change 192.168.0.15:8080 to Your ip and port.

In my case when I turn On my Virtual switch --> My Lua script works and my lights in kitchen Turns off when some time elapses and no motion is discovered.

When i turn Off my Virtual switch --> My lua script doesn't work and my kitchen light are turned on all the time.

Sorry for my English.

Best regards
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Script to disable/enable events

Post by Slinkos »

Domosapiens wrote:Update your version?
I am on the latest stable
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest