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.
Script to disable/enable events
Moderator: leecollings
-
- 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
Is there no script to do this?
- 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
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
-
- 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
No... I also can't find the menu you are suggesting.
- 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
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
Re: Script to disable/enable events
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.
If the vacation switch is OFF then execute events, if its ON do nothing.
-
- Posts: 29
- Joined: Saturday 19 March 2016 23:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Script to disable/enable events
HiSlinkos 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.
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 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¶m=updateuservariable&vname=MyScriptRun&vtype=integer&vvalue=1
Code: Select all
http://192.168.0.15:8080/json.htm?type=command¶m=updateuservariable&vname=MyScriptRun&vtype=integer&vvalue=0
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
-
- 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
I am on the latest stableDomosapiens wrote:Update your version?
Who is online
Users browsing this forum: No registered users and 1 guest