Problem is that this is only updated every 15 minutes so there is a chance somebody opens the screen and it will stay open for up to 15 minutes before closing again.
I want to add in a device trigger of the actual roller shutter fibaro device.
This is my current script.
Wind is the IDX of the buienradar wind
Zonnescherm is the Fiaro Roller Shutter connected to the sunscreen.
I thought that I could just add Zonnescherm to devices but that does not really work because when I trigger the device it will stop opening but wil not close as it is continuously triggered so Z-Wave is flooded with close commands but not doing anything and I'm flooded with pushover messages that it is closing.
Code: Select all
local scriptVar = 'Close_Sunscreen'
local Wind = 4
local Zonnescherm = 552
return {
on = {
devices = {
Wind,
--Zonnescherm
},
httpResponses =
{
scriptVar,
},
},
logging = {
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(domoticz, device)
if device.isHTTPResponse then
domoticz.log(device.data,domoticz.LOG_DEBUG)
return
end
local function pushover(PushoverUser, PushoverApp, title, message, priority, sound)
domoticz.openURL({
url = 'https://api.pushover.net/1/messages.json',
method = 'POST',
callback = scriptVar,
postData =
{
token = PushoverApp.token,
user = PushoverUser.key,
message = message,
title = title or 'Pushover from dzVents',
priority = priority or 0,
sound = sound or 'echo',
},
})
end
local PushoverUsers =
{
['Martijn'] = { ['key'] = '--' },
['Nicky'] = { ['key'] = '--'},
['Familie'] = { ['key'] = '--'},
}
local PushoverApps =
{
['Huis'] = { ['token'] = '--' },
['Test'] = { ['token'] = '--' },
['Was'] = { ['token'] = '--' },
['Domoticz'] = { ['token'] = '--' },
['Alarm'] = { ['token'] = '--' },
}
if (domoticz.devices(Wind).gust > 9.0) then
domoticz.log('Current Wind Gust: ' .. domoticz.devices(Wind).gust, domoticz.LOG_DEBUG)
domoticz.log('More then 100 so closing screen', domoticz.LOG_DEBUG)
if (domoticz.devices(Zonnescherm).level ~= 100) then
pushover(PushoverUsers.Familie, PushoverApps.Huis, 'Zonnescherm', 'Te harde windvlagen: '.. domoticz.devices(Wind).gust .. 'm/s\nZonnescherm word ingeklapt 🌪', 0, 'pushover' )
domoticz.log('Closing screen', domoticz.LOG_DEBUG)
domoticz.devices(Zonnescherm).close()
end
end
if (domoticz.devices(Wind).speed > 7.0) then
domoticz.log('Current Wind speed: ' .. domoticz.devices(Wind).speed, domoticz.LOG_DEBUG)
domoticz.log('More then 100 so closing screen', domoticz.LOG_DEBUG)
if (domoticz.devices(Zonnescherm).level ~= 100) then
pushover(PushoverUsers.Familie, PushoverApps.Huis, 'Zonnescherm', 'Te harde wind: '.. domoticz.devices(Wind).speed .. 'm/s\nZonnescherm word ingeklapt 🌪', 0, 'pushover' )
domoticz.log('Closing screen', domoticz.LOG_DEBUG)
domoticz.devices(Zonnescherm).close()
end
end
end
}
Code: Select all
2022-05-11 16:00:48.810 Status: dzVents: Info: Close_Sunscreen: ------ Start internal script: DZ_Close_Sunscreen: Device: "Zonnescherm (Z-wave)", Index: 552
2022-05-11 16:00:48.811 Status: dzVents: Debug: Close_Sunscreen: Processing device-adapter for Wind: Wind device adapter
2022-05-11 16:00:48.811 Status: dzVents: Debug: Close_Sunscreen: Current Wind Gust: 12.0
2022-05-11 16:00:48.811 Status: dzVents: Debug: Close_Sunscreen: More then 100 so closing screen
2022-05-11 16:00:48.811 Status: dzVents: Debug: Close_Sunscreen: Closing screen
2022-05-11 16:00:48.811 Status: dzVents: Debug: Close_Sunscreen: Constructed timed-command: On
2022-05-11 16:00:48.814 Status: dzVents: Info: Close_Sunscreen: ------ Finished DZ_Close_Sunscreen
2022-05-11 16:00:48.815 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2022-05-11 16:00:48.946 Status: dzVents: Info: Close_Sunscreen: ------ Start internal script: DZ_Close_Sunscreen: Device: "Zonnescherm (Z-wave)", Index: 552
2022-05-11 16:00:48.947 Status: dzVents: Debug: Close_Sunscreen: Processing device-adapter for Wind: Wind device adapter
2022-05-11 16:00:48.947 Status: dzVents: Debug: Close_Sunscreen: Current Wind Gust: 12.0
2022-05-11 16:00:48.947 Status: dzVents: Debug: Close_Sunscreen: More then 100 so closing screen
2022-05-11 16:00:48.947 Status: dzVents: Debug: Close_Sunscreen: Closing screen
2022-05-11 16:00:48.947 Status: dzVents: Debug: Close_Sunscreen: Constructed timed-command: On
2022-05-11 16:00:48.950 Status: dzVents: Info: Close_Sunscreen: ------ Finished DZ_Close_Sunscreen
2022-05-11 16:00:48.952 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2022-05-11 16:00:49.097 Status: dzVents: Info: Close_Sunscreen: ------ Start internal script: DZ_Close_Sunscreen: Device: "Zonnescherm (Z-wave)", Index: 552
2022-05-11 16:00:49.099 Status: dzVents: Debug: Close_Sunscreen: Processing device-adapter for Wind: Wind device adapter
2022-05-11 16:00:49.099 Status: dzVents: Debug: Close_Sunscreen: Current Wind Gust: 12.0
2022-05-11 16:00:49.099 Status: dzVents: Debug: Close_Sunscreen: More then 100 so closing screen
2022-05-11 16:00:49.099 Status: dzVents: Debug: Close_Sunscreen: Closing screen
2022-05-11 16:00:49.099 Status: dzVents: Debug: Close_Sunscreen: Constructed timed-command: On
2022-05-11 16:00:49.102 Status: dzVents: Info: Close_Sunscreen: ------ Finished DZ_Close_Sunscreen
2022-05-11 16:00:49.104 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2022-05-11 16:00:49.333 Status: dzVents: Info: Close_Sunscreen: ------ Start internal script: DZ_Close_Sunscreen: Device: "Zonnescherm (Z-wave)", Index: 552
2022-05-11 16:00:49.335 Status: dzVents: Debug: Close_Sunscreen: Processing device-adapter for Wind: Wind device adapter
2022-05-11 16:00:49.335 Status: dzVents: Debug: Close_Sunscreen: Current Wind Gust: 12.0
2022-05-11 16:00:49.335 Status: dzVents: Debug: Close_Sunscreen: More then 100 so closing screen
2022-05-11 16:00:49.335 Status: dzVents: Debug: Close_Sunscreen: Closing screen
2022-05-11 16:00:49.335 Status: dzVents: Debug: Close_Sunscreen: Constructed timed-command: On
2022-05-11 16:00:49.338 Status: dzVents: Info: Close_Sunscreen: ------ Finished DZ_Close_Sunscreen