- Platform information:
- Hardware:RPI3
- openhab 2.4.0
Hello, I hope to find a solution.
I have set up my entire house, now I would like to go a little further in the persistence. but I can not understand the operation.
What I want to do:
my wife has an office in the dining room.
I want that when she turns on her computer, only some lights (ikea trafri binding) shine stronger, for that I arrive, thanks to the following rule below, and then when she turns off, lights came back to the previous mood light or previous state of light
/*laptop
rule "laptop ON"
when
Item Laptop changed from OFF to ON
if ((Lumieres.state == OFF) && (((hour >= 18) && (hour <= 23 )) || ((hour >= 4) && (hour <= 8 )))) {
logInfo("laptop ON", "laptop ON Ambiance bureau")
sendCommand(Bureau, ON)}
if (Lumieres.state == ON){
sendCommand(ArcheDroite, 100)
sendCommand(ArcheGauche, 100)
sendCommand(ArcheMilieu, 100)
sendCommand(Plafond_Salle_A_Manger_3, 100)
logInfo("laptop ON", "laptop ON Ambiance bureau")
}
end
my light moods are manage by rules like this one
rule "bureau"
when
Item Bureau received command ON
then
sendCommand(Plafond_Salle_A_Manger_3, 100)
sendCommand(Lumieres_Arche, 90)
postUpdate(Lumieres, ON)
postUpdate(Ambiance_Apero, OFF)
postUpdate(Ambiance_Diner, OFF)
postUpdate(Ambiance_Matin, OFF)
postUpdate(Ambiance_Film_Tele, OFF)
postUpdate(Ambiance_Tele, OFF)
postUpdate(Ambiance_Pleine_lumiere, OFF)
postUpdate(Ambiance_du_Soir, OFF)
postUpdate(Ambiance_cosy, OFF)
postUpdate(Ambiance_VP, OFF)
postUpdate(Ambiance_feutree, OFF)
postUpdate(Bureau, ON)
end
, I know, it would be simpler to do like this way :Design Pattern: What is a Design Pattern and How Do I Use Them
but mine is more comprehensive for my mind.
I understood that to recover a previous state I needed a persistence in openhab, so I install rr4dj, (maybe another type would be more appreciated for my case, I’m confused about it), I have configure the following way with the rrd4j.persist file in the persistence folder, this way:
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange
}
Items {
// persist items on every change and every minute
* : strategy = everyChange, everyMinute
Lumieres: strategy = everyChange
}
I also defined the default persistence in openhab
Some people advise to write something in the cfg file, but i’m not sure, so i didn’t touched it?
and now i’m stuck with my rule:
i don’t know what to do
convert to decimal type ?
restores (item.previous.state)?
when to store my value etc…
i tried this rule: but nothing happens:
rule "laptop OFF"
when
Item Laptop changed from ON to OFF
then
var LumieresStates = storeStates(Lumieres_Arche,Lumieres_PLafond_Salle_a_manger)
restoreStates(LumieresStates)
logInfo("laptop OFF", "laptop OFF Ambiance bureau")
postUpdate(Bureau, OFF)
end
i’m aware that this kind of topic is reccurent, i followed multiples topic about persistence, make multiples test, but i’m stuck on something that it sure i don’t understand. I need to understand. thx by advance.