I read some documentation and managed to use the Cron expression maker to create a rule that successfully turns on my gas heater in winter at 5.30am and off at 10.30am, Mon-Friday.
I’d like to turn it on at 7.30am and off at 10.30am on Saturday and Sundays. I know that I can just write another two rules, but perhaps theres a more intelligent/compact way of doing it within my existing rules?
Any thoughts?
rule "Turn Heater on in June/July/Aug @ 5.30am, Monday to Friday"
when
Time cron "0 30 5 ? 6-8 MON,TUE,WED,THU,FRI *"
then
Heater.sendCommand("HeaterOn")
end
rule "Turn Heater Off in June/July/Aug @ 10.30am, Monday to Friday"
when
Time cron "0 30 10 ? 6-8 MON,TUE,WED,THU,FRI *"
then
Heater.sendCommand("HeaterOff")
end
rule "Turn Heater on in June/July/Aug @ 5.30am, Mon to Fri in Winter"
when
Time cron "0 30 5 ? 6-8 MON,TUE,WED,THU,FRI *" or
// Turns on the Heater @ 7.30am, Sat to Sun
Time cron "0 30 7 ? 6-8 SAT,SUN *"
then
Heater.sendCommand("HeaterOn")
end
rule "Turn Heater Off in June/July/Aug @ 10.30am, Mon to Fri in Winter"
when
Time cron "0 30 10 ? 6-8 MON,TUE,WED,THU,FRI *"
then
Heater.sendCommand("HeaterOff")
end
Hi All, ive expanded this a little now to look at Temperature state however it doesnt appear to work.
The rules that relate to HeaterTimer ON & HeaterTimer Off, work correctly. But the rule which turns the heater on/off does not.
I can see the FibaroEye1Temp item is receiving updates and changing the temp. I wonder is this related to the use of a variable? currentTemp? This may actually not be needed as the FibaroEye1Temp is already a number as defined here:
rule "HeaterTimer ON"
when
Time cron "0 0 6-9 ? 6-8 MON,TUE,WED,THU,FRI *" or
Time cron "0 0 7-9 ? 6-8 SUN,SAT *"
then
HeaterTimer.postUpdate(ON)
end
rule "HeaterTimer OFF"
when
Time cron "0 0 9 ? 6-8 MON,TUE,WED,THU,FRI *" or
Time cron "0 0 9 ? 6-8 SUN,SAT *"
then
HeaterTimer.postUpdate(OFF)
end
rule "FibaroEye1 Temperature Controlled Gas Heater turns on when Temp is below 16°C. Turns off when temp is above 18°C"
when
Item FibaroEye1Temp received update
then
val currentTemp = FibaroEye1Temp.state as Number
if (HeaterTimer == ON) {
if (currentTemp < 16 ) {
Heater.sendCommand("HeaterOn")
logInfo("FibaroEye1Temp","Eye1 temp below 16°C, Turning on Heater")
} else if (currentTemp > 20) {
logInfo("FibaroEye1Temp", "Eye1 temp above 20°C, Turning off Heater")
Heater.sendCommand("HeaterOff")
}
} else if (HeaterTimer == OFF) {
if (Heater.state.toString == "HeaterOn") Heater.sendCommand("HeaterOff")
}
end