rules file
import org.openhab.core.library.types.*
rule "Set HSB value of item RGBLed to RGB color value"
when
Item RGBLed changed
then
val hsbValue = RGBLed.state as HSBType
val brightness = hsbValue.brightness.intValue
val redValue = ((((hsbValue.red.intValue * 255) / 100) *brightness) /100).toString
val greenValue = ((((hsbValue.green.intValue * 255) / 100) *brightness) /100).toString
val blueValue = ((((hsbValue.blue.intValue * 255) / 100) *brightness) /100).toString
val color = redValue + "," + greenValue + "," + blueValue
sendCommand( RGBLedColor, color)
end
the code works fine with phone app mqtt dashboardâbut i cant put it to openhabâŠi think i m not good with subcribtionsâplease help----with item configuration and rule
on my phone i see this pictureâŠon openhab nothing hapensâŠthe color changes very good on mqtt dashboard appâŠi think i not send the right topic on the item file
Group All
Color RGBLed âNeoPixel Colorâ (All)
String RGBLedColor (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}
2018-04-17 20:58:38.250 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at âitems/RGBLedâ for the unknown item âRGBLedâ.
when i change the color on my telephone mqtt dashboard then is see on mqtt fx for example this #F700BAâŠbut on openhab logviever i see nothing
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mqtt:broker.url=tcp://192.168.2.122:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>
# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
Group All
Color RGBLed NeoPixel Color(All){mqtt="<[mosquitto:esp/1/out:state:default]"}
String RGBLedColor (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}
2018-04-18 11:47:56.268 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/RGBLed' for the unknown item 'RGBLed'.
2018-04-18 12:34:34.076 [ome.event.ItemCommandEvent] - Item 'RGBLedColor' received command 107,91,255
2018-04-18 12:34:34.082 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
java.lang.IllegalArgumentException: 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:48) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.library.types.PercentType.<init>(PercentType.java:43) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.library.types.HSBType.getBrightness(HSBType.java:105) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.library.types.HSBType.toString(HSBType.java:132) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.compat1x.internal.TypeMapper.mapToESHType(TypeMapper.java:125) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.events.EventPublisherDelegate.postUpdate(EventPublisherDelegate.java:63) [208:org.openhab.core.compat1x:2.2.0]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:150) [212:org.openhab.binding.mqtt:1.11.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556) [213:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [213:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [213:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [213:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:748) [?:?]```