- Platform information:
- Hardware: RP3 +
- OS: openhabian 2.4
Hello everyone, this is my first post on this forum, I hope my request is properly written.
Beginner on openhab, I try to create a rule that would allow me to activate some light scene based on the hours of detection of the presence of my phone via wifi and network binding.
For example if it is between 6 am and 7 am and phones are detect, activates the rule “atmosphere of the morning”,
If it is between 7am and 4pm activates the rule “evening atmosphere” etc …
I read this post which helped me partially, but I confess to being stuck:
https://community.openhab.org/t/execute-rule-during-certain-period-of-time/5440
Here are my items:
Group:Switch:OR(ON, OFF) Ambiance_Apero "apero" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_Matin "Ambiance Lumiere du matin" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_cosy "Ambiance cosy" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_TV "Ambiance TV" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_VP "Ambiance VP" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_Film_TV "Ambiance film TV" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_Diner "Ambiance diner" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_Pleine_lumiere "Pleine lumiere" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_Soir "Ambiance soir" (Ambiances_lumineuses) [ "Switchable" ]
Group:Switch:OR(ON, OFF) Ambiance_feutree "Ambiance faible" (Ambiances_lumineuses) [ "Switchable" ]
An example of one of my rule
rule "Ambiance rentree Matin"
when
Item G_Presence changed from OFF to ON
then
var Number hour = now.getHourOfDay
if ((hour >= 4) || (hour <= 8 )) {
sendCommand(Ambiance_Matin, ON)
}
else if ((hour >= 8 ) || (hour <= 16 )) {
sendCommand(Plafond_Entree_1, ON)
sendCommand(Plafond_Entree_3, ON)
}
else if ((hour >= 16) || (hour <= 21)) {
sendCommand(Ambiance_Soir, ON)
}
else if ((hour >= 21) || (hour <= 4)) {
sendCommand(Ambiance_cosy, ON)
}
end
rule "Ambiance cosy"
when
Item Ambiance_cosy received command ON
then
sendCommand(Niche_Droite, 10)
sendCommand(Niche_Gauche, 10)
sendCommand(Niche_Milieu,0)
sendCommand(Lumieres_TV, 15)
sendCommand(Plafond_Entree_2, 5)
sendCommand(Plafond_Entree_1, 0)
sendCommand(Plafond_Entree_3, 0)
sendCommand(Plafond_Entree_4, 0)
sendCommand(Plafond_Salle_A_Manger_1, 15)
sendCommand(Plafond_Salle_A_Manger_2, 0)
sendCommand(Plafond_Salle_A_Manger_3, 15)
sendCommand(ArcheDroite, 0)
sendCommand(ArcheGauche, 0)
sendCommand(ArcheMilieu, 15)
sendCommand(Lumieres_Cuisine, 20)
sendCommand(Lampe_Ambiance_Entree, 10)
sendCommand(Lampe_Ambiance_Entree_ColorTemperature, 80)
postUpdate(Lumieres, ON)
postUpdate(Ambiance_Apero, OFF)
postUpdate(Ambiance_Diner, OFF)
postUpdate(Ambiance_Matin, OFF)
postUpdate(Ambiance_Film_TV, OFF)
postUpdate(Ambiance_TV, OFF)
postUpdate(Ambiance_Pleine_lumiere, OFF)
postUpdate(Ambiance_Soir, OFF)
postUpdate(Ambiance_cosy, ON)
postUpdate(Ambiance_VP, OFF)
postUpdate(Ambiance_feutree, OFF)
end
the result is that it’s always the “ambiance_matin” which is triggered.
What i’m doing wrong?
Thank you for your help.