Countdown Rule not Working

I took a while to read the different posts about counters, timers and expire and ended up trying a variation of a solution @sam posted in Timer progress/remaining in sitemap.
I want to have it so If my Wemo Plug is Turned ON and the Office Light is OFF a countdown from 60min is started at the end of which the Wemo is Turned OFF (just in case I never end up going into the room ie got distracted) but if the Office Lights are turned on before the end of the countdown the countdown is to be canceled. Also When the Office Lights are Turned OFF if the Wemo Plug is ON a countdown from 60min is started at the end of which the Wemo is Turned OFF. I’d also like to display the countdown in basicUI when it is running.
Here’s what I wrote and thought should work:

Color Hue_Office_Light "Office Light" <slider> { channel="hue:0210:00178825acf3:9:color", autoupdate="false" }

Number Enail_Timer "Timer duration"
Number Enail_Timer_Remaining "Minutes Left till Powering Off  [%s]" 

Switch Wemo_Enail_Switch "Wemo E-nail Switch" <poweroutlet_us> { channel="wemo:socket:Socket-1_0-221710K010472B:state" }
sitemap main label="The Sanctum Sanctorum" 
{
Frame label="Office" {
		Switch item=Wemo_Enail_Switch icon="poweroutlet_us"
		Text  item=Enail_Timer_Remaining visibility=[Enail_Timer<60] icon="clock"
		Switch item=Hue_Office_Light label="Toggle" icon="light"
		Slider item=Hue_Office_Light label="Brightness"
		Colorpicker item=Hue_Office_Light label="Color" icon="colorpicker"
	}
}
import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*

import org.joda.time.*

var Timer timerEnail = null

rule "Initialize Enail switch on startup"
when
    System started
then
    sendCommand(Wemo_Enail_Switch, OFF)
    postUpdate(Enail_Timer,60)
end

rule "Turn Enail Off after 1hr"
when
    Item Wemo_Enail_Switch changed to ON
then
	if(Hue_Office_Light.state == OFF) {
		postUpdate(Enail_Timer,60)
	    val org.eclipse.xtext.xbase.lib.Functions$Function2 makeTimer = [
	        int myDelay,
	        org.eclipse.xtext.xbase.lib.Functions$Function2 makeTimer2 |
	            if(myDelay>0) {
	                postUpdate(Enail_Timer_Remaining, myDelay)
	                            // to save processes I only update UI once a minute
	                timerEnail=createTimer(now.plusMinutes(1)) [|
	                postUpdate(Enail_Timer_Remaining, myDelay-1)
	                makeTimer2.apply(myDelay-1, makeTimer2)
	                ]
	            }else {
	                // timer reach zero
	           		postUpdate(Enail_Timer,60)
	                // what I want to happen when the timer stops
	                sendCommand(Wemo_Enail_Switch, OFF)
	            }
	    ]
	
	    if(Hue_Office_Light.state == ON) {
	        timerEnail.cancel
	        timerEnail=null
	        postUpdate(Enail_Timer_Remaining,0)
	        postUpdate(Enail_Timer,60)
	    }
	
	    // extracts the value of the selection menu so you can set different times through the UI
	    var int int_Enail = (Enail_Timer.state as DecimalType).intValue
	
	    // updates the sitemap item straight away otherwise you have to wait 1 minute 
	    postUpdate(Enail_Timer_Remaining, int_Enail)
	
	        // what I want to happen at the start of the timer
	}
end

rule "Turn Enail Off 1hr after Light"
when
    Item Hue_Office_Light changed to OFF
then
	if(Wemo_Enail_Switch.state == ON) {
		postUpdate(Enail_Timer,60)
	    val org.eclipse.xtext.xbase.lib.Functions$Function2 makeTimer = [
	        int myDelay,
	        org.eclipse.xtext.xbase.lib.Functions$Function2 makeTimer2 |
	            if(myDelay>0) {
	                postUpdate(Enail_Timer_Remaining, myDelay)
	                            // to save processes I only update UI once a minute
	                timerEnail=createTimer(now.plusMinutes(1)) [|
	                postUpdate(Enail_Timer_Remaining, myDelay-1)
	                makeTimer2.apply(myDelay-1, makeTimer2)
	                ]
	            }else {
	                // timer reach zero
					postUpdate(Enail_Timer,60)
	                // what I want to happen when the timer stops
	                sendCommand(Wemo_Enail_Switch, OFF)
	            }
	    ]
	    
	    if(Hue_Office_Light.state == ON) {
	        timerEnail.cancel
	        timerEnail=null
	        postUpdate(Enail_Timer_Remaining,0)
	        postUpdate(Enail_Timer,60)
	    }
	
	    // extracts the value of the selection menu so you can set different times through the UI
	    var int int_Enail = (Enail_Timer.state as DecimalType).intValue
	
	    // updates the sitemap item straight away otherwise you have to wait 1 minute 
	    postUpdate(Enail_Timer_Remaining, int_Enail)
	
	        // what I want to happen at the start of the timer
	}
