Smart in a Month

Moderator: leecollings

Post Reply
matteos1
Posts: 36
Joined: Monday 08 May 2017 17:29
Target OS: -
Domoticz version:
Contact:

Smart in a Month

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Smart in a Month

Post 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
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
matteos1
Posts: 36
Joined: Monday 08 May 2017 17:29
Target OS: -
Domoticz version:
Contact:

Re: Smart in a Month

Post by matteos1 »

ok now i check.
matteos1
Posts: 36
Joined: Monday 08 May 2017 17:29
Target OS: -
Domoticz version:
Contact:

Re: Smart in a Month

Post 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"}},
SweetPants

Re: Smart in a Month

Post by SweetPants »

What's the error message?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest