Easy to use, 100% Lua-based event scripting framework.
Moderator: leecollings
ilkaskim
Posts: 19 Joined: Friday 20 August 2021 2:20
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Germany
Contact:
Post
by ilkaskim » Monday 25 December 2023 22:06
Good evening, I have a problem with my script that I can't solve on my own. I've looked at many sites but haven't found the right one. My script opens my garage door when I work that day. Because I mostly ride my motorcycle, it's practically impossible to always reach for the remote control. So far I have done the automatic opening with my cell phone (Tasker). This made it possible for me to stop the automatic opening if I didn't finish work normally. Maybe someone knows better how I can stop the countdown.
Happy holidays
Code: Select all
return
{
on =
{
devices =
{
'Schichtkalender', -- Name of your device
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Schichtkalender',
},
execute = function(dz, item)
local variables = dz.variables('Schichtende')
if item.text == '' then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
dz.variables('Schichtende').set('0')
elseif variables.value == 1 then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
elseif item.text == 'Frühschicht' and variables.value == 0 then
dz.variables('Frühschicht').set('1')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
dz.devices('Rolltor Öffnen').switchOn().at('13:49')
elseif item.text == 'Spätschicht' and variables.value == 0 then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('1')
dz.variables('Nachtschicht').set('0')
dz.devices('Rolltor Öffnen').switchOn().at('21:49')
elseif item.text == 'Nachtschicht' and variables.value == 0 then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('1')
dz.devices('Rolltor Öffnen').switchOn().at('05:49')
end
end
}
waltervl
Posts: 5882 Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:
Post
by waltervl » Monday 25 December 2023 22:56
To cancel the countdown (or queue) you can use cancelQueuedCommands()
Eg
Code: Select all
dz.devices('Rolltor Öffnen').cancelQueuedCommands()
Next you need to discover that you used a tasker to open it. Perhaps you can send also a tasker command to set your user variable to a special state.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ilkaskim
Posts: 19 Joined: Friday 20 August 2021 2:20
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Germany
Contact:
Post
by ilkaskim » Monday 25 December 2023 23:25
waltervl wrote: ↑ Monday 25 December 2023 22:56
To cancel the countdown (or queue) you can use cancelQueuedCommands()
Eg
Code: Select all
dz.devices('Rolltor Öffnen').cancelQueuedCommands()
Next you need to discover that you used a tasker to open it. Perhaps you can send also a tasker command to set your user variable to a special state.
Thank you, that worked. I have modified the script so far. Using Tasker I send a variable (Schichtende) and the process aborts. Thank you
Code: Select all
return
{
on =
{
devices =
{
'Schichtkalender', -- Name of your device
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Kalender',
},
execute = function(dz, item)
local variables = dz.variables('Schichtende')
if item.text == '' then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
dz.variables('Schichtende').set('0')
elseif variables.value == 1 then
dz.devices('Rolltor Öffnen').cancelQueuedCommands()
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
dz.variables('Schichtende').set('0')
elseif item.text == 'Frühschicht' then
dz.variables('Frühschicht').set('1')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('0')
dz.devices('Rolltor Öffnen').switchOn().at('13:49')
elseif item.text == 'Spätschicht' then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('1')
dz.variables('Nachtschicht').set('0')
dz.devices('Rolltor Öffnen').switchOn().at('21:49')
elseif item.text == 'Nachtschicht' then
dz.variables('Frühschicht').set('0')
dz.variables('Spätschicht').set('0')
dz.variables('Nachtschicht').set('1')
dz.devices('Rolltor Öffnen').switchOn().at('05:49')
end
end
}
Users browsing this forum: No registered users and 1 guest