end

First, in openHAB2 you must not use the * in imports.
Second, I don’t use lambdas for defining functions myself, but I’m pretty sure this has to be done outside a rule.
Third, if using a function, you have to call it.
Fourth… please prefer the method item.sendCommand(value)/item.postUpdate(value) against the action sendCommand(item, value)/postUpdate(item, value), read this for further information.
a simple rule with countdowm would be like this:

var Timer tMyTimer = null
rule "timer with countdown"
when
    Item myItem received command ON
then
    myCountdown.postUpdate(60)
    if (tMyTimer !=null) 
        tMyTimer.cancel
    tMyTimer = createTimer(now.plusMinutes(1),[
        myCountdown.postUpdate((myCountdown.state as Number).intValue - 1)
        if ((myCountdown.state as Number).intValue !=0)
            tMyTimer.reschedule(now.plusMinutes(1))
        else
            myLight.sendCommand(OFF)
    ])
end

As long as myItem is retriggered with ON, the rule will restart the timer and reset the Countdown to 60. if there are no more triggers, the item myCountdown will be decremented once every minute.
When myCountdown reaches 0, the item myLight will be set to OFF.

Of course, you may want to stop the timer and reset the countdown when the light is switched off manually…

1 Like

@Udo_Hartmann Thank you this looks much more like what I expected from openHAB I apologize I tried to use an obviously outdated strategy I just wasn’t sure where to start. By the way I loved the link as I have done some time learning Java so that explanation was easy to follow and cleared up how openHAB handles somethings.
My only question is which loop do I add my secondary restriction to to interrupt the timer? As in when the office light is turned ON cancel the timer (which is meant for turning off a plug) or never start it if the office light was already ON. ATM your example would be turning off the wrong device and doesn’t pay attention to the state of the office light. I know starting with “if(Hue_Office_Light.state == OFF)” after Then would be my first check but I’m not sure which loop should be interrupt if the lights are turned on after the timer started. I can reverse the code with these restrictions to start a timer as soon as the lights are turned off if the plug is still on so I really would just appreciate a good nudge at where I should interrupt the active timer!

I tried my hand at interrupting the countdown but it won’t start even with the light off. I’m really not sure what is off with my version.

var Timer tMyTimer = null
rule "E-nail Power Off Timer"
when
    Item Wemo_Enail_Switch changed to ON
then
	if(Hue_Office_Light.state == OFF) {
	    Enail_Timer.postUpdate(60)
	    if (tMyTimer !=null) 
	        tMyTimer.cancel
	    tMyTimer = createTimer(now.plusMinutes(1),[
	    	if(Hue_Office_Light.state == OFF){
		        Enail_Timer.postUpdate((Enail_Timer.state as Number).intValue - 1)
		        if ((Enail_Timer.state as Number).intValue !=0)
		            tMyTimer.reschedule(now.plusMinutes(1))
		        else
		            Wemo_Enail_Switch.sendCommand(OFF) 
		     } else {
		     	tMyTimer.cancel
		     }
	    ]
	    )
	}
end

rule "Turn E-nail Off 1hr after Light"
when
    Item Hue_Office_Light changed to OFF
then
	if(Wemo_Enail_Switch.state == ON) {
	    Enail_Timer.postUpdate(60)
	    if (tMyTimer !=null) 
	        tMyTimer.cancel
	    tMyTimer = createTimer(now.plusMinutes(1),[
	    	if(Hue_Office_Light.state == OFF){
		        Enail_Timer.postUpdate((Enail_Timer.state as Number).intValue - 1)
		        if ((Enail_Timer.state as Number).intValue !=0)
		            tMyTimer.reschedule(now.plusMinutes(1))
		        else
		            Wemo_Enail_Switch.sendCommand(OFF) 
		     } else {
		     	tMyTimer.cancel
		     }
	    ]
	    )
	}
