I have wondering why this happens… I have some rules which controls RGB leds during the day… However when one of these rules seems active, it refreshes the state really quickly, as I see it in events.log
2018-07-31 23:38:16.964 [ome.event.ItemCommandEvent] - Item 'wifiled2_power' received command OFF
2018-07-31 23:38:16.974 [ome.event.ItemCommandEvent] - Item 'wifiled1_power' received command ON
2018-07-31 23:38:16.981 [ome.event.ItemCommandEvent] - Item 'wifiled_livingroom' received command OFF
2018-07-31 23:38:17.002 [ome.event.ItemCommandEvent] - Item 'wifiled2_power' received command OFF
2018-07-31 23:38:17.012 [ome.event.ItemCommandEvent] - Item 'wifiled1_power' received command ON
2018-07-31 23:38:17.018 [ome.event.ItemCommandEvent] - Item 'wifiled_livingroom' received command OFF
2018-07-31 23:38:17.103 [ome.event.ItemCommandEvent] - Item 'wifiled2_power' received command OFF
2018-07-31 23:38:17.107 [ome.event.ItemCommandEvent] - Item 'wifiled1_power' received command ON
2018-07-31 23:38:17.124 [ome.event.ItemCommandEvent] - Item 'wifiled_livingroom' received command OFF
2018-07-31 23:38:17.272 [ome.event.ItemCommandEvent] - Item 'wifiled2_power' received command OFF
2018-07-31 23:38:17.322 [ome.event.ItemCommandEvent] - Item 'wifiled1_power' received command ON
2018-07-31 23:38:17.359 [ome.event.ItemCommandEvent] - Item 'wifiled_livingroom' received command OFF
In milliseconds… However nothing changes, so it resends the same command these many times… Maybe it’s because that it is unclear for me when these rules fire. I usually use received update, but that’s why it this happens? Maybe using Item … changed is a better approach?
rule "Night Light in Kitchen and Living Room"
when
Item Zone4 changed
then
if(Zone4.state.toString == "ON" && (vTimeOfDay.state == "BED" || vTimeOfDay.state == "NIGHT") && CurrentActivityHub.state.toString == "PowerOff" && Sonoff.state.toString == "OFF") {
// LED on -- Reset timer or start it, if it was turned on before...
if(gKitchenLedLight.state.toString == "ON") {
Turn_Off_Leds.sendCommand(ON)
logInfo("wifiled.rules", "Reset timer")
}
// Turn everything on
else {
gKitchenLedLight.sendCommand(ON)
wifiled_livingroom.sendCommand(ON)
Turn_Off_Leds.sendCommand(ON)
logInfo("wifiled.rules", "Turning on the LEDs...")
}
}
end
rule "Movie/TV Light Kitchen and Living Room"
when
Item CurrentActivityHub received update or
Item Sonoff received update or
Item gKitchenLedLight received update or
Item vTimeOfDay changed
then
if(Sonoff.state.toString == "OFF" && CurrentActivityHub.state.toString == "Watch a Movie") {
wifiled2_power.sendCommand(OFF)
wifiled1_power.sendCommand(ON)
wifiled_livingroom.sendCommand(OFF)
}
else if(CurrentActivityHub.state.toString == "Watch TV" && (vTimeOfDay.state == "EVENING" || vTimeOfDay.state == "NIGHT" || vTimeOfDay.state == "BED")) {
wifiled_livingroom.sendCommand(ON)
}
end
rule "Led Off Timer expired"
when
Item Turn_Off_Leds received command OFF
then
gKitchenLedLight.sendCommand(OFF)
wifiled_livingroom.sendCommand(OFF)
end
rule "Turn LED on when Kitchen Light is on"
when
Item Sonoff received update
then
if(Sonoff.state.toString == "ON") {
if(gKitchenLedLight.state.toString == "ON") {
logInfo("wifiled.rules", "Kitchen LED is turned on manually!")
Wifiled_Manual.sendCommand(ON)
}
gKitchenLedLight.sendCommand(ON)
}
else {
if(Wifiled_Manual.state.toString == "OFF") {
gKitchenLedLight.sendCommand(OFF)
}
}
end
rule "Reset Sonoff_Manual if LED turned off"
when
Item gKitchenLedLight received update
then
if(gKitchenLedLight.state.toString == "OFF") {
Wifiled_Manual.sendCommand(OFF)
}
end
rule "WifiLed Presets"
when
Item wifiled_presets received command
then
switch(receivedCommand) {
case "1" : {
gKitchenLedLight.sendCommand(ON)
wifiled1_color.sendCommand("0,100,100")
wifiled2_color.sendCommand("0,100,100")
}
}
end
rule "Reset Preset button"
when
Item gKitchenLedLight received update
then
if(gKitchenLedLight.state == OFF) {
wifiled_presets.postUpdate("")
}
end
Example :
I suppose that this zone4 is a group attached to almost all you item in you kitchen.
So, when “Night Light in Kitchen and Living Room” starts, it turns ON/OFF your items.
This raise the group to receive an update. So “Night Light in Kitchen and Living Room” starts again, and again, …
Those errors indicate that VSCode has lost its connection to the language server protocol on OH. Just restart VSCode and the error should clear itself out.
Track what event is triggering the Rule. It may not be that line but some event is occurring over and over and it is just because of the state of everything causes this else to execute.
Forgot to answer, thanks for the help it was just an infinite loop made by me
It was hard to see first because I have triggered a group, but later in the rule I have sent commands directly to some of the group members…