Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Add a periodic guard 'only_every' #356

Open
boc-tothefuture opened this issue Oct 31, 2021 · 1 comment
Open

Add a periodic guard 'only_every' #356

boc-tothefuture opened this issue Oct 31, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@boc-tothefuture
Copy link
Owner

Add an additional guard type named 'only_every' that will prevent execution of the rule if it triggers again within that duration.

current:

rule 'Cycle HVAC fan for office' do 
    changed [Office_Temperature, Thermostats_Upstairs_Temp, Office_Occupied]
    run do 
        logger.debug("Turning on HVAC air cycle upstairs to balance temperature")
        Buttons_Circ_2nd.on
        last_run = now()
    end 
    only_if { (Office_Temperature - Thermostats_Upstairs_Temp).abs > '2 °F'}
    only_if Office_Occupied
    not_if  Thermostats_Upstairs_Status
    not_if Thermostats_Upstairs_Fan_Mode
    only_if { (now() - last_run) > 2.hours }
end

proposed:

rule 'Cycle HVAC fan for office' do 
    changed [Office_Temperature, Thermostats_Upstairs_Temp, Office_Occupied]
    run do 
        logger.debug("Turning on HVAC air cycle upstairs to balance temperature")
        Buttons_Circ_2nd.on
    end 
    only_if { (Office_Temperature - Thermostats_Upstairs_Temp).abs > '2 °F'}
    only_if Office_Occupied
    not_if  Thermostats_Upstairs_Status
    not_if Thermostats_Upstairs_Fan_Mode
    only_every 2.hours
end
@jimtng
Copy link
Collaborator

jimtng commented Oct 31, 2021

only_every gives the impression that it will perform at a regular interval similar to every. How about min_interval ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants