return { on = { devices = { 'Otwórz i zamknij bramę za...' } }, execute = function(domoticz) local shelly = domoticz.devices('Brama') local funkcjaBramy=domoticz.devices('Otwórz i zamknij bramę za...') local statusBramy=domoticz.devices('Status bramy') local czas_uch = 9 --uchylenie bramy 9s local czas_otw = 25 -- całkowite otwarcie 25s domoticz.log(statusBramy.state) if statusBramy.state=='Closed' then if (funkcjaBramy.state == 'Uchyl i zamknij po 15 sek') then shelly.switchOn().repeatAfterSec(czas_uch, 1) --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_uch+15) --else --domoticz.log('Brama zamknięta w międzyczasie --> '.. statusBramy.state) --end end if (funkcjaBramy.state == 'Uchyl i zamknij po 1 min') then shelly.switchOn().repeatAfterSec(czas_uch, 1) --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_uch+60) --end end if (funkcjaBramy.state == 'Uchyl i zamknij po 3 min') then shelly.switchOn().repeatAfterSec(czas_uch, 1) --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_uch + 180) --end end if (funkcjaBramy.state == 'Otwórz i zamknij po 1 min') then shelly.switchOn() --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_otw+60) --end end if (funkcjaBramy.state == 'Otwórz i zamknij po 5 min') then shelly.switchOn() --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_otw+300) --end end if (funkcjaBramy.state == 'Otwórz i zamknij po 10 min') then shelly.switchOn() --if statusBramy.state=='Open' then shelly.switchOn().afterSec(czas_otw+600) --end end else domoticz.log('Brama już otwarta - funkcja '.. funkcjaBramy.state ..' nieprzeprowadzona. Aktualny status bramy: --> '.. statusBramy.state) end funkcjaBramy.switchSelector(0).afterSec(2).silent() end }