Help needed with script

Post Reply
drwurn
Posts: 42
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi
Domoticz version:
Contact:

Help needed with script

Post by drwurn » Monday 18 June 2018 19:58

What I want to accomplish is:

The light goes on at sunset, light goes out at 00:00
And the light goes on at 06:00 until sunrise. So these days the light stays out because sunrise is at 05:xx

Can't make it work.
Attachments
Screenshot_20180615-124857_Chrome.jpg
Screenshot_20180615-124857_Chrome.jpg (127.22 KiB) Viewed 892 times

niki_lauda
Posts: 145
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Help needed with script

Post by niki_lauda » Monday 18 June 2018 20:40

1.jpg
1.jpg (114.28 KiB) Viewed 882 times
Create a dummy switch Zonsopgang/or sunrise that switches a few minutes before sunrise or after if you like.
This is my script

snellejellep
Posts: 132
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep » Monday 18 June 2018 21:00

i use the timer section for this:
Image
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

drwurn
Posts: 42
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn » Thursday 21 June 2018 7:50

snellejellep wrote:
Monday 18 June 2018 21:00
i use the timer section for this:
Image
It doesn't work with the timer section. The light goes on at 06.00 while sunrise has been.

snellejellep
Posts: 132
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep » Thursday 21 June 2018 8:08

drwurn wrote:
Thursday 21 June 2018 7:50
It doesn't work with the timer section. The light goes on at 06.00 while sunrise has been.
that is an isssue a am having too, when i notice that sunrise is before 6:00 i turn off the timers that turn the lights on in the morning, you can see that in the screenshot i send.

so if someone does have a script that can do this, or maby, i can figure something out with dzvents.
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

User avatar
mrf68
Posts: 277
Joined: Monday 23 February 2015 13:45
Target OS: Windows
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Help needed with script

Post by mrf68 » Thursday 21 June 2018 8:44

To me, the blockly in the first post looks valid. “Can’t make it work” is too little info. Which part isn’t working? What does the log say at those specific moments that something should happen? For example: the log should say that the script has run at 00:00. Between 00:00 and 00:15 it should mention that 11 is turned off.

snellejellep
Posts: 132
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep » Thursday 21 June 2018 13:06

i just created this dzvents script, i am gonna test that one tonight since it is dependant on the sunrise and sunset :)

Code: Select all

return {
	on = {
		timer = { "at 1:00",
	              "at sunset",
	              "at sunrise",
	              "at 6:00"
	   }
	},
	execute = function(dz, device)
		
		local garden_lights     = dz.groups("Tuinverlichting")  --group used to switch multiple garden lights/switches
		local morningtime       = 360                           --time in minutes after midnight sunrise should be for the garden lights to turn on
		
		if dz.time.matchesRule("at sunset")  then
		    garden_lights.switchOn()
		elseif dz.time.matchesRule("at 1:00") then
		    garden_lights.switchOff()
		elseif (sunriseinMinutes > "morningtime")  and dz.time.matchesRule("at 6:00") then
		    garden_lights.switchOn()
		elseif dz.time.matchesRule("at sunrise") then
		    garden_lights.switchOff()
		end
		
	end
}
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

drwurn
Posts: 42
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn » Thursday 21 June 2018 21:24

Let me know :)

snellejellep
Posts: 132
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep » Thursday 21 June 2018 22:06

drwurn wrote:
Thursday 21 June 2018 21:24
Let me know :)
update: it dit turn on the lights, now lets see if they are off tomorrow morning :)
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

drwurn
Posts: 42
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn » Friday 22 June 2018 9:47

And and?

snellejellep
Posts: 132
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep » Friday 22 June 2018 9:55

it did work! it turned the garden lights off at 1:00

i only could not test the morning because obviously the sun rises way too early now :)
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests