Vacation-mode Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Vacation-mode

Post 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.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Vacation-mode

Post by Egregius »

Link your domoticz to Google Calendar, make some appointments and your lights turn on :)
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Vacation-mode

Post 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 :)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
franzelare
Posts: 139
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Vacation-mode

Post 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
jannl
Posts: 625
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Vacation-mode

Post 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...
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Vacation-mode

Post 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.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Vacation-mode

Post by EdwinK »

So, now this work. Next thing, adding the times when the lights needs to turn on and off.

Back to reading again.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Vacation-mode

Post 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&param=setactivetimerplan&ActiveTimerPlan=4" &')
        print("Family is Home")
    else
        os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command&param=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...
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Vacation-mode

Post 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
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Vacation-mode

Post 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 :D

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.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Vacation-mode

Post 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&param=setactivetimerplan&ActiveTimerPlan=4" &')
        print("Family is Home")
    else
        os.execute('curl -s "http://username:[email protected]:8080/json.htm?type=command&param=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.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Vacation-mode

Post by febalci »

You should find a life partner then :D

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&param=setactivetimerplan&ActiveTimerPlan=4" &')
        print("Edwin is Home")
    else
        os.execute('curl -s "http://username:pass@domoticz_ip:domoticz_port/json.htm?type=command&param=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.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Vacation-mode

Post by EdwinK »

I'm happy alone ;)

But with above script, wouldn't it change the timerplan every time I'm leaving home?
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
febalci
Posts: 331
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Vacation-mode

Post 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"
alexcf
Posts: 3
Joined: Sunday 24 September 2017 10:37
Target OS: -
Domoticz version:
Contact:

Re: Vacation-mode

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest