Help with Rule to control all lights

Hi All

Im frequently getting this error with regards to using MQTT pub/sub event bus rules

19:04:39.133 [WARN ] [org.openhab.core.items.GenericItem   ] - failed notifying listener 'gAllInsideDimmers (Type=GroupItem, BaseType=DimmerItem, Members=9, State=100.00000000, Label=All Inside Dimmers, Category=light, Tags=[Control, Power], Groups=[gAllInsideLights])' about state update of item LivingRoomDim1: Value must be between 0 and 100
java.lang.IllegalArgumentException: Value must be between 0 and 100
        at org.openhab.core.library.types.PercentType.validateValue(PercentType.java:93) ~[?:?]
        at org.openhab.core.library.types.PercentType.<init>(PercentType.java:88) ~[?:?]
        at org.openhab.core.library.types.DecimalType.as(DecimalType.java:207) ~[?:?]
        at org.openhab.core.internal.items.ItemStateConverterImpl.convertToAcceptedState(ItemStateConverterImpl.java:64) ~[?:?]
        at org.openhab.core.items.GroupItem.stateUpdated(GroupItem.java:372) ~[?:?]
        at org.openhab.core.items.GenericItem.lambda$1(GenericItem.java:257) ~[?:?]
        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:829) [?:?]
19:04:39.154 [INFO ] [openhab.event.ChannelTriggeredEvent  ] - mqtt:broker:MQTT_Broker:remote_updates triggered House/out/LivingRoomDim1/state#5
19:04:39.157 [WARN ] [org.openhab.core.items.GenericItem   ] - failed notifying listener 'gAllInsideDimmers (Type=GroupItem, BaseType=DimmerItem, Members=9, State=100.00000000, Label=All Inside Dimmers, Category=light, Tags=[Control, Power], Groups=[gAllInsideLights])' about state update of item LivingRoomDim1: Value must be between 0 and 100
java.lang.IllegalArgumentException: Value must be between 0 and 100
        at org.openhab.core.library.types.PercentType.validateValue(PercentType.java:93) ~[?:?]
        at org.openhab.core.library.types.PercentType.<init>(PercentType.java:88) ~[?:?]
        at org.openhab.core.library.types.DecimalType.as(DecimalType.java:207) ~[?:?]
        at org.openhab.core.internal.items.ItemStateConverterImpl.convertToAcceptedState(ItemStateConverterImpl.java:64) ~[?:?]
        at org.openhab.core.items.GroupItem.stateUpdated(GroupItem.java:372) ~[?:?]
        at org.openhab.core.items.GenericItem.lambda$1(GenericItem.java:257) ~[?:?]
        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:829) [?:?]

Any suggestions as to what to look for?
I think this rule is triggering it when mQTT sends its state about an item


val eb_br = "mqtt:broker:MQTT_Broker" // Thing ID of the broker connection
val eb_name = "Garage"              // <client ID>

rule "Publish commands to the event bus"
when
    Member of PubItems_CMD received command // eb_cmd_gr
then
    val mqttActions = getActions("mqtt",eb_br)
    mqttActions.publishMQTT(eb_name+"/out/"+triggeringItem.name+"/command",receivedCommand.toString)
end

rule "Publish updates to the event bus"
when
    Member of PubItems_UPD received update // eb_upd_gr
then
    val mqttActions = getActions("mqtt",eb_br)
    mqttActions.publishMQTT(eb_name+"/out/"+triggeringItem.name+"/state",triggeringItem.state.toString)
end


rule "Subscribe for commands and updates from the event bus"
when
    Channel "mqtt:broker:MQTT_Broker:remote_updates" triggered
then
    var topic = receivedEvent.toString.split("#").get(0)
    var state = receivedEvent.toString.split("#").get(1)
    val itemName = topic.split("/").get(2)
    val type = topic.split("/").get(3)

    if(type == "command") sendCommand(itemName, state)
    else postUpdate(itemName, state)
end

Thanks!

The problem might be in your mqtt channel definitions and Item definition, especially LivingRoomDim1

Here is the item definition screenshot:

The broker on this machine only has 1 channel which is a remote update trigger, this machine receives the updates via the MQTT eventbus

What is the MQTT state value for LivingRoomDim1 received via the subscriber?
Looks like it is outside the range of 0 and 100. Very often the raw value for “brightness” is between 0 and 255 and you have to convert it to a percent value.

You cannot postUpdate to a Group Item, though I don’t know if that generates an error or not. It really doesn’t make sense to update a Group Item though in any case.

The error is probably because you are trying to update the Group with ON or OFF and while you can command a Dimmer with those, you cannot update a Dimmer with those. Or if some device is using the bus, you have to make sure that the value published by the device isn’t outside the range of 0-100.

Overall, given the title of the posting, you are sending a command to the state topic and that’s wont work. You need to send it to the command topic.

You have a disconnect between Item types on the two instances or a mix up between commands and updates.

Thanks Rich, Ok ill need to look into why thats occuring. I was under the impression all of my dimmer items are using 0 (OFF) 100 (ON)

Add logging to confirm what’s being sent on what topic of course. Also take heed that about updates to a Group not being allowed (I think, it used to be that way). gAllInsideDimmers (and any other Group) should not be a member of PubItems_UPD.

Ive had a look at this, its complaining about gAllInsideDimmers. That group does not have the event bus groups attached to it.

The issue occurs when I give Alexa a command to set the state of a dimmer, say 50%. Alexa, dim living room to 50 and I get the error.

the item definition is:

Dimmer DiningRoomDim1 "Dining Room [%d %%]"                            (gAllDimmers,PubItems_UPD)                                                       { channel="zwave:device:12c97eda:node32:switch_dimmer1" }

Log:


20:19:13.088 [INFO ] [openhab.event.ChannelTriggeredEvent  ] - mqtt:broker:MQTT_Broker:remote_updates triggered House/out/DiningRoomDim1/state#10
20:19:13.089 [WARN ] [org.openhab.core.items.GenericItem   ] - failed notifying listener 'gAllInsideDimmers (Type=GroupItem, BaseType=DimmerItem, Members=9, State=10.00000000, Label=All Inside Dimmers, Category=light, Tags=[Control, Power], Groups=[gAllInsideLights])' about state update of item DiningRoomDim1: Value must be between 0 and 100
java.lang.IllegalArgumentException: Value must be between 0 and 100
        at org.openhab.core.library.types.PercentType.validateValue(PercentType.java:93) ~[?:?]
        at org.openhab.core.library.types.PercentType.<init>(PercentType.java:88) ~[?:?]
        at org.openhab.core.library.types.DecimalType.as(DecimalType.java:207) ~[?:?]
        at org.openhab.core.internal.items.ItemStateConverterImpl.convertToAcceptedState(ItemStateConverterImpl.java:64) ~[?:?]
        at org.openhab.core.items.GroupItem.stateUpdated(GroupItem.java:372) ~[?:?]
        at org.openhab.core.items.GenericItem.lambda$1(GenericItem.java:257) ~[?:?]
        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:829) [?:?]

Im not understanding where im going wrong. The updates are 0 to 100. The group isnt tied to the event bus

Cheers

As Rich said, we need the log to see what is sent.
I would go to the API Explorer and check which value is stored and test which value range is accepted. If Alexa sends for example 0.5 to the item but the item expects 50 then it will never work

What’s the Group’s definition? In particular the aggregation function.

Why is the MQTT event bus involved at all if Alexa is giving the command?

I wish the error actually logged out the value that it is attempting to use.

1 Like

You got it Rich, it was the Group Agg function, it was SUM. Changing it to none fixed the issue