end

This part

else {
    tMyTimer.cancel
}

isn’t useful (in both rules), because the timer already ended, so no need to cancel the timer.

I’m afraid, I don’t see any obvious error in your code, I have no idea why the rule should not work as expected.
Are you sure that the rule file itself is ok? You should see a message in openhab.log about loading the rules file. If there is an error in the file, it wouldn’t be loaded at all and instead this openHAB should complain about issues in the rules file.

Ah, forgot to mention… maybe the trigger changed to ON isn’t working as expected?

When I get home I’ll check the logs. Will I have to tell openhab to start logging or is there a basic log? So far I havent implimented any logging my self because out side of this I usually have no need for logs of regular use. Also that else is supposed to match the

if(Hue_Office_Light.state == OFF){

Its point is to cancel the timer if the light is switched on while the timer is running! Is this in the wrong spot or should I cancel it a diffrent way if the lights are turned on during a running timer? I really need a way to interupt the timer if it has already started but hasnt reached 0.

Yes, and this part is ok, but the else{} part is useless, because the code is executed when the timer already expired!
As you can see, when the timer expired, the code checks if countdown reached the end, if not, the timer is rescheduled. the only thing not to let the timer run is to omit the reschedule :wink:

1 Like

How should I go about setting it up to not reschedule the timer if the lights are turned on while its already counting down? That’s why I had that in there I really need the timer to stop if it has already started and the Lights are turned ON. For instance if I turned my Plug ON from another room and the Light is OFF in the office the timer will start (just in case I never go to my office). Then if I go into my office and turn the Light ON the timer should be cleared and not rescheduled. I thought that line would cause this reaction.

The timer expires once a minute, and is only rescheduled when countdown is not 0…

@Udo_Hartmann Sorry I may have been quite confused I apologize I thought I need something to interrupt this line:

if ((Enail_Timer.state as Number).intValue !=0)
		            tMyTimer.reschedule(now.plusMinutes(1))

Was this next line enough to interrupt the count down any time the Light is turned ON? I thought this would only prevent the coutdown from starting. If it is enough to stop a countdown mid count shouldn’t I also be clearing the timer any time it doesn’t reschedule?

 tMyTimer = createTimer(now.plusMinutes(1),[
	    	if(Hue_Office_Light.state == OFF){

Edit
BTW here’s the error I’m getting in my log I’m not sure what it means but it comes up multiple times the second I switch my plug ON and at least once when I turn it OFF.

2017-08-21 17:02:23.561 [ERROR] [e.internal.WriterInterceptorExecutor] - MessageBodyWriter not found for media type=text/event-stream, type=class org.glassfish.jersey.media.sse.OutboundEvent, genericType=class org.glassfish.jersey.media.sse.OutboundEvent.

I’ve never seen this error…

In fact, one rule is enough:

var Timer tMyTimer = null

rule "E-nail Power Off Timer"
when
    Item Wemo_Enail_Switch changed to ON or                                         // Wemo E-nail switched on
    Item Hue_Office_Light changed to OFF                                            // Office Light switched off
then
    if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON) {            // Office Light is off but Wemo E-nail is on, and one of them changed state...
        Enail_Timer.postUpdate(60)                                                  // set Countdown
        if (tMyTimer !=null)                                                        // if the Coundown was already started
            tMyTimer.cancel                                                         // cancel timer to start over
        tMyTimer = createTimer(now.plusMinutes(1),[                                 // start timer for countdown once a minute
            if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON){     // when timer expired: Office Light off and Wemo E-nail still on? if yes,
                Enail_Timer.postUpdate((Enail_Timer.state as Number).intValue - 1)  // decrease counter and test
                if ((Enail_Timer.state as Number).intValue !=0)                     // counter = 0? if no, 
                    tMyTimer.reschedule(now.plusMinutes(1))                         // continue countdown
                else                                                                // if yes
                    Wemo_Enail_Switch.sendCommand(OFF)                              // switch Wemo E-nail off
            }                                                                       // Office Light not off or Wemo E-nail not on, so don't continue countdown (i.e. do nothing at all)
            // want to reset countdown: else Enail_Timer.postUpdate(0)
        ])
    }
end

I put statements to the code to explain the steps, hope that helps to understand.

One thing left: The counter would show remaining time “forever” (until it get’s started again), maybe this is not what you want, then… the else block would be correct, but only to set Countdown to a specific value, not(!) to cancel the timer, as the timer already expired.

1 Like

seems that jersey has something to do with RESTFUL API (from openHAB)

1 Like

That looks much more like what I wanted to be able to do from day one but I couldn’t find any reference to the ability to use OR so i just figured you couldn’t! Thank you so much I can understand it so much more now. Unfortunatly a 5 years break from coding made me a little rusty haha. Ill start looking into the error next. But first to be clear because I have this line in my sitemap

Text item=Enail_Timer visibility=[Enail_Timer<60] icon="clock"

Can I replace the line

// want to reset countdown: else Enail_Timer.postUpdate(0)

With

else Enail_Timer.postUpdate(60)

To alow it to stay invisible when not running?

Sure, but keep in mind, that the countdown starts with 60. You could even set the countdown to 61 and change visibility accordingly.

EDIT: Oh, no… when countdown is decreased, it never will turn to 61, so better use 0 as invisibility:

Text item=Enail_Timer visibility=[Enail_Timer>0] icon="clock"

So, if Countdown expired, it will switch E-nail off and turn invisible, if Countdown is stopped, it also will turn invisible.

1 Like

I’m sorry this is just running on but I really appreciate it. I understand rule structure quite clearly and think I have everything else from following the beginners guide and the openHAB docs.
So I’m going to code block every bit of detail I can here because with your last rule when tested brought up the timer at 60 but never decreased it and it will not clear if I turn on the light or turn off the plug. Seeing as I didn’t really change anything maybe I screwed up somewhere else.

items - trimmed to those involved

Color Hue_Office_Light "Office Light" <slider> { channel="hue:0210:00178825acf3:9:color", autoupdate="false" }

Number Enail_Timer "Minutes Left till Powering Off  [%s]"

Switch Wemo_Enail_Switch "Wemo E-nail Switch" <poweroutlet_us> { channel="wemo:socket:Socket-1_0-221710K010472B:state" }

sitemap - trimmed to part involved

sitemap main label="The Sanctum Sanctorum" 
{
	Frame label="Office" {
		Switch item=Wemo_Enail_Switch icon="poweroutlet_us"
		Text  item=Enail_Timer visibility=[Enail_Timer>0] icon="clock"
		Switch item=Hue_Office_Light label="Toggle" icon="light"
		Slider item=Hue_Office_Light label="Brightness"
		Colorpicker item=Hue_Office_Light label="Color" icon="colorpicker"
	}
}

enail_timer.rules

var Timer tMyTimer = null

rule "E-nail Power Off Timer"
when
    Item Wemo_Enail_Switch changed to ON or                                         // Wemo E-nail switched on
    Item Hue_Office_Light changed to OFF                                            // Office Light switched off
then
    if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON) {            // Office Light is off but Wemo E-nail is on, and one of them changed state...
        Enail_Timer.postUpdate(60)                                                  // set Countdown
        if (tMyTimer !=null)                                                        // if the Coundown was already started
            tMyTimer.cancel                                                         // cancel timer to start over
        tMyTimer = createTimer(now.plusMinutes(1),[                                 // start timer for countdown once a minute
            if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON){     // when timer expired: Office Light off and Wemo E-nail still on? if yes,
                Enail_Timer.postUpdate((Enail_Timer.state as Number).intValue - 1)  // decrease counter and test
                if ((Enail_Timer.state as Number).intValue !=0)                     // counter = 0? if no, 
                    tMyTimer.reschedule(now.plusMinutes(1))                         // continue countdown
                else                                                                // if yes
                    Wemo_Enail_Switch.sendCommand(OFF)                              // switch Wemo E-nail off
            }                                                                       // Office Light not off or Wemo E-nail not on, so don't continue countdown (i.e. do nothing at all)
            else Enail_Timer.postUpdate(0)
        ])
    }
