Switch item on every day in 06:30

I’d like to fire a rule if the time is 6:30 AM. Something like this, but this code does not work. Nothing in the logs.

rule "switch light on scheduled time"
when
    Item Plafond_Power received command OFF
then
    if(now.getHourOfDay == 6 && now.getMinuteOfHour == 30 ) // nothing
    // if(now.getHourOfDay >= 6 && now.getMinuteOfHour >= 30 ) nothing
      {
		Plafond_Power.sendCommand(ON)
		logInfo("XYZXYZ", "Plafond_Power is ON!") // nothing in events.log
      }
end

What’s wrong with this code? Why are the lights off? I don’t see a result in the logs.

I use:

  • Ubuntu Server 16.04
  • Kernel: x86_64 Linux 4.4.0-184-generic
  • openHAB 2.5.5 stable
  • Timezone checked. It’s OK.
  • Part of command date returns this: IDT
  • java -version: Zulu 8.46.0.19-CA-linux64
  • Tasmota 6.7.1

Another example.

rule "Cron Quartz Timer - Everyday 06:30"
when
     Time cron "0 30 6 1/1 * ? *"       
then
     if(Plafond_Power.state == OFF && ledXYD_power_auto.state == ON){
		Plafond_Power.sendCommand(ON)
		createTimer(now.plusSeconds(45))[|Plafond_Power.sendCommand(OFF)]
       }
end

This code works great. At the set time the lights are on. This means Plafond_Power is beyond suspicion, timezone too.

I don’t know JAVA. My one is PHP. I recently became interested in openHAB. I decided to share my achievements in Bulgarian on my blog (profruit.blogspot.com). The solution to this problem will be the occasion for another publication. Thanks in advance for the help.

Your rule will fire only if item Plafond_Power receives command OFF and if it is 6:30.
Cron rule is the better choice here.

2 Likes

Lightning response. Thanks.
I suspected so. Another option for Item Plafond_Power.

when
    Item Plafond_Power xxxxxxxxxxx
then

If you want the rule to be triggered by a specified time, you should only use cron.

4 Likes