Page 1 of 1
Need help with sunscreen script
Posted: Tuesday 09 October 2018 12:42
by drwurn
Since I can't make such a script with blockly cause of the multiple 'if' I need some help with dzvents. Did some reading on wiki and the forum but guess I'm not much of a script writer.
The weather conditions are from darksky
What I want to create is the following:
If
'zonnescherm' is closed
Time is between 11.30 and sunset
Date is between 1 april and 30 september
'Windsnelheid Assen' <8
'UV Index Assen' >1
'Regen voorspelling Assen' <1
Then
Set 'Zonnescherm' On
If 'Zonnescherm' is On and one of the conditions changing, 'Zonnescherm' should close. (Off)
Not sure if I'm missing something.
Who can help me with creating this?
Re: Need help with sunscreen script
Posted: Tuesday 09 October 2018 21:10
by waaren
drwurn wrote: ↑Tuesday 09 October 2018 12:42
Since I can't make such a script with blockly cause of the multiple 'if' I need some help with dzvents. Did some reading on wiki and the forum but guess I'm not much of a script writer.
- Spoiler: show
Code: Select all
If
'zonnescherm' is closed
Time is between 11.30 and sunset
Date is between 1 april and 30 september
'Windsnelheid Assen' <8
'UV Index Assen' >1
'Regen voorspelling Assen' <1
Then
Set 'Zonnescherm' On
If 'Zonnescherm' is On and one of the conditions changing, 'Zonnescherm' should close. (Off)
Who can help me with creating this?
Could be something like this
Code: Select all
-- sunProtection.lua
return {
on = { timer = {"every 10 minutes between 11:30 and 10 minute after sunset on 1/4-30/9"}},
logging = { level = domoticz.LOG_DEBUG,
marker = "Sunscreen" },
execute = function(dz)
local sunscreen = dz.devices(###) -- replace ### by your sunscreen device IDX
local windSpeed = dz.devices(###).speed -- replace ### by your virtual wind device IDX
local UV = dz.devices(###).uv -- replace ### by your virtual UV device IDX
local rainPrediction = tonumber(dz.devices(###).state) -- replace ### by your virtual rainprediction device IDX
local OnConditionsMet = sunscreen.state == "Open" and -- Maybe you need to reverse this to ~= or to "Closed"
windSpeed < 8 and
UV > 1 and
rainPrediction < 1 and
dz.time.matchesRule("between 11:30 and sunset")
if OnConditionsMet then
sunscreen.switchOff()
else
sunscreen.switchOn().checkFirst()
end
end
}
Re: Need help with sunscreen script
Posted: Tuesday 09 October 2018 23:48
by drwurn
waaren wrote: ↑Tuesday 09 October 2018 21:10
drwurn wrote: ↑Tuesday 09 October 2018 12:42
Since I can't make such a script with blockly cause of the multiple 'if' I need some help with dzvents. Did some reading on wiki and the forum but guess I'm not much of a script writer.
- Spoiler: show
Code: Select all
If
'zonnescherm' is closed
Time is between 11.30 and sunset
Date is between 1 april and 30 september
'Windsnelheid Assen' <8
'UV Index Assen' >1
'Regen voorspelling Assen' <1
Then
Set 'Zonnescherm' On
If 'Zonnescherm' is On and one of the conditions changing, 'Zonnescherm' should close. (Off)
Who can help me with creating this?
Could be something like this
Code: Select all
-- sunProtection.lua
return {
on = { timer = {"every 10 minutes between 11:30 and 10 minute after sunset on 1/4-30/9"}},
logging = { level = domoticz.LOG_DEBUG,
marker = "Sunscreen" },
execute = function(dz)
local sunscreen = dz.devices(###) -- replace ### by your sunscreen device IDX
local windSpeed = dz.devices(###).speed -- replace ### by your virtual wind device IDX
local UV = dz.devices(###).uv -- replace ### by your virtual UV device IDX
local rainPrediction = tonumber(dz.devices(###).state) -- replace ### by your virtual rainprediction device IDX
local OnConditionsMet = sunscreen.state == "Open" and -- Maybe you need to reverse this to ~= or to "Closed"
windSpeed < 8 and
UV > 1 and
rainPrediction < 1 and
dz.time.matchesRule("between 11:30 and sunset")
if OnConditionsMet then
sunscreen.switchOff()
else
sunscreen.switchOn().checkFirst()
end
end
}
That looks good.
I've spend the intire evening on this script.
Code: Select all
return {
on = {
timer = { 'on 1/4-30/9 between 11:30 and sunset' },
},
execute = function (domoticz, item)
if item.isTimer and
domoticz.devices('Test lamp').state == "On" and
domoticz.devices('UV Index Assen').uv >0 then
domoticz.devices('Dummy Zonnescherm').switchOn()
else
domoticz.devices('Dummy Zonnescherm').switchOff()
end
end
}
Still not finished and needs testing.
Also need to work out how to get a message when the sunscreen is set to off, and which variable causes it.
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 0:00
by waaren
drwurn wrote: ↑Tuesday 09 October 2018 23:48
Also need to work out how to get a message when the sunscreen is set to off, and which variable causes it.
Does this help ?
Code: Select all
-- sunProtection.lua
return {
on = { timer = {"every 10 minutes between 11:30 and 10 minute after sunset on 1/4-30/9"}},
logging = { level = domoticz.LOG_DEBUG,
marker = "Sunscreen" },
execute = function(dz)
local sunscreen = dz.devices(###) -- replace ### by your sunscreen device IDX
local windSpeed = dz.devices(###).speed -- replace ### by your virtual wind device IDX
local UV = dz.devices(###).uv -- replace ### by your virtual UV device IDX
local rainPrediction = tonumber(dz.devices(###).state) -- replace ### by your virtual rainprediction device IDX
local OnConditionsMet = sunscreen.state == "Open" and -- Maybe you need to reverse this to ~= or to "Closed"
windSpeed < 8 and
UV > 1 and
rainPrediction < 1 and
dz.time.matchesRule("between 11:30 and sunset")
if OnConditionsMet then
sunscreen.switchOff()
else
if sunscreen.state == "Closed " then
sunscreen.switchOn()
if windSpeed >= 8 then dz.notify(sunscreen.name .. " closed because of windspeed " .. windSpeed)
elseif UV <= 1 then dz.notify(sunscreen.name .. " closed because of UV " .. UV)
elseif rainPrediction >= 1 then dz.notify(sunscreen.name .. " closed because of rainPrediction " .. rainPrediction)
else dz.notify(sunscreen.name .. " closed because of timerule " )
end
end
end
end
}
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 19:03
by drwurn
I've made a dummy switch for the sunscreen for testing.
The dummy switch turned on this morning but didn't turn off after sunset or because of the UV rule
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 22:04
by waaren
drwurn wrote: ↑Wednesday 10 October 2018 19:03
I've made a dummy switch for the sunscreen for testing.
The dummy switch turned on this morning but didn't turn off after sunset or because of the UV rule
Can you check what the On / Off equivalent of "Open" is for your sunscreen and report back ?
What would also help is to add some log statements.
Thx
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 22:26
by drwurn
waaren wrote: ↑Wednesday 10 October 2018 22:04
drwurn wrote: ↑Wednesday 10 October 2018 19:03
I've made a dummy switch for the sunscreen for testing.
The dummy switch turned on this morning but didn't turn off after sunset or because of the UV rule
Can you check what the On / Off equivalent of "Open" is for your sunscreen and report back ?
What would also help is to add some log statements.
Thx
Open = On and Close = Off.
The sunscreen isn't responding at all with the script, without the script the screen works as normal. Double checked the IDX's and they're right.
- darksky.jpg (88.03 KiB) Viewed 3885 times
The log:
2018-10-10 22:18:00.410 Status: dzVents: Info: Sunscreen: ------ Start internal script: Zonnescherm:, trigger: every 1 minutes between 11:30 and 1 minute after 23:59 on 1/4-30/12
2018-10-10 22:18:00.446 Status: dzVents: Debug: Sunscreen: Processing device-adapter for Dummy Zonnescherm Forum: Switch device adapter
2018-10-10 22:18:00.447 Status: dzVents: Debug: Sunscreen: Processing device-adapter for Windsnelheid Assen: Wind device adapter
2018-10-10 22:18:00.449 Status: dzVents: Debug: Sunscreen: Processing device-adapter for UV Index Assen: UV device adapter
2018-10-10 22:18:00.450 Status: dzVents: Debug: Sunscreen: Processing device-adapter for Regen voorspelling Assen: Rain device
2018-10-10 22:18:00.450 Status: dzVents: Info: Sunscreen: ------ Finished Zonnescherm
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 22:38
by waaren
drwurn wrote: ↑Wednesday 10 October 2018 22:26
waaren wrote: ↑Wednesday 10 October 2018 22:04
drwurn wrote: ↑Wednesday 10 October 2018 19:03
I've made a dummy switch for the sunscreen for testing.
The dummy switch turned on this morning but didn't turn off after sunset or because of the UV rule
Can you check what the On / Off equivalent of "Open" is for your sunscreen and report back ?
What would also help is to add some log statements.
Thx
Open = On and Close = Off.
The sunscreen isn't responding at all with the script, without the script the screen works as normal. Double checked the IDX's and they're right.
At line 23 there is an extra space after the word Closed that does not belong there. Can you correct that and try again ?
Re: Need help with sunscreen script
Posted: Wednesday 10 October 2018 22:45
by drwurn
waaren wrote: ↑Wednesday 10 October 2018 22:38
drwurn wrote: ↑Wednesday 10 October 2018 22:26
waaren wrote: ↑Wednesday 10 October 2018 22:04
Can you check what the On / Off equivalent of "Open" is for your sunscreen and report back ?
What would also help is to add some log statements.
Thx
Open = On and Close = Off.
The sunscreen isn't responding at all with the script, without the script the screen works as normal. Double checked the IDX's and they're right.
At line 23 there is an extra space after the word Closed that does not belong there. Can you correct that and try again ?
Removed it but still don't work
Re: Need help with sunscreen script [Solved]
Posted: Thursday 11 October 2018 5:32
by waaren
drwurn wrote: ↑Wednesday 10 October 2018 22:26
... Removed it but still don't work
I Sent you a PM
Re: Need help with sunscreen script
Posted: Saturday 29 June 2019 21:33
by dendoba
And? Did you manage to get it working?
Re: Need help with sunscreen script
Posted: Friday 23 August 2019 20:22
by remko2000
good question: did you succeed???