end

events.log - entries during test Edit: to clarify I didn’t toggle it off and on like that I used BasicUI to turn Wemo_Enail_Switch On and I left it On for the whole test

2017-08-21 19:18:09.194 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from OFF to ON
2017-08-21 19:18:09.241 [ItemCommandEvent          ] - Item 'Wemo_Enail_Switch' received command ON
2017-08-21 19:18:09.417 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from ON to OFF
2017-08-21 19:18:09.811 [ItemStateChangedEvent     ] - wemo_socket_Socket_1_0_221710K010472B_state changed from OFF to ON
2017-08-21 19:18:09.814 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from OFF to ON
2017-08-21 19:18:27.020 [ItemStateChangedEvent     ] - network_device_192_168_0_20_time changed from 110.094308 to 314.427899
2017-08-21 19:19:26.930 [ItemStateChangedEvent     ] - network_device_192_168_0_20_time changed from 314.427899 to 223.211378
2017-08-21 19:20:26.712 [ItemStateChangedEvent     ] - network_device_192_168_0_20_time changed from 223.211378 to 3.029345
2017-08-21 19:20:58.964 [ItemCommandEvent          ] - Item 'Hue_Office_Light' received command ON
2017-08-21 19:21:05.081 [ItemStateChangedEvent     ] - hue_0210_00178825acf3_9_color changed from 216,5,0 to 216,5,100
2017-08-21 19:21:05.084 [ItemStateChangedEvent     ] - Hue_Office_Light changed from 216,5,0 to 216,5,100
2017-08-21 19:21:26.726 [ItemStateChangedEvent     ] - network_device_192_168_0_20_time changed from 3.029345 to 15.544321

