Get/Store state of a Hue lightbulb

I’m really uncommitted to any particular method right now. I don’t know javascript so playing around with the example above I’m mostly just stumbling through it while tweaking things randomly to see how they work. I have experience writing perl scripts so if one method has similarities to perl then it would probably push me in that direction.

My concept:

If <this happens>
then <save state of thing A>
     change thing A to newState
     wait 2 seconds
     change thing A to anotherState
     wait 2 seconds
     change thing A back to saved state

I think those steps will handle everything I want to do and I can add or remove steps as necessary for differences in implementation.

Back when I was running OH2.5 I had something like this working in a text rule but did not have the saved state. The rule just turned the light off or left it on depending on whether the sun was up or not. I’d like to recreate that but add in the steps of saving the state and restoring at the end of the rule.

Right now I’m taking a state change from a Nanomote Scene number and playing an mp3 to a Sonos speaker, and then sending an ON to a relay switch to trigger a garage door to open or close. I’d like to add a Hue color bulb change to red (for a second or two), then green (for another second or two) then back return that Hue bulb to it’s previous state of color, saturation, and brightness.

Well, you kind of have to make a choice because I don’t have the time to show you all the possibilities in all the languages. Since you have some .rules files already…

Assuming it’s a Color Item

rule "blah blah blah"
when
    <something happens>
then
    val lastState = <NameOfLightItem>.state

    <NameOfLightItem>.sendCommand(<newState>)
    createTimer(now.plusSeconds(2), [ | <NameOfLightItem>.sendCommand(<anotherState>) ])
    createTimer(now.plusSeconds(4), [ | <NameOfLightItem>.sendCommand(lastState)])
end

Obviously the stuff marked with < > needs to be replaced with your Item name and triggers and such.

Review the rules docs for specifics on how to construct a rule in .rules files.

It’s better to use Timers than blocking sleeps so see Actions | openHAB for how to schedule something to happen in the future.

Not exactly what you want but maybe it works for you anyways: do you know the Hue binding offers a built-in alert for most bulb types, see Philips Hue - Bindings | openHAB. Link a String item and send the command LSELECT to it, it will make the bulb flash for 4-5 seconds - does the job.

This sounds very interesting but I’ve never had to “link a string item” before so I’m not sure how to do that. I tried sending the LSELECT command to a couple of Hue items and it didn’t work that way.

It’s an advanced channel so you have to check “Show advanced” to see it:

Once the alert item is created and linked to the alert channel, you’ll see a “None” box that you can click on it to test the alert:

You’ll get a menu with the options “Alert” (raw command: SELECT) and “Long Alert” (raw command: LSELECT) that you can send to the item via rules.

Found it now and got it working. It’s close to what I want. Playing with that and the code that Rich posted a bit ago.

Well I’m definitely getting close now. Put this together just to test it out fiddle with the settings and it’s mostly working the way I want.

rule "Color Cycle Lights"
when
    Item NanoMote_SceneNumber changed from 2.2 to 2.1
then
    val lastState = OfficeRoom_Color.state
    OfficeRoom_Color.sendCommand("1,100,100")
    createTimer(now.plusSeconds(1), [ | OfficeRoom_Color.sendCommand("140,100,50") ])
    createTimer(now.plusSeconds(2), [ | OfficeRoom_Color.sendCommand("250,100,50") ])
    createTimer(now.plusSeconds(3), [ | OfficeRoom_Color.sendCommand("0,0,0") ])
    createTimer(now.plusSeconds(4), [ | OfficeRoom_Color.sendCommand(lastState) ])
end

The HUE led strip turns on red, then green, then blue, then off but doesn’t revert to the previous state at the end and I get this in the openhab.log:

2021-05-18 15:00:45.543 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job failed and stopped
java.lang.IllegalStateException: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1209) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1167) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1153) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:1098) ~[?:?]
	at org.openhab.core.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:151) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:878) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:243) ~[?:?]
	at org.openhab.core.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:475) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:251) ~[?:?]
	at org.openhab.core.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:213) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:47) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:30) ~[?:?]
	at com.sun.proxy.$Proxy427.apply(Unknown Source) ~[?:?]
	at org.openhab.core.model.script.actions.ScriptExecution.lambda$0(ScriptExecution.java:82) ~[?:?]
	at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:184) ~[?:?]
	at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:87) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@3ccb6aa4
	at jdk.internal.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1192) ~[?:?]
	... 25 more

It should be able to handle that as written. But based on the error it doesn’t seem to understand the HSBType.

Try this:

val lastState as OfficeRoom_Color.state as HSBType

If that doesn’t work try

Office_Color.sendCommand(lastState.toString)

For some reason it can’t figure out what the lastState is. NOTE: there will be a similar error if lastState is NULL or UNDEF. If neither of the above work double check that the Item isn’t NULL.

Note, instead of sending “0,0,0” you can sendCommand(OFF).

Here’s the testing rule that works now. Got errors when I tried the first suggestion, it didn’t like the “as” being in there. Typo in the val line you sent. Should be “val lastState = Office…”

I did test both suggestions and it appears that either will work by themselves or together.

rule "Color Cycle Lights"
when
    Item NanoMote_SceneNumber changed from 2.2 to 2.1
then
    val lastState = OfficeRoom_Color.state  
    OfficeRoom_Color.sendCommand("1,100,100")
    createTimer(now.plusSeconds(1), [ | OfficeRoom_Color.sendCommand("140,100,50") ])
    createTimer(now.plusSeconds(2), [ | OfficeRoom_Color.sendCommand("250,100,50") ])
    createTimer(now.plusSeconds(3), [ | OfficeRoom_Color.sendCommand(OFF) ])
    createTimer(now.plusSeconds(4), [ | OfficeRoom_Color.sendCommand(lastState.toString)])
end
1 Like

Hi Steve

Did you confirm that the light goes back to the initial state?

I have tried with a similar rule (modified with my devices). However it seems that my Hue Group somehow affects the individual light and as a result the specific light does not go back to what the initial state was?

Logs as follows:

12:03:46.981 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command ON
12:03:46.981 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from OFF to ON
12:03:48.008 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 1,100,100
12:03:48.008 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 1,100,100
12:03:48.008 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 1,100,100
12:03:49.178 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 140,100,50
12:03:49.178 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 140,100,50
12:03:49.194 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 1,100,100 to 140,100,50
12:03:50.215 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 250,100,50
12:03:50.215 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 250,100,50
12:03:50.215 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 140,100,50 to 250,100,50
12:03:52.050 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command OFF
12:03:52.050 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from ON to OFF
12:03:52.254 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 78,71,85
12:03:52.254 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 78,71,85
12:03:52.254 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 250,100,50 to 78,71,85

12:03:56.533 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 65,73,85
12:03:56.548 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 78,71,85 to 0,0,85
12:03:56.548 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_ColorTemperature' changed from 75 to 0

I can’t work out what causes the last three events?

Any suggestions?
Mark

This is a guess by autoupdate.

Some time later …

a real report from the device, causes another Item change because it doesn’t match the guess.
Maybe the device has different granularity/steps in its internal values. Maybe its ramping and this is an intermediate report before it reaches final values.

The last three log entries seem to happen after the rule has completed? The rest of the lights remain in the initial state, however the affected light does not go back to the state it should?

Rule with some logging:

rule "Color Cycle Lights"
when
    Item Testing_Switch changed to ON
then
    val lastState = Huecolorspot4_Color.state 
    logWarn("Hue", "lastState " + lastState  )
    //Huecolorspot4_Color.sendCommand(ON)
    createTimer(now.plusSeconds(1), [ | 
        Huecolorspot4_Color.sendCommand("1,100,100") 
        logWarn("Hue", "State 1 " + Huecolorspot4_Color.state  ) 
        ])
    createTimer(now.plusSeconds(2), [ | 
    Huecolorspot4_Color.sendCommand("140,100,50") 
    logWarn("Hue", "State 2 " + Huecolorspot4_Color.state  )
        ])
    createTimer(now.plusSeconds(3), [ | 
    Huecolorspot4_Color.sendCommand("250,100,50") 
    logWarn("Hue", "State 3 " + Huecolorspot4_Color.state  )
        ])
    //createTimer(now.plusSeconds(4), [ | Huecolorspot4_Color.sendCommand(OFF) ])
    createTimer(now.plusSeconds(5), [ | 
    Huecolorspot4_Color.sendCommand(lastState.toString)
    logWarn("Hue", "Reset " + Huecolorspot4_Color.state  )
        ])

end

Logs:

12:54:39.788 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command ON
12:54:39.788 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from OFF to ON
12:54:39.804 [WARN ] [org.openhab.core.model.script.Hue    ] - lastState 78,71,85
12:54:40.811 [WARN ] [org.openhab.core.model.script.Hue    ] - State 1 78,71,85
12:54:40.811 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 1,100,100
12:54:40.811 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 1,100,100
12:54:40.811 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 1,100,100
12:54:41.881 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 140,100,50
12:54:41.881 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 140,100,50
12:54:41.881 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 1,100,100 to 140,100,50
12:54:41.881 [WARN ] [org.openhab.core.model.script.Hue    ] - State 2 140,100,50
12:54:42.873 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 140,100,50 to 139,100,50
12:54:42.936 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 78,71,85 to 0,0,81
12:54:42.936 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 85 to 81
12:54:42.936 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_ColorTemperature' changed from 75 to 0
12:54:42.952 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 250,100,50
12:54:42.952 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 250,100,50
12:54:42.967 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 139,100,50 to 250,100,50
12:54:42.967 [WARN ] [org.openhab.core.model.script.Hue    ] - State 3 250,100,50
12:54:45.040 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 78,71,85
12:54:45.042 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 78,71,85
12:54:45.046 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 250,100,50 to 78,71,85
12:54:45.048 [WARN ] [org.openhab.core.model.script.Hue    ] - Reset 78,71,85
12:54:45.406 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command OFF
12:54:45.406 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from ON to OFF
12:54:52.925 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 77,70,85
12:54:52.989 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 0,0,81 to 0,0,85
12:54:52.989 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 81 to 85
12:55:02.985 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 77,70,85 to 65,73,85

These ar ethe once I don’t understand the source of:

12:54:52.925 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 77,70,85
12:54:52.989 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 0,0,81 to 0,0,85
12:54:52.989 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 81 to 85
12:55:02.985 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 77,70,85 to 65,73,85

I’ve only implemented this against single lights so far. My rules reference the Hue Room but in my case that’s just a single bulb. I’ll experiment with a room that has multiple bulbs later today after the wife goes to work. (Far too early and not nearly enough coffee so far to annoy her with lights going on and off.)

Added: But so far yes, my tests have seen that the lights do revert back to whatever state they were in before the actions fired off.

1 Like

I don’t know how else to put it

observe the timestamps. It’s taking the hues some time to respond to the last command

Thanks, but the last command was logged as: Item 'Huecolorspot4_Color' changed from 250,100,50 to 78,71,85

The initial saved state was 78,71,85

Added some logging:

rule "Color Cycle Lights"
when
    Item Testing_Switch changed to ON
then
    val lastState = Huecolorspot4_Color.state 
    logWarn("Hue", "lastState " + lastState  )
    //Huecolorspot4_Color.sendCommand(ON)
    createTimer(now.plusSeconds(1), [ | 
        Huecolorspot4_Color.sendCommand("1,100,100") 
        logWarn("Hue", "State 1 " + Huecolorspot4_Color.state  ) 
        ])
    createTimer(now.plusSeconds(2), [ | 
    Huecolorspot4_Color.sendCommand("140,100,50") 
    logWarn("Hue", "State 2 " + Huecolorspot4_Color.state  )
        ])
    createTimer(now.plusSeconds(3), [ | 
    Huecolorspot4_Color.sendCommand("250,100,50") 
    logWarn("Hue", "State 3 " + Huecolorspot4_Color.state  )
        ])
    //createTimer(now.plusSeconds(4), [ | Huecolorspot4_Color.sendCommand(OFF) ])
    createTimer(now.plusSeconds(5), [ | 
    Huecolorspot4_Color.sendCommand(lastState.toString)
    logWarn("Hue", "Reset " + Huecolorspot4_Color.state  )
    logWarn("Hue", "Rules Done... " )
        ])
logWarn("Hue", "Rule Exit... " )
end
14:03:31.651 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command ON
14:03:31.760 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from OFF to ON
14:03:31.869 [WARN ] [org.openhab.core.model.script.Hue    ] - lastState 78,71,85
14:03:32.158 [WARN ] [org.openhab.core.model.script.Hue    ] - Rule Exit... 
14:03:32.891 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 1,100,100
14:03:32.891 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 1,100,100
14:03:32.891 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 1,100,100
14:03:32.891 [WARN ] [org.openhab.core.model.script.Hue    ] - State 1 78,71,85
14:03:33.990 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 140,100,50
14:03:33.991 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 140,100,50
14:03:33.995 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 1,100,100 to 140,100,50
14:03:33.998 [WARN ] [org.openhab.core.model.script.Hue    ] - State 2 140,100,50
14:03:34.741 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 140,100,50 to 139,100,50
14:03:34.803 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 78,71,85 to 0,0,81
14:03:34.803 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 85 to 81
14:03:34.803 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_ColorTemperature' changed from 75 to 0
14:03:35.087 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 250,100,50
14:03:35.087 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 250,100,50
14:03:35.087 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 139,100,50 to 250,100,50
14:03:35.087 [WARN ] [org.openhab.core.model.script.Hue    ] - State 3 250,100,50
14:03:36.759 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Testing_Switch' received command OFF
14:03:36.759 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Testing_Switch' changed from ON to OFF
14:03:37.182 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Huecolorspot4_Color' received command 78,71,85
14:03:37.182 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Huecolorspot4_Color' predicted to become 78,71,85
14:03:37.182 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 250,100,50 to 78,71,85
14:03:37.182 [WARN ] [org.openhab.core.model.script.Hue    ] - Reset 78,71,85
14:03:37.182 [WARN ] [org.openhab.core.model.script.Hue    ] - Rules Done...
14:03:44.792 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 77,70,85
14:03:44.861 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 0,0,81 to 0,0,85
14:03:44.861 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 81 to 85
14:03:54.839 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 77,70,85 to 65,73,85

So it appears these events happen after the end of processing rules and Timer:

14:03:44.792 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 78,71,85 to 77,70,85
14:03:44.861 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Color' changed from 0,0,81 to 0,0,85
14:03:44.861 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LoungeRoom_Brightness' changed from 81 to 85
14:03:54.839 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Huecolorspot4_Color' changed from 77,70,85 to 65,73,85

Yes, that’s what I’m trying to tell you.

The last update is the device reporting its state. I couldn’t tell you if that is in direct response to the last command, or a periodic report. Nor can I tell you if that is some final setting, or it is an in-progress report while it is still ramping to some new final setting. You’d need to find out more about your hue device.

What problem is this giving you?

The idea was to use the single light to indicate an alarm of some sort - UPS Low battery is my plan.

So as per the previous discussion:

Save the current state of the light
Flash the light through colours etc
Restore the previous state of the light.

In my case the light is a part of a room.

So if the room lights are on, the single lights does what is required - but does not get restored to the previous state and ends up as a different colour.

If the lights start off being off, when the lights are next turned on the single light is a different colour,

Your log shows you that the last command you send to the lamp is exactly the state that you began with.

What’s the relationship to these other Items churning about?

As the hue seems to be a slowcoach, the first thing I would try is taking much slower steps. It might be thinking about reporting current state when your rule comes along with another command.

Do you happen to have these up in your UI while this is going on? There was a weird UI bug that can turn display updates into extra commands. I don’t think that is happening, because you’d see extra commands in your log.

LoungeRoom_ is the Room, so the rest of the lights

Do you mean the Times of the 4 createTimer ?

No, I just have my test switch up.

I managed to get the revert to work if the lights are on - had to save the ColorTemperature state as well.

No luck however if the lights started off being turned off.

Looks like has something to do with he way HUE handles Rooms?