I have a question regarding the behavior of the rules at startup.
When I restart openhab (sudo service openhab restart) all the rules are executed while booting up.
This is very funny since all of the lights go totally crazy.
I have only 2 rules that should be executed at “System started”
rule “Reset permissions at startup”
when
System started
then
executeCommandLine(“chmod 777 /etc/openhab/configurations/scripts/*”)
logInfo(“Network”, “Resetting permissions on script:\n”)
end
rule “Update max and min temperatures”
when
Item Weather_Temperature changed or
Time cron “0 0/5 0 * * ?” or
System started
then
postUpdate(Weather_Temp_Max, Weather_Temperature.maximumSince(now.withTimeAtStartOfDay).state)
postUpdate(Weather_Temp_Min, Weather_Temperature.minimumSince(now.withTimeAtStartOfDay).state)
logInfo(“Weather”, “Temperature evolved of " + Weather_Temperature.deltaSince(now.minusMinutes(2)) + " degrees.”)
end
The rest of them should only be executed at other triggers.
e.g.
rule “Fenster geschlossen”
when
Item winsens_sleep_Open_Closed received update 0
then
logInfo(“Fensterbewegung”, “Das Schlafzimmerfenster wurde geschlossen”)
sendCommand(winsens_sleep_timer, OFF)
end
This isn’t a good fix. This is like having a hurt toe so you cut off your foot. Sure you solved the hurt toe but now you have other problems. The correct solution, as @Mpower has said, is to correct your rule triggers.
If it is binary you should use either a Contact Item whose states are OPEN and CLOSED or a Switch whose states are ON and OFF. Do not use a Number Item to store boolean values and do not use the numerical equivalents to OPEN/CLOSED/ON/OFF in your rules, particularly in your rule triggers. Your code will be easier to read, less prone to error and easier for us on the forum to help you with if you follow these conventions.
The main point that @Mpower is trying to get across is that you want your rules to trigger only when winsens_sleep_Open_Closed actually changes, not every time it receives an update indicates that the state of the Item has changed.