Way to enable/disable whole switch schedule...

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
lost
Posts: 666
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Way to enable/disable whole switch schedule...

Post by lost »

Hello,

I've found no easy way to enable/disable whole shedule in a switch:
-There is the possibility to switch between 2 schedules (normal+vacations), this may help but does not really does the job (maybe done by having more shedules & mapping a selector virtual switch on them, indeed).
-Through the json api, there is a way to do this. But as every line in a schedule looks to be triggered by a timer (each with it's own timer idx) & json api uses timer idx this is not easy to invalidate all a switch schedule this way.
-Reading forum, I tried to use one sideway that alters to domoticz db directly: Looks successfull when looking at the enable statuses but sometimes, all schedules are set back to on! Probably it's not very sane to alter domoticz db while running: This may be cached somewere and previous enable statuses set back. Yesterday, I had to replace windows & used the virtual switch triggered scripts that invalidate all floor heaters plannings + sets them to off... but they restarted later because switches schedules were re-enabled.

So my question is: Is there a way to do this I may have missed (quite new to Domoticz)? If not, could it make it's way in the feature list for next version?

BR
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

Re: Way to enable/disable whole switch schedule...

Post by dressie »

*bump*
Did we ever find a solution to this?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Way to enable/disable whole switch schedule...

Post by waaren »

dressie wrote: Sunday 05 May 2019 9:20 *bump*
Did we ever find a solution to this?
I use different timerplans to do just this. To give an idea how this can work..:

Below dzVents script change the timerplans based on the content of a domoticz text-device. This ensure that we are not waked too early by blinds going up when we do not have to work :D

Code: Select all

--[[ SetTimerplan.lua 
 ]]-- 

 return {
   
    on      =   {   variables = { 'GCal*' } },
 
    logging =   {   level = domoticz.LOG_ERROR,                                      -- DEBUG, ERROR or INFO
                    marker = "setTimerPlan" },       
            
    execute = function(dz)
        dz.log ("Calender XXXX text: " .. dz.devices('Calender XXXX Text').text,dz.LOG_DEBUG)
        
        local function setTimerplan(timerPlan)
            local jsonString = dz.settings['Domoticz url'] ..  "/json.htm?type=command&param=setactivetimerplan&ActiveTimerPlan=" .. tostring(timerPlan)
            dz.openURL(jsonString)
            dz.variables('TimerPlan').set(timerPlan)
            newTimerPlan = timerPlan
        end

        local function inString(text, searchString)
            if string.find(string.lower( text),searchString ) ~= nil then 
                return true 
            else
                return false
            end    
        end
                    
        local XXXX         =  dz.devices('Calender XXXX Text').text -- Text from Google calendar
        local ZZZZ    =  dz.devices('Calender XXXX en YYYY Text').text
        local timerPlan     =  dz.variables('TimerPlan').value  
        local newTimerPlan  =  timerPlan
        
        if dz.time.matchesRule('at 22:00-02:00') then
            if (inString ( XXXX,"erken" ) or inString ( XXXX,"ursus" )) then
                setTimerplan(0)                                          -- XXXX at work so default TimerPlan
            elseif (inString ( ZZZZ,"holiday" ) or inString ( ZZZZ,"vakantie" )) and timerPlan ~= 1 then
                setTimerplan(1)                                                                         -- It is a Holiday 
            elseif timerPlan ~= 2 then 
                setTimerplan(2)          -- No Holiday but no working day either (including weekends)
            end
        end
        
        dz.log ("timerPlan:                 " .. newTimerPlan,dz.LOG_DEBUG)
        dz.log ("calendar XXXX:            " .. XXXX,dz.LOG_DEBUG)
        dz.log ("calendar XXXX en YYYY:    " .. ZZZZ,dz.LOG_DEBUG)
        
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
gizmocuz
Posts: 2552
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Way to enable/disable whole switch schedule...

Post by gizmocuz »

I suggest the following:

- Add a new Field in the DeviceStatus table, ScheduleActive (default true)
- In the "Edit Timer" GUI code, add a checkbox "Active" and use this to enable/disable all the timers of that device/switch
- When changing this checkbox, reload the schedules

Of course some code need to be adjusted as well to only load the timers if they are enabled for this device

And then of course a pull request on github would be appreciated
Quality outlives Quantity!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest