Hello @all,
I have tried to build a timer script by putting 2 selectors: 1) select your device and 2) select a time (15,30,60,120 mins)
Then a "start" button which starts the timer, and I put a blockly in place to manage the timing. It is working, but not very seamlessly..
As I am no Wizzard with scripting I reckon this should be done by a DZvents script, question is how? The principal is simple; set the two selectors and press start.. well at least in my mind it's not complex, but how to put this in a Script....
Wenn there is anyone who could give me a direction I woul dbe very Greatfull!
Building a Timer Script in DZvents
Moderator: leecollings
- waltervl
- Posts: 5846
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Building a Timer Script in DZvents
What should it do after you press start? Toggle the selected device after countdown?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 24
- Joined: Friday 06 September 2019 11:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Building a Timer Script in DZvents
Hey Walter, yes it should activate the device and deactivate it after the selected time frame.. The problem I have with Blockly is that the number of combinations possible (Let's say 10 devices and 5 possible time frames) makes the matter really "heavy" and extensive. I was thinking (but I'm not more than an noob in scripting) that with a DZvents-script the matter would be way more "thin" and smarter..
- waltervl
- Posts: 5846
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Building a Timer Script in DZvents
Something like this (not tested!!!!)
It assumes you have 3 devices:
1. 'Your Device Selector' with the list of devices and levelName should be exact device name
2. 'Your Timer Selector' with a list of timer options and levelname should be the timers in minutes
3 'Your Start Device' eg a Push On button switch.
Modify the names of in the script according your own devices.
It assumes you have 3 devices:
1. 'Your Device Selector' with the list of devices and levelName should be exact device name
2. 'Your Timer Selector' with a list of timer options and levelname should be the timers in minutes
3 'Your Start Device' eg a Push On button switch.
Modify the names of in the script according your own devices.
Code: Select all
return {
on = {
devices = {
'Your Start Device' -- this device triggers the timer script
}
},
execute = function(domoticz, switch)
-- Device that has the list of devices.
-- levelName should be exact device name.
local SelectedDevice = domoticz.devices('Your Device Selector').levelName
-- Device that has the list of timers eg 15,30,60,120
-- levelName should be the time in minutes.
local SelectedTimer = domoticz.devices('Your Timer Selector').levelName
domoticz.devices(SelectedDevice).switchOn() -- Switch the selected device on
domoticz.devices(SelectedDevice).switchOff().afterMin(tonumber(SelectedTimer)) -- Switch the device off after selected minutes
end
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 24
- Joined: Friday 06 September 2019 11:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Building a Timer Script in DZvents
Hey Walter,
Thanks a million, I will test this would be really cool when this solves my Timer Wish (and Blockly headache:) )
I will report back you you!
Thanks a million, I will test this would be really cool when this solves my Timer Wish (and Blockly headache:) )
I will report back you you!
-
- Posts: 24
- Joined: Friday 06 September 2019 11:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Building a Timer Script in DZvents
Good Morning Walter,
Looks like this works! Thanks! The "start button" is in this case a normal switch, I will test it with a pressing-button because I have to set the switch back manually. Should work i guess. Maybe a simple question; Can I make a copy of the script with a second "start" to be able to run a second timer?
Thanks, Bert
Looks like this works! Thanks! The "start button" is in this case a normal switch, I will test it with a pressing-button because I have to set the switch back manually. Should work i guess. Maybe a simple question; Can I make a copy of the script with a second "start" to be able to run a second timer?
Thanks, Bert
- waltervl
- Posts: 5846
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Building a Timer Script in DZvents
With the Edit button on the switch device widget you can change the type to PushOn.
Yes you can make a second script with different devices, no problem with that.
Yes you can make a second script with different devices, no problem with that.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest