rule "Timer gLights"
when
Member of gLights received command ON
then
//Int Variable der GUI
if(gLightsOffset.state.toString == "null")
{
var State myState = new State(90)
gLightsOffset.setState(myState)
}
timeOffset = (gLightsOffset.state as Number).intValue
if(timer === null | timer.hasTerminated){
timer = createTimer(now.plusMinutes(timeOffset), [|
gLights.sendCommand(OFF);
//Systembenachrichtigungen
sendBroadcastNotification("Timer abgelaufen: Lichter wurden nach "+ timeOffset.toString + " Minuten automatisch ausgeschalten.")
logInfo("GroupLights.rules","Das Ende des Skripts wurde erreicht. Lichter wurden ausgeschalten")
])
}
else
{
timer.reschedule(now.plusMinutes(timeOffset))
}
end
But I’m getting an Error at
var State myState = new State(90)
gLightsOffset.setState(myState) //postUpdate didn't work
2018-11-02 19:15:40.822 [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.
NULL not null. NULL is an openHAB state. null is a java variable value/condition setState ??? Where does that come from??
To update an item state use the postUpdate method
rule "Timer gLights"
when
Member of gLights received command ON
then
//Int Variable der GUI
if(gLightsOffset.state.toString == "NULL") {
gLightsOffset.postUpdate(90)
}
From the name of the item (gLightsOffset) it looks like this is a group, or? I know you should be able to use .sendCommand() on a group item, but I am not sure you can use .postUpdate(). Anyone?
Correct, if the item is a group then you can’t postUpdate because the item is updated by its members.
But using sendCommand will cascade the command to all the items in the group provided the group and the items are of the same type.
You can send a command via a Group, that gets passed to all members. That will not update the Group’s state either. The command may eventually result in members states changing, that may or may not cange the Group’s state, depending on if/how the Group’s aggregate functions are defined.
Short story : Group state is only calculated from member states, and then only if you define how in an aggregate function.
rule "Timer gLights"
when
Member of gLights received command ON
then
//Int Variable der GUI
if(gLightsOffset.state == NULL) {
gLightsOffset.postUpdate(90)
}
timeOffset = (gLightsOffset.state as Number).intValue
if (timer === null) {
timer = createTimer(now.plusMinutes(timeOffset), [|
gLights.sendCommand(OFF);
//Systembenachrichtigungen
sendBroadcastNotification("Timer abgelaufen: Lichter wurden nach "+ timeOffset.toString + " Minuten automatisch ausgeschalten.")
logInfo("GroupLights.rules","Das Ende des Skripts wurde erreicht. Lichter wurden ausgeschalten")
])
}
else {
timer.reschedule(now.plusMinutes(timeOffset))
}
end
And you are saying that the postUpdate(90) doesn’t work. What does the log show when you trigger that rule and gLightsOffset is NULL?