openhab.log - Now has no issues after I restarted openHAB. I think it was because I moved my oldest enail_timer.rules to the root of /conf while I built a new one until I saw SmartHome Designer complaining. Must have caused some residual issues in openhab from that mistake until the restart.

Well… time for some debugging then… :slight_smile:

please add some logInfo to the code:

var Timer tMyTimer = null

rule "E-nail Power Off Timer"
when
    Item Wemo_Enail_Switch changed to ON or                                         // Wemo E-nail switched on
    Item Hue_Office_Light changed to OFF                                            // Office Light switched off
then
    logInfo ("enailTimer","rule started with Wemo {} and Hue {}",Wemo_Enail_Switch.state,Hue_Office_Light.state)
    if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON) {            // Office Light is off but Wemo E-nail is on, and one of them changed state...
        logInfo ("enailTimer","setting up Countdown")
        Enail_Timer.postUpdate(60)                                                  // set Countdown
        if (tMyTimer !=null)                                                        // if the Coundown was already started
            tMyTimer.cancel                                                         // cancel timer to start over
        tMyTimer = createTimer(now.plusMinutes(1),[                                 // start timer for countdown once a minute
            logInfo ("enailTimer","timer expired with Wemo {} Hue {} Countdown {}",Wemo_Enail_Switch.state,Hue_Office_Light.state,Enail_Timer.state)
            if(Hue_Office_Light.state == OFF && Wemo_Enail_Switch.state == ON){     // when timer expired: Office Light off and Wemo E-nail still on? if yes,
                Enail_Timer.postUpdate((Enail_Timer.state as Number).intValue - 1)  // decrease counter and test
                if ((Enail_Timer.state as Number).intValue !=0)                     // counter = 0? if no, 
                    tMyTimer.reschedule(now.plusMinutes(1))                         // continue countdown
                else                                                                // if yes
                    Wemo_Enail_Switch.sendCommand(OFF)                              // switch Wemo E-nail off
            }                                                                       // Office Light not off or Wemo E-nail not on, so don't continue countdown (i.e. do nothing at all)
            else Enail_Timer.postUpdate(0)
        ])
        logInfo ("enailTimer","Countdown started")
    }
end

Logging should apear at least in openhab.log.

To disable rules (if you want to save them…) please either move the file away from conf structure, rename files to rulename.rules.old (in fact, the only thing to do is to change the extension to something different to .rules) or mark them as a comment (use /* … first line of rule … last line of rule … */)

/*
This is a comment
and this
and also this
*/

This is no comment
// but this is a comment
This is no comment
1 Like

Alright here’s my logs after using that version of the rule. Tested by turning on the Wemo Plug while office Light was Off, waiting several minutes and then turning On the office light.

openhab.log -

