11master wrote: ↑Thursday 04 February 2021 23:00
I would like to achieve something like this in domoticz:
I turn on the switch / socket and then a window pops up with a choice of time from 1h to 24h.
I don't think this is possible in standard domoticz.
You can do something that gets close to this by creating a virtual selector with the various labels (headphones, toothbrush, car, etc.. ) and use a script to power the socket for the set time based on the selector level chosen.
in dzVents it could look like below script
__________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
___________________________________________________________________________________________________________________________
Code: Select all
return
{
on =
{
devices =
{
'socketTimer', -- change to name of selector
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is clock
marker = 'socket timer',
},
execute = function(dz, item)
dz.log('Selector ' .. item.name .. ' set to ' .. item.levelName, dz.LOG_DEBUG)
if item.levelName ~= 'Off' then
local socket = dz.devices('socket') -- change to name of socket / switch
choices =
{ -- levelName set time in minutes
Toothbrush = 840,
Car = 480,
Powerbank = 120,
}
if choices[item.levelName] then
socket.switchOn()
socket.switchOff().afterMin(item.levelName)
-- socket.switchOff().afterSec(choices[item.levelName] / 30) -- Test only
else
dz.log(item.levelName ..' is unknown; no time set', dz.LOG_ERROR)
end
item.switchSelector('Off').afterSec(2).silent() -- reset selector
end
end
}

- socket.png (35.19 KiB) Viewed 472 times