i want to make a rule, whioch makes different things when a specific month is at that time:
Rule for jalousie/blinds:
If it is summer, then only open jalousie a little bit in the morning (only moving the angel of the lamellas)
if it is winter, open the whole jalousie - so that i can use sun heating
How can i do that? I know i can do that on top of the rule in the “when…”-part.
But can i do that on the “if-part” as well?
Here is my actual rule:
// Rollos morgens Astro hoch - wenn nach xx Uhr
rule "Rollos Astro hoch"
when
Item Rollos_astro_up received update ON
then
sendCommand(Rollos_is_day, ON)
if (SunriseLimit.state == ON) {
sendCommand(Rollos, UP)
sendCommand(Lamellen, 0)
}
end
Is something like this also working?
// Rollos morgens Astro hoch - wenn nach xx Uhr
rule "Rollos Astro hoch"
when
Item Rollos_astro_up received update ON
then
sendCommand(Rollos_is_day, ON)
if (SunriseLimit.state == ON) {
sendCommand(Rollos, UP)
if month=4-8
sendCommand(Lamellen, 0)
if month=9-3
sendCommand(Jalousie, 0)
}
end
I have same rules implemented. I use the weather and astro binding for it.
When the outside temp is below X and weather != sunny open blinds completly, otherwise only a bit.
With this implemention the blinds also open when its raining in summer.
I know that, but i don´t want to use weather binding. I sometimes get wired things from this, not like the weater is on my place at this moment. And sometimes weather changes very fast.
I made a proxy-switch-item for shading: Beschattung_Proxy
rule
// Beschattung ja
rule "Beschattung ja"
when
Time cron "* * * ? 5-9 *"
then
sendCommand(Beschattung_Proxy, ON)
end
// Beschattung nein
rule "Beschattung nein"
when
Time cron "* * * ? 10-4 *"
then
sendCommand(Beschattung_Proxy, OFF)
end
// Rollos morgens Astro hoch - wenn nach xx Uhr
rule "Rollos Astro hoch"
when
Item Rollos_astro_up received update ON
then
sendCommand(Rollos_is_day, ON)
if (SunriseLimit.state == ON) {
sendCommand(Rollos, UP)
if (Beschattung_Proxy == ON) {
sendCommand(Lamellen, 0)
}
if (Beschattung_Proxy == OFF {
sendCommand(Jalousien, UP)
}
}
end
I think it is workin now.
Can i do this in a better way? Maybe remove one of the rules?
rule "Jalousie auf am Morgen"
when
Item Sunrise_Event received update
then
//das Bad dreht am Morgen nur ein wenig auf
Jal_Bad.sendCommand(UP)
Thread::sleep(500) //Aufdrehen, 0.7s
Jal_Bad.sendCommand(STOP)
//wenn die Wettervorhersage sonnig Storen ostseitig nur aufgedreht
if(Current_Clouds.state <= 50) {
if ((Temp_Max_0.state > 15) && (Temp_Max_0.state < 28)) {
//Nach einer Pause das Büro
Jal_Buerau.sendCommand(UP)
Thread::sleep(200) //Aufdrehen, 0.3s
Jal_Buerau.sendCommand(STOP)
if (AnasSleep.state == OFF) {
Jal_Kinderzimmer.sendCommand(UP)
Thread::sleep(200)
Jal_Kinderzimmer.sendCommand(STOP)
}
}
// wenn die Aussentemperatur höher als 30° ist, bleiben die Storen ganz zu
if (Temp_Max_0.state > 28) {
}
}
if (Current_Clouds.state > 50) {
Jal_Buerau.sendCommand(UP)
if (AnasSleep.state == OFF) {
Jal_Kinderzimmer.sendCommand(UP)
}
}
end
This is actually pretty close to the Design Pattern I posted above. To make it a little more human readable and a little more flexible (i.e. have other rules that change their behavior based on the seasons) I would change your Proxy Item to a String and create a rule that populates that String with the season. Then in your rule:
This way you can actually get the calculation for when the season starts and stops very precisely if you want, and you can add new seasons or states if desired with minimal extra work.
I’ve found that when you set up a state Item like this you start to think of new ways you can use it.
If i use currHour - it will work with 24-time format? Like this?
if(currHour >= 10 && currHour <= 14)
EDIT:
Not working, i get the following error in the log:
[.script.engine.ScriptExecutionThread] - Rule 'Licht Eingang EG ein': An error occured during the script execution: The name 'currHour' cannot be resolved to an item or type.
Is there a way to get this working? Other way i have to do this with a proxy item and cron job i think? But it would be much better, if i can do it this way.