2017-08-22 14:51:52.951 [INFO ] [se.smarthome.model.script.enailTimer] - rule started with Wemo ON and Hue 232,18,0
2017-08-22 14:51:54.151 [INFO ] [se.smarthome.model.script.enailTimer] - rule started with Wemo ON and Hue 232,18,0
2017-08-22 14:54:10.411 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 9314840 failed: null
2017-08-22 14:59:24.974 [INFO ] [se.smarthome.model.script.enailTimer] - rule started with Wemo ON and Hue 232,18,81

events.log

2017-08-22 14:51:52.958 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from OFF to ON
2017-08-22 14:51:53.011 [ItemCommandEvent          ] - Item 'Wemo_Enail_Switch' received command ON
2017-08-22 14:51:53.173 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from ON to OFF
2017-08-22 14:51:54.146 [ItemStateChangedEvent     ] - wemo_socket_Socket_1_0_221710K010472B_state changed from OFF to ON
2017-08-22 14:51:54.148 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from OFF to ON
2017-08-22 14:51:57.044 [ItemStateChangedEvent     ] - hue_0220_00178825acf3_2_brightness changed from 100 to 0
2017-08-22 14:51:57.045 [ItemStateChangedEvent     ] - Hue_Kitchen_Light changed from 100 to 0
2017-08-22 14:54:45.102 [ThingUpdatedEvent         ] - Thing 'kodi:kodi:4509294f-7927-c0fe-ff4a-c7e2cc53c6b0' has been updated.
2017-08-22 14:54:45.172 [hingStatusInfoChangedEvent] - 'kodi:kodi:4509294f-7927-c0fe-ff4a-c7e2cc53c6b0' changed from OFFLINE to ONLINE
2017-08-22 14:55:33.093 [ItemCommandEvent          ] - Item 'Hue_Office_Light' received command ON
2017-08-22 14:55:37.050 [ItemStateChangedEvent     ] - hue_0210_00178825acf3_9_color changed from 232,18,0 to 232,18,81
2017-08-22 14:55:37.051 [ItemStateChangedEvent     ] - Hue_Office_Light changed from 232,18,0 to 232,18,81
2017-08-22 14:55:42.972 [ThingUpdatedEvent         ] - Thing 'kodi:kodi:4509294f-7927-c0fe-ff4a-c7e2cc53c6b0' has been updated.
2017-08-22 14:59:24.757 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from ON to OFF
2017-08-22 14:59:24.823 [ItemCommandEvent          ] - Item 'Wemo_Enail_Switch' received command OFF
2017-08-22 14:59:24.971 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from OFF to ON
2017-08-22 14:59:24.975 [ItemStateChangedEvent     ] - wemo_socket_Socket_1_0_221710K010472B_state changed from ON to OFF
2017-08-22 14:59:24.976 [ItemStateChangedEvent     ] - Wemo_Enail_Switch changed from ON to OFF

I really don’t like how the wemo seems to be quickly turning back Off and then On again before staying on any time I turn it On. I can only assume this is either caused by the binding or the fact that almost all of my items seem to have doubles of each channel in the control part of paperUI but only under control. I assume this is because I enabled “Simple Mode” for Item Linking, I did this because the beginners guide said to but I wasn’t impressed to see the duplicates after following that same beginners guide to setup my first sitemap but I ignore it because I don’t use paperUI for controlling anything. Just setup and discovery!

So… the first thing is, even if the rule is fired (rule started…) there is no executed timer at all, because Hue is never ON or OFF but ends with 0 (brightness in percent)

As I don’t use Color Items, I’m not sure if there is an easy way to get ON/OFF state, but I think you could use this fragment instead:

if((Hue_Office_Light.state as HSBType).brightness == 0 && Wemo_Enail_Switch.state == ON) {   

Be aware to change both lines.

In question of toggling wemo switch, I guess this is the changing state of the item.

Unfortunately that doesn’t work SmartHome Designer didn’t even like it.The Error underlines these “.brightness == 0” and says :
Ambiguous binary operation. the operators declaration operator_equals(Number, Number) in NumberExtensions and operator_equals(Type, Number) in NumberExtensions both match.

It changed nothing in the logs. It started but did nothing. Can we not do something like this with wildcards? is there such a thing for this?

if(Hue_Office_Light.state == *.*.0 && Wemo_Enail_Switch.state == ON) {
if((Hue_Office_Light.state as HSBType).brightness.intValue == 0 && Wemo_Enail_Switch.state == ON) {