Very basic off/on with timer

Moderator: leecollings

Post Reply
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Very basic off/on with timer

Post by tontze »

Hi !

Im a blockly user, but blockly does not support seconds, so im out of luck there :/

Im looking for a very basic script, turning switch off->on defined number of times with defined interval. Is this done how ?

Thank you in advance :)
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Very basic off/on with timer

Post by snellejellep »

does the timer function of a switch not fill your needs?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Very basic off/on with timer

Post by tontze »

snellejellep wrote: Friday 28 August 2020 20:07 does the timer function of a switch not fill your needs?
Nope, i need seconds :) Otherwise i would have been doing it with blockly ..
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Very basic off/on with timer

Post by waaren »

tontze wrote: Friday 28 August 2020 20:43
snellejellep wrote: Friday 28 August 2020 20:07 does the timer function of a switch not fill your needs?
Nope, i need seconds :) Otherwise i would have been doing it with blockly ..
What should trigger the actions ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Very basic off/on with timer

Post by snellejellep »

you can do it in dzvents with for example <switchname>.switchOff().afterSec(5) which switches it off after 5 seconds
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Very basic off/on with timer

Post by tontze »

waaren wrote: Friday 28 August 2020 20:59
tontze wrote: Friday 28 August 2020 20:43
snellejellep wrote: Friday 28 August 2020 20:07 does the timer function of a switch not fill your needs?
Nope, i need seconds :) Otherwise i would have been doing it with blockly ..
What should trigger the actions ?
certain time of day, like 20:00, switch is on, then it switches off and on 6 times in 1 sec interval, and stays on.
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Very basic off/on with timer

Post by tontze »

snellejellep wrote: Friday 28 August 2020 21:00 you can do it in dzvents with for example <switchname>.switchOff().afterSec(5) which switches it off after 5 seconds
Il look in to it, thnx
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Very basic off/on with timer

Post by snellejellep »

tontze wrote: Friday 28 August 2020 22:00
snellejellep wrote: Friday 28 August 2020 21:00 you can do it in dzvents with for example <switchname>.switchOff().afterSec(5) which switches it off after 5 seconds
Il look in to it, thnx
this should do the trick, turning it on and off 6 times and then leaving it on at 20:00
i assumed it would be a lamp so called it that but you can fill in the name of the switch you want to use in place of yourlampnameoridx

Code: Select all

return {
    on ={
        timer={
            'at 20:00' -- the time at which this script should trigger
        }
    },

    execute = function(dz, device)
        
        local lamp          = dz.devices("yourlampnameoridx")
        
        lamp.switchOn()
        lamp.switchOff().afterSec(1)
        lamp.switchOn().afterSec(2)
        lamp.switchOff().afterSec(3)
        lamp.switchOn().afterSec(4)
        lamp.switchOff().afterSec(5)
        lamp.switchOn().afterSec(6)
        lamp.switchOff().afterSec(7)
        lamp.switchOn().afterSec(8)
        lamp.switchOff().afterSec(9)
        lamp.switchOff().afterSec(10)
        lamp.switchOn().afterSec(11)

    end
}
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Very basic off/on with timer

Post by waaren »

tontze wrote: Friday 28 August 2020 21:59 certain time of day, like 20:00, switch is on, then it switches off and on 6 times in 1 sec interval, and stays on.
dzVents version

Code: Select all

return 
{
	on = 
	{
		timer = 
		{
			'at 20:00',
		},
	},
	execute = function(dz)
	    light = dz.devices('Flicker')
	    for i = 0, 12, 2 do
	        light.switchOff().afterSec(i)
	        light.switchOn().afterSec(i + 1)
	    end     
	end
}
Classic Lua version (save with trigger type timer)

Code: Select all

local executionTime = '20:00'
local light = 'Flicker' -- Name of your light

commandArray = {}

if os.date('%H:%M') == executionTime then
     for i = 0, 12, 2 do
        commandArray[#commandArray + 1] = { [light] = 'Off AFTER ' .. i }
        commandArray[#commandArray + 1] = { [light] = 'On AFTER ' .. (i + 1) }
    end
end

return commandArray
Blockly (save with trigger type timer)
flickr.png
flickr.png (60.52 KiB) Viewed 895 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest