Mqtt item slider

Hi,

i have a problem with an inbound mqtt topic from an external dimmer.

My item is

Dimmer Deckenlicht_Couch_Dim “Wohnzimmer Deckenlicht Couch Dim [%d %%]” {mqtt=">[mosquitto:edomi/in/set/Wohnzimmer/Licht/Deckenlicht_Couch_dw:command::default], <[mosquitto:edomi/out/status/Wohnzimmer/Licht/Deckenlicht_Couch_RMw:state::default]", autoupdate=“false” }

here is the karaff log
log:tail org.openhab.binding.mqtt
21:58:36.229 [DEBUG] [g.mqtt.internal.MqttMessageSubscriber] - Skipped message '20
’ because Message Filter ‘default’ does not apply.

what im doing wrong.
I tried everthing.

You have an extra : between state and default. There should only be one. This problem exists in both MQTT configs.

Hi thx for your answer.
unfortunatly thats a copy paste error.

Here is my items file:

Dimmer	Deckenlicht_Couch_Dim	"Wohnzimmer Deckenlicht Couch Dim [%d %%]"	{mqtt=">[mosquitto:edomi/in/set/Wohnzimmer/Licht/Deckenlicht_Couch_dw:command:*:default], <[mosquitto:edomi/out/status/Wohnzimmer/Licht/Deckenlicht_Couch_RMw:state:*:default]", autoupdate="false" }

The outboud message works as aspected.
Only inbound is the problem.

Use this:

Dimmer	Deckenlicht_Couch_Dim	"Wohnzimmer Deckenlicht Couch Dim [%d %%]"	{mqtt=">[mosquitto:edomi/in/set/Wohnzimmer/Licht/Deckenlicht_Couch_dw:command:*:default], <[mosquitto:edomi/out/status/Wohnzimmer/Licht/Deckenlicht_Couch_RMw:state:default]", autoupdate="false" }

The inbound syntax is different from the outbound: broker:topic:state:default no * needed

1 Like

Th alot!
but i found a “better way” for me with another problem :wink:
maybe someone could give me hint.

Heres my actual item

Dimmer	Deckenlicht_Couch_Dim	"Wohnzimmer Deckenlicht Couch Dim [%.1f %%]"	{mqtt=">[mosquitto:edomi/in/set/Wohnzimmer/Licht/Deckenlicht_Couch_dw:command:*:JS(convert-dim.js)], <[mosquitto:edomi/out/status/Wohnzimmer/Licht/Deckenlicht_Couch_RMw:state:JS(convert-dim-in.js)]", autoupdate="false" }

Here is my convert-dim-in.js transformation


(function(i) {
    if(input >= 0)
    {
        return input / 255 * 100 ;
    }
    else
    {
        return null;
    }
})(input)

I use this because my inbound topic is a dimmer that sends at 100% a Value of 255.
Here is the problem:

If I receive a payload of 128 I get something like this: 50,19607843137255

how could i change to a integer?
Do I have to modify the “js convert” or is this a rule?

return (input / 255 * 100).floor()

Hi thx. but i couldn’t get it to work.

I get

20:50:24.092 [ERROR] [g.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: An error occurred while executing script.

i modified the js transformation like this

(function(i) {
    if(input >= 0)
    {
        return (input / 255 * 100).floor() ;
    }
    else
    {
        return null;
    }
})(input)

:flushed:

Hi I think i get it

here is my js code

(function(i) {
    if(input >= 0)
    {
        return Math.floor(input / 255 * 100);
    }
    else
    {
        return null;
    }
})(input)

thx alot for helping!!!