Page 1 of 1

Set Timer Active/Inactive script

Posted: Wednesday 11 March 2020 20:16
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?

Re: Set Timer Active/Inactive script

Posted: Thursday 12 March 2020 10:18
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
}

Re: Set Timer Active/Inactive script

Posted: Thursday 12 March 2020 10:25
by salvacalatayud
Wouldn't it be better to use the alarm function on google home?

Re: Set Timer Active/Inactive script

Posted: Friday 13 March 2020 8:29
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

Re: Set Timer Active/Inactive script

Posted: Friday 13 March 2020 8:30
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

Re: Set Timer Active/Inactive script

Posted: Friday 13 March 2020 9:25
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.

Re: Set Timer Active/Inactive script

Posted: Friday 13 March 2020 13:58
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

Re: Set Timer Active/Inactive script  [Solved]

Posted: Sunday 15 March 2020 11:19
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!