Set Timer Active/Inactive script  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Set Timer Active/Inactive script

Post by gschmidt »

Hi,

I have a set a timer on a virtual switch (every weekday at 7.00 AM)
The switch triggers a node-red-contrib-castv2 node which sends a media stream to my google home mini's.
I use it as an media alarm to wake up.

But I also want to trigger the timer's active/inactive state with a second virtual switch (to voice control the Alarm to be active/inactive)
Is that possible with dzVents?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Set Timer Active/Inactive script

Post by waaren »

gschmidt wrote: Wednesday 11 March 2020 20:16 I have a set a timer on a virtual switch (every weekday at 7.00 AM)
I also want to trigger the timer's active/inactive state with a second virtual switch (to voice control the Alarm to be active/inactive)
You could try and use a openURL like (

Code: Select all

 domoticz.openURL(<domoticz ip:domoticz port>/json.htm?active=true&command=0&days=128&hour=0&idx=3&level=100&min=0&param=updatetimer&randomness=false&timertype=0&type=command)
or something similar but it is quite complicated to find the right parms for this openURL.

My approach would be to remove the timer of the switch and use the timer = trigger in dzVents for that.
It could look like.

Code: Select all

return 
{
    on = 
    {
        timer = 
        {
            'at 07:00',
        },
    },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'alarming',
    },

    execute = function(dz)
        if dz.devices('second virtual switch').active then 
            dz.devices('virtual switch').switchOn()
        else
            dz.log('No alarm needed today',dz.LOG_DEBUG)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
salvacalatayud
Posts: 112
Joined: Monday 26 June 2017 21:16
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Spain
Contact:

Re: Set Timer Active/Inactive script

Post by salvacalatayud »

Wouldn't it be better to use the alarm function on google home?
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Timer Active/Inactive script

Post by gschmidt »

waaren wrote: Thursday 12 March 2020 10:18 You could try and use a openURL like (

Code: Select all

 domoticz.openURL(<domoticz ip:domoticz port>/json.htm?active=true&command=0&days=128&hour=0&idx=3&level=100&min=0&param=updatetimer&randomness=false&timertype=0&type=command)
or something similar but it is quite complicated to find the right parms for this openURL.
Well I have tried a simple blockly script to activate/deactivate the timer of the virtual switch with a JSON http request (described on the wiki page)

Code: Select all

http://127.0.0.1:9090/json.htm?type=command&param=disabletimer&idx=243
http://127.0.0.1:9090/json.htm?type=command&param=enabletimer&idx=243
Also with 192.168.1.x (and I have added in the settings page the 127.0.0.*;192.168.1.* for local networks no login)
But I keep the error of opening the URL
My approach would be to remove the timer of the switch and use the timer = trigger in dzVents for that.
It could look like.

Code: Select all

return 
{
    on = 
    {
        timer = 
        {
            'at 07:00',
        },
    },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'alarming',
    },

    execute = function(dz)
        if dz.devices('second virtual switch').active then 
            dz.devices('virtual switch').switchOn()
        else
            dz.log('No alarm needed today',dz.LOG_DEBUG)
        end
    end
}
I will try your script this weekend
Last edited by gschmidt on Friday 13 March 2020 8:41, edited 1 time in total.
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Timer Active/Inactive script

Post by gschmidt »

salvacalatayud wrote: Thursday 12 March 2020 10:25 Wouldn't it be better to use the alarm function on google home?
In Dutch language it is not possible yet to set an Music Alarm for only weekdays
salvacalatayud
Posts: 112
Joined: Monday 26 June 2017 21:16
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Spain
Contact:

Re: Set Timer Active/Inactive script

Post by salvacalatayud »

I have my google mini in both spanish and english, if I need a function that is not possible in spanish I speak in english.
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Timer Active/Inactive script

Post by gschmidt »

salvacalatayud wrote: Friday 13 March 2020 9:25 I have my google mini in both spanish and english, if I need a function that is not possible in spanish I speak in english.
I know it is possible but the timer options in domoticz are more flexible to my needs....7.00 AM was just an example
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Timer Active/Inactive script  [Solved]

Post by gschmidt »

gschmidt wrote: Friday 13 March 2020 8:29
waaren wrote: Thursday 12 March 2020 10:18 My approach would be to remove the timer of the switch and use the timer = trigger in dzVents for that.
It could look like.

Code: Select all

return 
{
    on = 
    {
        timer = 
        {
            'at 07:00',
        },
    },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'alarming',
    },

    execute = function(dz)
        if dz.devices('second virtual switch').active then 
            dz.devices('virtual switch').switchOn()
        else
            dz.log('No alarm needed today',dz.LOG_DEBUG)
        end
    end
}
I will try your script this weekend
It is working...Thanx!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest