Cannot not get value from MQTT

Need help with this one:

I have installed the MQTT binding and set it up in openhab.cfg as follows:
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.


In the Items file I got this row:

String LightLevel "Ljus ute" (all) {mqtt="<[skynet:MyLog/Light/Level:state:default]"}

I have tried with Number instead of string but there is no difference

This is my rule:
(I have tried without the conversion as well, both with LightLevel as String and Number)

 import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Integer.*

rule MQTTLightLevel
  Item LightLevel  changed
 logInfo("LightLevel: ", LightLevel)

 if(Integer::parseInt(LightLevel) < 50) {
        sendCommand(Light_FV_Entee_UTE_Tak, ON)
        sendCommand(Light_Garden_Altan_Spot, ON)

There is no reaction at all, not even in the log files.

What am I doing wrong?

More digging i get this info and error:

I get the right value here
09:12:58.762 [INFO ] [runtime.busevents :26 ] - LightLevel state updated to 94

But in the rules it seems like there is some XML code in the variable?!
09:12:04.797 [ERROR] [o.o.c.s.ScriptExecutionThread :50 ] - Error during the execution of rule 'MQTTLightLevel': The name '<XFeatureCallImplCustom> < <XNumberLiteralImpl>' cannot be resolved to an item or type.

If there is really nothing, double check if you have the correct binding installed:
and check for correct permissions.
Also make sure you have a mqtt broker installed, most here use mosquitto.
You should have the following log entries:

2016-10-02 21:13:31.407 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2016-10-02 21:13:31.410 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'

Stupid me… you have to use the .state i.e
if(LightLevel.state < 50) {

Sometimes you just need to make a post to get it right :slight_smile: