Help needed with script

Moderator: leecollings

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

Help needed with script

Post by drwurn »

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 1678 times
niki_lauda
Posts: 117
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Help needed with script

Post by niki_lauda »

1.jpg
1.jpg (114.28 KiB) Viewed 1668 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: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep »

i use the timer section for this:
Image
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn »

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: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep »

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 vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
mrf68

Re: Help needed with script

Post by mrf68 »

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: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep »

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 vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn »

Let me know :)
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep »

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 vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help needed with script

Post by drwurn »

And and?
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Help needed with script

Post by snellejellep »

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 vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
rinyheuvelman
Posts: 15
Joined: Wednesday 19 December 2018 14:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10427
Contact:

Re: Help needed with script

Post by rinyheuvelman »

Although the claim of creating the script is over 18 months old, those who take the time and effort to help, deserve the credits for doing so!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests