Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Restore light states when system restart #1768

Closed
raditv opened this issue Nov 30, 2014 · 2 comments
Closed

Restore light states when system restart #1768

raditv opened this issue Nov 30, 2014 · 2 comments
Labels

Comments

@raditv
Copy link

raditv commented Nov 30, 2014

anyone has an example of rule, which I can use to restore my light state when the system restarted? I use gpio and mysensors devices for light relay. all gpio always turn on after system restart and all mysensors relay always turn off after system restart.

@raditv
Copy link
Author

raditv commented Nov 30, 2014

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"

    // if no strategy is specified for an item entry below, the default list will be used
    default = everyChange
}

/* 
 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).
 */
Items {
    // persist all items once a day and on every change and restore them from the db at startup
    // careful, this might result in huge databases - that's why it is in comment here ;-)
    // * : strategy = everyChange, everyDay, restoreOnStartup

    // persist all temperature and weather values at every change and every hour
    Temperature*, Weather_Chart*,Weather_Room_Chart*,Lux_Sensors_Chart* : strategy = everyChange, everyHour

    IN_Living*,IN_Bathroom*,IN_Bed* : strategy = everyUpdate, everyChange, everyDay, restoreOnStartup
}

that is my db40.persist

and this is my rule

rule "Initialize light states"
    when
        System started
    then
        Lights?.members.forEach(light|
            postUpdate(light, light.state)
        )
end

@nfnty
Copy link

nfnty commented Apr 6, 2015

I was able to hack together a fix for this problem:

rule "Initialize states"
when
    System started
then
    Lights?.members.forEach(member|
        postUpdate(member, member.historicState(now.minusSeconds(30)).state)
    )
end

Why isn't something similar to this the default starting behavior? Without this rule all my light states are updated to OFF during startup.

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

No branches or pull requests

3 participants