Page 1 of 1
Vacation-mode
Posted: Thursday 21 September 2017 22:23
by EdwinK
So, I thought of making some kind of thingy that would turn on my HUE lights at Sunset during my vacation, and also a light in my office during at a random time.
It isn't that easy as I thought it would be. Thankfully I've enough time to try something out, as I won't go on vacation before the end of December, but still...
I made a switch called 'Vakantie-mode' from
this topic. At least, that part is working
Code: Select all
-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
devices = {
-- scripts is executed if the device that was updated matches with one of these triggers
'Vakantie-mode', -- device name
-- 'abc*', -- triggers for all devices which name begins with abc
221, -- id
},
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every day'
}
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz, device)
--[[
The domoticz object holds all information about your Domoticz system. E.g.:
local myDevice = domoticz.devices('myDevice')
local myVariable = domoticz.variables('myUserVariable')
local myGroup = domoticz.groups('myGroup')
local myScene = domoticz.sceneds('myScene')
The device object is the device that was triggered due to the device in the 'on' section above.
]] --
-- example
if (device.state == 'On') then
switchOn('Scene Lezen')
end
end
}
This is my first attempt, and of course it isn't working, with a 'Error: dzVents: Error: ...ticz/var/scripts/dzVents/generated_scripts/Vakantie?.lua:40: attempt to call global 'switchOn' (a nil value)'.
Also tried Blockly, but don't understand that at all.
Re: Vacation-mode
Posted: Thursday 21 September 2017 22:38
by Egregius
Link your domoticz to Google Calendar, make some appointments and your lights turn on

Re: Vacation-mode
Posted: Friday 22 September 2017 8:49
by dannybloe
EdwinK wrote: ↑Thursday 21 September 2017 22:23
So, I thought of making some kind of thingy that would turn on my HUE lights at Sunset during my vacation, and also a light in my office during at a random time.
It isn't that easy as I thought it would be. Thankfully I've enough time to try something out, as I won't go on vacation before the end of December, but still...
I made a switch called 'Vakantie-mode' from
this topic. At least, that part is working
Code: Select all
-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
devices = {
-- scripts is executed if the device that was updated matches with one of these triggers
'Vakantie-mode', -- device name
-- 'abc*', -- triggers for all devices which name begins with abc
221, -- id
},
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every day'
}
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz, device)
--[[
The domoticz object holds all information about your Domoticz system. E.g.:
local myDevice = domoticz.devices('myDevice')
local myVariable = domoticz.variables('myUserVariable')
local myGroup = domoticz.groups('myGroup')
local myScene = domoticz.sceneds('myScene')
The device object is the device that was triggered due to the device in the 'on' section above.
]] --
-- example
if (device.state == 'On') then
switchOn('Scene Lezen')
end
end
}
This is my first attempt, and of course it isn't working, with a 'Error: dzVents: Error: ...ticz/var/scripts/dzVents/generated_scripts/Vakantie?.lua:40: attempt to call global 'switchOn' (a nil value)'.
Also tried Blockly, but don't understand that at all.
Well, you started well by using dzVents (but posted this question in the wrong forum I guess). Anyhow... it's very simple: you have to call switchOn ON the device. switchOn is a so called object method. So you need an object to call it on. In this case you want to activate a scene so you have to get the scene from the scenes collection:
Code: Select all
if (device.state == 'On') then
domoticz.scenes('Scene Lezen').switchOn()
end
It's all in the manual

Re: Vacation-mode
Posted: Friday 22 September 2017 9:44
by franzelare
my hue lights are alway controlled by light level outside and with a randomized variable turned off in the evening
i use a blocky script for my holiday, that simulates going to the bathroom and closing and opening the curtains in the morning and evening
makes all very easy to read what will happen when without a lot of code
Re: Vacation-mode
Posted: Friday 22 September 2017 11:29
by jannl
For now I do not do anything different when we are not at home or on holiday. Curtains go on different times, some lights...
Re: Vacation-mode
Posted: Friday 22 September 2017 11:38
by EdwinK
dannybloe wrote: ↑Friday 22 September 2017 8:49
EdwinK wrote: ↑Thursday 21 September 2017 22:23
Well, you started well by using dzVents (but posted this question in the wrong forum I guess).
Whoops. Thought I was in the right board.

Well, maybe some nice moderator will move it
Anyhow... it's very simple: you have to call switchOn ON the device. switchOn is a so called object method. So you need an object to call it on. In this case you want to activate a scene so you have to get the scene from the scenes collection:
Code: Select all
if (device.state == 'On') then
domoticz.scenes('Scene Lezen').switchOn()
end
It's all in the manual
Somehow, it just doesn't connect for me reading those manuals, so I need to experiment.
Re: Vacation-mode
Posted: Friday 22 September 2017 11:54
by EdwinK
So, now this work. Next thing, adding the times when the lights needs to turn on and off.
Back to reading again.
Re: Vacation-mode
Posted: Friday 22 September 2017 12:07
by febalci
Actually if you can handle some presence mode for your or family members smartphones, it is much more easier and you do not have to switch on or off do anything when you are on a vacation:
1. Add presence mode for one or more smartphones of the family members. You can check our one sample here:
http://www.domoticz.com/forum/viewtopic ... 43#p140728
2. Add a dummy switch for one or more smartphones presence (on for at home, off for out of home)
3. Add Timerplan for "At Home" and "At Vacation" where you assign which devices will work or which not when you're home or on vacation.
4. Add a LUA script like this:
Code: Select all
if (devicechanged['FEB_Presence'] or devicechanged['DIB_Presence'] or devicechanged['HTB_Presence']) then
if (otherdevices['FEB_Presence'] == 'On' or otherdevices['DIB_Presence']== 'On' or otherdevices['HTB_Presence']== 'On') then
os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=4" &')
print("Family is Home")
else
os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=3" &')
print("Family is Away")
end
end
Simply when you and all of your family members are not at home (vacation or dinner or something else), disables all events; when at least one of you are at home, it enables all events, or just the ones you want...
Re: Vacation-mode
Posted: Friday 22 September 2017 12:09
by EdwinK
I tried some presence-detector. The one I use now is very unreliable, but will see what happens now.
I don't understand much about those timerplans. Don't seem to have a 'rooms' in /settings/more options. just a roomplan
Re: Vacation-mode
Posted: Friday 22 September 2017 12:51
by febalci
To tell the truth i am very satisfied with the Life360 approach. I will go with it until Fingbox came with an API
Btw to use the timerplans you do not need to have rooms. If you have Timer events based on devices, like "at sunset switch the lights on" on hue; when you change the timerplan, the timer is not there, either you can create a new timer or leave it as it is. Then when you go back to the previous timerplan, your previous sunset timer event is there again. You can change the current timerplan either by Settings/Other/Timer Plan dropbox, or with script as i did.
I have 2 timerplans. 1st one "At Home" has events assigned to devices with Timer buttons, like open shutters at 08:00 on shutter switch, switch on the lights at sunset on living room switch etc. The other time plan "Not At Home" has no timer events on none of the devices.
Re: Vacation-mode
Posted: Friday 22 September 2017 19:39
by EdwinK
febalci wrote: ↑Friday 22 September 2017 12:07
Code: Select all
if (devicechanged['FEB_Presence'] or devicechanged['DIB_Presence'] or devicechanged['HTB_Presence']) then
if (otherdevices['FEB_Presence'] == 'On' or otherdevices['DIB_Presence']== 'On' or otherdevices['HTB_Presence']== 'On') then
os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=4" &')
print("Family is Home")
else
os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=3" &')
print("Family is Away")
end
end
Need to alter this to us it just for me. My dog doesn't have a phone yet.
Re: Vacation-mode
Posted: Friday 22 September 2017 20:01
by febalci
You should find a life partner then
That would be as follows for one:
Code: Select all
commandArray = {}
if (devicechanged['Edwin_Presence']) then
if (otherdevices['Edwin_Presence'] == 'On') then
os.execute('curl -s "http://username:pass@domoticz_ip:domoticz_port/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=4" &')
print("Edwin is Home")
else
os.execute('curl -s "http://username:pass@domoticz_ip:domoticz_port/json.htm?type=command¶m=setactivetimerplan&ActiveTimerPlan=3" &')
print("Edwin is Away")
end
end
The places you should change is:
username:pass@domoticz_ip:domoticz_port - write your login info here
ActiveTimerPlan=4 and ActiveTimerPlan=3 : Write the IDX number of the TimerPlans you created. In my case Timerplan=4 is "At Home" plan, Timerplan=3 is "Not At Home" Plan which doesnot have any Timer events.
Re: Vacation-mode
Posted: Friday 22 September 2017 20:25
by EdwinK
I'm happy alone
But with above script, wouldn't it change the timerplan every time I'm leaving home?
Re: Vacation-mode
Posted: Saturday 23 September 2017 11:16
by febalci
Well, yes actually, i do not want my shutters or lights open or close when i'm not at home. You can complete the series with "When i come home, do this do that if it is after xx o'clock"
Re: Vacation-mode
Posted: Sunday 24 September 2017 11:53
by alexcf
Disclaimer: haven’t tried this yet..
I’m planning on using tiles which we have on our everything, bags, passport wallets etc. My thoughts are, if our passports are gone, I’d like to disable the boiler, then use google calendar to pick up when our holiday is “ending” and re-enable. Doesn’t work so well if my wife and I are travelling at the same time to different places. Either way, beacon on the dog might do it!
Sent from my iPhone using Tapatalk