Page 1 of 1

Smart in a Month

Posted: Sunday 23 December 2018 16:36
by matteos1
Hi, I would like to create an action that allows me to turn on a xiaomi switch from 17 to 23 in a period from December 7th to January 7th of the following year. For periods not included, the switch remains off. Can someone help me?
thank you. The name of the switch is "SMart Christmas". Thank you

Re: Smart in a Month

Posted: Sunday 23 December 2018 17:36
by waaren
matteos1 wrote: Sunday 23 December 2018 16:36 Hi, I would like to create an action that allows me to turn on a xiaomi switch from 17 to 23 in a period from December 7th to January 7th of the following year. For periods not included, the switch remains off. Can someone help me?
thank you. The name of the switch is "SMart Christmas". Thank you
In dzVents it would look like

Code: Select all

local XiaomiOff = "at 23:00"
local XiaomiOn  = "at 17:00"

return {
    on = { timer = {XiaomiOn .. " on 7/12-31/12",XiaomiOn .. " on 1/1-7/1",XiaomiOff .. " on 7/12-31/12",XiaomiOff .. " on 1/1-7/1"}},
 
    execute = function(dz)
        smartCristmas = dz.devices("SMart Christmas")
        
        if dz.time.matchesRule(XiaomiOn) then
            smartCristmas.switchOn()
        else 
            smartCristmas.switchOff()
        end
    end
}


Re: Smart in a Month

Posted: Sunday 23 December 2018 17:47
by matteos1
ok now i check.

Re: Smart in a Month

Posted: Sunday 23 December 2018 17:54
by matteos1
waaren wrote: Sunday 23 December 2018 17:36
matteos1 wrote: Sunday 23 December 2018 16:36 Hi, I would like to create an action that allows me to turn on a xiaomi switch from 17 to 23 in a period from December 7th to January 7th of the following year. For periods not included, the switch remains off. Can someone help me?
thank you. The name of the switch is "SMart Christmas". Thank you
In dzVents it would look like

Code: Select all

local XiaomiOff = "at 23:00"
local XiaomiOn  = "at 17:00"

return {
    on = { timer = {XiaomiOn .. " on 7/12-31/12",XiaomiOn .. " on 1/1-7/1",XiaomiOff .. " on 7/12-31/12",XiaomiOff .. " on 1/1-7/1"}},
 
    execute = function(dz)
        smartCristmas = dz.devices("SMart Christmas")
        
        if dz.time.matchesRule(XiaomiOn) then
            smartCristmas.switchOn()
        else 
            smartCristmas.switchOff()
        end
    end
}

thre is an error here?
on = { timer = {XiaomiOn .. " on 7/12-31/12",XiaomiOn .. " on 1/1-7/1",XiaomiOff .. " on 7/12-31/12",XiaomiOff .. " on 1/1-7/1"}},

Re: Smart in a Month

Posted: Sunday 23 December 2018 18:59
by SweetPants
What's the error message?