Scheduling with dzVents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
DannyElfman
Posts: 16
Joined: Monday 13 October 2014 14:05
Target OS: Linux
Domoticz version: 3.8136
Location: France
Contact:

Scheduling with dzVents

Post by DannyElfman »

Hi guys,

First, thanks again for these great tools (Domoticz+dzVents) !

I am not a coder. At all. Or I am the worst ever :)
But I try.
I have read the wiki in all directions and I lack some info (and scripting skills obviously).

I am building a script to switch on a device (zwave relay controlling my heating device) depending on the temperature. That I managed :)

And I want it on during specific period of the day. I did manage that part as well.

But, with my script, if the device is switched on 1 minute before the active timeframe ends, it will never be switched of ...

So I wanted to have a condition on the temperature and on the time but I just cannot figure it out ...

I went though this part of the wiki (https://www.domoticz.com/wiki/DzVents:_ ... ime_object) many times but I do not get it.

To be honest, I am not even capable to print in the log any value for domoticz.time

And I am not even sure this is the best way to go when I think about it ...

I ended up with switching the device to a non heating status using the timers button ....

Here is the disaster :

Code: Select all

return {

	active = true, 

	on = {
		timer = {
		    
			'every 10 minutes between 05:50 and 08:00',
			'every 10 minutes between 19:00 and 21:00'
		},
			},
	
	execute = function(domoticz, device)
			
		local sdbtemp = domoticz.devices(623) -- sdb temp
		local relais1 = domoticz.devices(236) -- sdb relais 1 mode confort si OFF et relais 2 off aussi
		local relais2 = domoticz.devices(243) -- relais 2 - toujours off.
		
		if (sdbtemp.temperature < 20 ) then
			relais1.switchOff()
			relais2.switchOff()
			domoticz.notify('Chauffage Sdb en mode confort')
		else  
		    relais1.switchOn()
		    relais2.switchOff()
		end
	end
}
Debian Jessie VM on EsxI on a Gen 8 Proliant + RFXCom + AeonLabs Zwave+ + Fibaro eye + Fibaro Smoke + Fibaro FGS211 Philips Hue + Harmony Hub + Somfy RTS + Oregon Temp sensors + Xiaomi Gateway + Xiaomi sensors + Sonoff basic
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Scheduling with dzVents

Post by BakSeeDaa »

It's not tested and with reservation for that I've understood the problem correctly, maybe you can try something like this:

Code: Select all

return {
	active = true,
	logging = {
		level = domoticz.LOG_DEBUG,
		marker = "sdb"
	},
	on = {
		timer = {
			'every 10 minutes between 05:50 and 08:00',
			'every 10 minutes between 19:00 and 21:00',
			'every 10 minutes',
		},
	},

	execute = function(domoticz, device, triggerInfo)

		local sdbtemp = domoticz.devices(623) -- sdb temp
		local relais1 = domoticz.devices(236) -- sdb relais 1 mode confort si OFF et relais 2 off aussi
		local relais2 = domoticz.devices(243) -- relais 2 - toujours off.

		if relais2.state == 'On' then relais2.switchOff() end

		domoticz.log('sdbtemp.temperature: '..tostring(sdbtemp.temperature), domoticz.LOG_DEBUG)
		domoticz.log('triggerInfo.trigger: '..triggerInfo.trigger, domoticz.LOG_DEBUG)

		local newState = 'On'

		if (sdbtemp.temperature < 20)
		or (triggerInfo.trigger == 'every 10 minutes') then
			newState = 'Off'
		end

		if relais1.state ~= newState then
			domoticz.log('Switching relais1 to: '..newState, domoticz.LOG_DEBUG)
			relais1.setState(newState)
			if newState == 'Off' then domoticz.notify('Chauffage Sdb en mode confort') end
		end
	end
}
DannyElfman
Posts: 16
Joined: Monday 13 October 2014 14:05
Target OS: Linux
Domoticz version: 3.8136
Location: France
Contact:

Re: Scheduling with dzVents

Post by DannyElfman »

Oops, I did not get any notification :p

First , thanks a lot for taking the time. I mean, A LOT !
Second, I of course understand it cannot be tested, no worries :) . I'm glad I have help so :)
Third, it is difficult for me to explain something which is not that clear so kudos to you if you go my point ^^

I will check it asap, and will come back with my findings.
Debian Jessie VM on EsxI on a Gen 8 Proliant + RFXCom + AeonLabs Zwave+ + Fibaro eye + Fibaro Smoke + Fibaro FGS211 Philips Hue + Harmony Hub + Somfy RTS + Oregon Temp sensors + Xiaomi Gateway + Xiaomi sensors + Sonoff basic
arkoko
Posts: 34
Joined: Saturday 17 December 2016 12:13
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Estonia
Contact:

Re: Scheduling with dzVents

Post by arkoko »

I think there overkill in proposed trigger condition:

Code: Select all

'every 10 minutes between 05:50 and 08:00',
'every 10 minutes between 19:00 and 21:00',
'every 10 minutes',
The last line makes first two useless.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Scheduling with dzVents

Post by BakSeeDaa »

arkoko wrote: Thursday 09 November 2017 17:01 I think there overkill in proposed trigger condition:

Code: Select all

'every 10 minutes between 05:50 and 08:00',
'every 10 minutes between 19:00 and 21:00',
'every 10 minutes',
The last line makes first two useless.
Not really.
The documentation wrote:dzVents lists the first timer definition that matches the current time. If there are more timer triggers that could have been triggering the script, dzVents only picks the first for this trigger property.
So,

Code: Select all

(triggerInfo.trigger == 'every 10 minutes')
will be true if none of the previously defined triggers has triggered. (E.g. it tells us that we are not within the specified time intervals and that will lead to setting the state of relais1 to 'Off')
DannyElfman
Posts: 16
Joined: Monday 13 October 2014 14:05
Target OS: Linux
Domoticz version: 3.8136
Location: France
Contact:

Re: Scheduling with dzVents

Post by DannyElfman »

Yep, that is how I understood it. But i did not get the time to put it in place yet. I will of course and will come back here to report :)
Debian Jessie VM on EsxI on a Gen 8 Proliant + RFXCom + AeonLabs Zwave+ + Fibaro eye + Fibaro Smoke + Fibaro FGS211 Philips Hue + Harmony Hub + Somfy RTS + Oregon Temp sensors + Xiaomi Gateway + Xiaomi sensors + Sonoff basic
arkoko
Posts: 34
Joined: Saturday 17 December 2016 12:13
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Estonia
Contact:

Re: Scheduling with dzVents

Post by arkoko »

Oh, I see ... I didn't notice usage of trigger info ((triggerInfo.trigger) in the script body.
Sorry.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest