Dimmer and MQTT: No percent state

Hello,

I am brandnew to OH. With my first solution, I want to control an MQTT actor based on ESP8266. Switches and input work well, but the dimmer not jet. With it the LED15 should be dimmed in 5% increase/decrease. But with the choosen setup, I only got ON/OFF and INCREASE/DECREASE states (and no MQTT messages).
My actor.items:

// Gruppen
Group gAct1 // Gruppe Actor 1
Group gAct2 // Gruppe Actor 2

/MQTT/
Switch LED11 “LED11” (gAct1) { mqtt=">[mosquitto:actor1/ch0:command:ON:ch0_255],>[mosquitto:actor1/ch0:command:OFF:ch0_0]" }
Switch LED12 “LED12” (gAct1) { mqtt=">[mosquitto:actor1/ch1:command:ON:ch1_255],>[mosquitto:actor1/ch1:command:OFF:ch1_0]" }
Switch LED13 “LED13” (gAct1) { mqtt=">[mosquitto:actor1/ch2:command:ON:ch2_255],>[mosquitto:actor1/ch2:command:OFF:ch2_0]" }
Switch LED14 “LED14” (gAct1) { mqtt=">[mosquitto:actor1/ch3:command:ON:ch3_255],>[mosquitto:actor1/ch3:command:OFF:ch3_0]" }

Dimmer LED15 “LED15 [%d %%]” (gAct1) { mqtt=">[mosquitto:actor1/ch3:state:*:default]" }

Switch LED21 “LED11” (gAct2) { mqtt=">[mosquitto:test:command:ON:211],>[mosquitto:test:command:OFF:210]" }
Switch LED22 “LED22” (gAct2) { mqtt=">[mosquitto:test:command:ON:221],>[mosquitto:test:command:OFF:220]" }
Switch LED23 “LED23” (gAct2) { mqtt=">[mosquitto:test:command:ON:231],>[mosquitto:test:command:OFF:230]" }
Switch LED24 “LED24” (gAct2) { mqtt=">[mosquitto:test:command:ON:241],>[mosquitto:test:command:OFF:240]" }

/MQTT input/
Number Temperatur “Temperatur [%d Grad C]” (gAct1) { mqtt="<[mosquitto:test:state:default]" }

My actor.sitemap:

sitemap actor label=“Hauptmenue”
{
Frame {
Group item=gAct1 label=“Actor 1” icon="Actor 1"
Group item=gAct2 label=“Actor 2” icon=“Actor 2”
}
Frame {
Slider item=LED15
}
}

My actor.rules:

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

/**

  • This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands

  • and posting an updated state on the bus
    */
    rule "Dimmed"
    when
    Item LED15 received command
    then
    var Number percent = 0
    if(LED15.state instanceof DecimalType) percent = LED15.state as DecimalType

     if(receivedCommand==INCREASE) percent = percent + 5
     if(receivedCommand==DECREASE) percent = percent - 5
    
     if(percent<0)   percent = 0
     if(percent>100) percent = 100
     
     postUpdate(LED15, percent);
    

end

I run Openhab1 (1.8.3) on a Windows 7 PC browsing with Chrome.
Any hint is very welcome!

Best regards
Walter

I don’t think you need the rule in this case. When you adjust the slider I think it sets the dimmer to the appropriate number value which gets sent over MQTT. The rule appears to be interacting with this behaviour.

Hello Rich,

Many thanks for your quick reaction. I have removed the rule, but no change.
Attached is the output from the OH console:

I still get ON/OFF after short click, INCREASE/DECREASE after long click, bat no percentage and MQTT.

Best regards
Walter

I admit that I have zero practical experience with Dimmers and Sliders.

Without out knowing the “proper” way, I would probably use a Proxy Item.

Create an Item that is not bound to anything (i.e. has no { } clause). Put this Item on your sitemap.

Add back in your Rule only this time when the Proxy Item receives INCREASE, sendCommand the number to LED15.

I wrote up a short tutorial on Proxy Items here:

Hello Rich,

Many thanks for this hint. I will give it a try and let you know the results.

Best regards
Walter