Min-max range for MQTT dimmer type

Tags: #<Tag:0x00007fc8f6cb1238> #<Tag:0x00007fc8f6cb0cc0> #<Tag:0x00007fc8f6cb0568>

I’m new to OpenHAB (but with years of Home Assistant experience), and was trying to set up a ceiling light running Tasmota through MQTT.

MQTT result messages look like this:

stat/utorch2/RESULT {"POWER":"ON","Dimmer":47,"Color":"393E","HSBColor":"0,0,47","Channel":[22,24],"CT":334}

while the brightness and colour temperature commands go into cmnd/utorch2/DIMMER and cmnd/utorch2/CT

There was no problem with the brightness, probably because it has the same 0-100 range as the dimmer item, so no transformation required. It works fine, if I change brightness of the light in HA, the slider in OpenHAB also changes.

I cannot get colour temperature to work the same way though, probably because its range is from 153-500, so I’ve specified min=153, max=500 in the MQTT thing channel:

Thing mqtt:topic:entry "Előszoba" (mqtt:broker:MQTT) {
    Type string : reachable "Reachable"   [ stateTopic="tele/utorch2/LWT" ]
    Type switch : power     "Power"       [ stateTopic="stat/utorch2/POWER",  commandTopic="cmnd/utorch2/POWER" ]
    Type dimmer : dimmer    "Brightness"  [ stateTopic="stat/utorch2/RESULT", commandTopic="cmnd/utorch2/DIMMER", transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer" ]
    Type dimmer : colortemp "Color Temp"  [ stateTopic="stat/utorch2/RESULT", commandTopic="cmnd/utorch2/CT", transformationPattern="REGEX:(.*CT.*)∩JSONPATH:$.CT", min=153, max=500 ]

with this item definition:

Group  gEntryLight                  "Előszoba lámpa"    <light> (Entry)             ["Lightbulb"]
Switch EntryLightControl            "Lámpa"             <light> (gEntryLight)       ["Control"]  { channel="mqtt:topic:entry:power" }
Dimmer EntryLightBrightness         "Fényerő"           <light> (gEntryLight)       ["Light"]    { channel="mqtt:topic:entry:dimmer", autoupdate="false" }
Dimmer EntryLightColor              "Színhőmérséklet"   <light> (gEntryLight)       ["Light"]    { channel="mqtt:topic:entry:colortemp", autoupdate="false" }

Now when I set CT to 327 in Home Assistant, I can see in OpenHAB events.log that EntryLightColor changes to about 50, which is fine, so the mapping/transformation was done from the range 153-500 where 327 is in the middle, so 50% is correct for a dimmer slider.

But in OpenHAB UI, it seems not only the displayed range of the slider has to be 153-500, but also the value, as the dot (with the value of “50”) is way off the scale on the left:

Also, if I move the slider to anywhere, no MQTT message is generated, I guess because the 0-100 value is out-of-range for 153-500. It seems there is no range mapping for the slider, even though its scale is correct.

So what can be done to map the 0-100 range of the slider correctly to the 153-500 range of the MQTT channel? Shouldn’t it be automatic when min, max values are specified?

I can’t test this right now, so apologies, but I think you’ll want a combination of this issue and this post where it says

We have to make one small adjustment to the Item created for the Dimmer Channel:

Items -> PorchLight_Dimmer -> Add Metadata -> State Description

Min: 0
Max: 100

adjusting for your min and max…

1 Like


I prefer setting everything up in config files, and found in your topic how to add metadata to an item, so item config now has stateDescription=""[min="0", max="100"] added to it:

Dimmer EntryLightColor "Színhőmérséklet"   <light> (gEntryLight) ["Light"]  { channel="mqtt:topic:entry:colortemp", autoupdate="false", stateDescription=""[min="0", max="100"] }

which resulted in changing into 0-100 range, with the slider dot at correct position:

I’d still rather have the range left in 153-500 as it was before (and somehow have the transformation done between that and 0-100), but the the point is now it reflects the state of the lamps colour temperature correctly, and most importantly, changing the slider creates MQTT message, so it finally works!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.