MQTT Homie Dimmer item value scale

OH 2.5 S1628.

Howdy! I have a simple question, for once. :grin:

My MQTT Homie device exposes a property named “dimmer”. $settable = true, $retained = true, $datatype = integer, $format = 0:100

I have the following item defined:

Dimmer DimmerTest              "Test Dimmer [%d %%]"                    <slider>	(FF_Homie)  { channel = "mqtt:homie300:ab60b3fb:nodeid1#dimmer" }

I see the slider in BasicUI. I can adjust it. If I set it to the middle, it reads 50 % as expected.
The log says the following, exactly as expected:

2019-07-02 23:37:57.439 [ome.event.ItemCommandEvent] - Item 'DimmerTest' received command 50
2019-07-02 23:37:57.476 [nt.ItemStatePredictedEvent] - DimmerTest predicted to become 50
2019-07-02 23:37:57.518 [vent.ItemStateChangedEvent] - DimmerTest changed from 88 to 50

So here’s the question:

WHY does the …/dimmer/set topic get the payload 0.5000000 ?
I’m expecting 50 (a hundred times greater). Format is clearly 0:100.

What am I missing?

Look at the channel in PaperUI for the minimum / maximum settings?

1 Like

I checked, here’s what I saw:

Looks okay to me? I tried to follow this spec.

Rossko, are you referring to Generic MQTT things? This document makes reference to “min”, “max” and “step” values. But, that’s for Generic MQTT things. I don’t think it applies to Homie.

For Homie, there’s this document. It’s incredibly light on details. I know tagging people is discouraged, but @David_Graeff could you offer a clue to how your binding works? If this is documented elsewhere, I apologize but I have not been able to find it. I will be happy to RTFM if you give me an FM to R. :slight_smile:

Indeed I was. Seems to me you should have something for similar effect in the Homie version.
The need for dimmer value scaling still applies, assuming Homie spec does not force some common standard.
Whether Format + Data Type together should cover that, I couldn’t say.

I’m hoping David Gräff will chime in. :slight_smile:

It would seem to make sense that if it’s specified as 0:100 in the format, then openhab should publish values in the range of 0 to 100 for a dimmer. Certainly, publishing (for example) 0.34 to an item designated as an integer cannot possibly be considered following the standard? :slight_smile:

It’s a lot of extra work to shoehorn things into the Homie standard when making a device (especially at this early date when I had to write my own library!), but it’s worth it if it simplifies inclusion into the controller (namely openHAB). One might argue that having to jump through hoops and implement workaround also on the controller side defeats the purpose of using Homie to begin with, and one may as well stick to plain MQTT if that is how it’s intended to work. I doubt that’s the case, though.

Workaround? It’s a work in progress. At both ends. I’m just pointing out the levers involved here. And I forgot the important one, unit=% !

This post you’ve likely seen claims a working dimmer, does not specify units for it. Seems weird.

It should do that if min is 0 and max is set to 100. The homie binding parses “format” and recognises “p1:p2” with p1 being assigned to the minimum allowed value and p2 being assigned to the maximum. A step value is also computed: (p2-p1)/100, rounded up to 1 for integers.

See https://github.com/openhab/openhab2-addons/blob/master/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java#L184

Everything else follows the generic thing implementation and the min, max semantic over there. A published value is therefore confined to this range.

1 Like

I personally would really like some documentation covering just which out of the quite numerous homie3 payloads OH is using and honouring, so that I can ensure OH works with my homie implementation. I do realise you could just say I should implement them all.

As I was only testing against 2.4 and 2.5M1 I was accepting some issues and handling them with workarounds. But I want my implementation to work correctly with the long awaited 2.5M2 as I’m sure you do.

1 Like

Interesting! Do you see anything wrong with my definition of nodeid1/dimmer? that would cause /set to be a decimal number?

homie/examplehomiedev/nodeid1/dimmer/$name Dimmer
homie/examplehomiedev/nodeid1/dimmer/$settable true
homie/examplehomiedev/nodeid1/dimmer/$retained true
homie/examplehomiedev/nodeid1/dimmer/$datatype integer
homie/examplehomiedev/nodeid1/dimmer/$unit %
homie/examplehomiedev/nodeid1/dimmer/$format 0:100

homie/examplehomiedev/nodeid1/dimmer/set 0.52000000

Here’s the full output from mosquitto_sub -v -t homie/#

homie/examplehomiedev/$homie 3.0
homie/examplehomiedev/$name Example Homie Device
homie/examplehomiedev/$state ready
homie/examplehomiedev/$stats uptime,signal
homie/examplehomiedev/$stats/uptime 120
homie/examplehomiedev/$stats/signal -39
homie/examplehomiedev/$stats/interval 30
homie/examplehomiedev/$localip 172.22.22.170
homie/examplehomiedev/$mac 84:0D:8E:AB:E0:72
homie/examplehomiedev/$nodes nodeid1,nodeid2
homie/examplehomiedev/nodeid1/$name Node One
homie/examplehomiedev/nodeid1/$type customtype
homie/examplehomiedev/nodeid1/$properties doorbell,doorsensor,dimmer,dimmer2,temp,hum,precip,wind
homie/examplehomiedev/nodeid1/doorbell/$name Doorbell
homie/examplehomiedev/nodeid1/doorbell/$settable false
homie/examplehomiedev/nodeid1/doorbell/$retained false
homie/examplehomiedev/nodeid1/doorbell/$datatype enum
homie/examplehomiedev/nodeid1/dimmer/$name Dimmer
homie/examplehomiedev/nodeid1/dimmer/$settable true
homie/examplehomiedev/nodeid1/dimmer/$retained true
homie/examplehomiedev/nodeid1/dimmer/$datatype integer
homie/examplehomiedev/nodeid1/dimmer/$unit %
homie/examplehomiedev/nodeid1/dimmer/$format 0:100
homie/examplehomiedev/nodeid1/temp -42
homie/examplehomiedev/nodeid1/temp/$name Temperature
homie/examplehomiedev/nodeid1/temp/$settable false
homie/examplehomiedev/nodeid1/temp/$retained true
homie/examplehomiedev/nodeid1/temp/$datatype integer
homie/examplehomiedev/nodeid1/temp/$unit C
homie/examplehomiedev/nodeid1/hum 49
homie/examplehomiedev/nodeid1/hum/$name Humidity
homie/examplehomiedev/nodeid1/hum/$settable false
homie/examplehomiedev/nodeid1/hum/$retained true
homie/examplehomiedev/nodeid1/hum/$datatype integer
homie/examplehomiedev/nodeid1/hum/$unit %
homie/examplehomiedev/nodeid1/precip 100
homie/examplehomiedev/nodeid1/precip/$name Precipitation
homie/examplehomiedev/nodeid1/precip/$settable false
homie/examplehomiedev/nodeid1/precip/$retained true
homie/examplehomiedev/nodeid1/precip/$datatype integer
homie/examplehomiedev/nodeid1/precip/$unit %
homie/examplehomiedev/nodeid1/wind 24.4
homie/examplehomiedev/nodeid1/wind/$name Wind speed
homie/examplehomiedev/nodeid1/wind/$settable false
homie/examplehomiedev/nodeid1/wind/$retained true
homie/examplehomiedev/nodeid1/wind/$datatype float
homie/examplehomiedev/nodeid1/wind/$unit m/s
homie/examplehomiedev/nodeid1/doorsensor/$name Door Open
homie/examplehomiedev/nodeid1/doorsensor/$settable false
homie/examplehomiedev/nodeid1/doorsensor/$retained false
homie/examplehomiedev/nodeid1/doorsensor/$datatype boolean
homie/examplehomiedev/nodeid1/dimmer2/$name Dimmer2
homie/examplehomiedev/nodeid1/dimmer2/$settable true
homie/examplehomiedev/nodeid1/dimmer2/$retained true
homie/examplehomiedev/nodeid1/dimmer2/$datatype integer
homie/examplehomiedev/nodeid1/dimmer2/$unit %
homie/examplehomiedev/nodeid1/dimmer2/$format 0:100
homie/examplehomiedev/nodeid2/$name Node Two
homie/examplehomiedev/nodeid2/$type customtype
homie/examplehomiedev/nodeid2/$properties light1,light2,light3,light4,light5,light6,light7,light8,light9,light10
homie/examplehomiedev/nodeid2/light9/$name Light 9
homie/examplehomiedev/nodeid2/light9/$settable false
homie/examplehomiedev/nodeid2/light9/$retained true
homie/examplehomiedev/nodeid2/light9/$datatype string
homie/examplehomiedev/nodeid2/light8/$name Light 8
homie/examplehomiedev/nodeid2/light8/$settable false
homie/examplehomiedev/nodeid2/light8/$retained true
homie/examplehomiedev/nodeid2/light8/$datatype string
homie/examplehomiedev/nodeid2/light7/$name Light 7
homie/examplehomiedev/nodeid2/light7/$settable false
homie/examplehomiedev/nodeid2/light7/$retained true
homie/examplehomiedev/nodeid2/light7/$datatype string
homie/examplehomiedev/nodeid2/light6/$name Light 6
homie/examplehomiedev/nodeid2/light6/$settable false
homie/examplehomiedev/nodeid2/light6/$retained true
homie/examplehomiedev/nodeid2/light6/$datatype string
homie/examplehomiedev/nodeid2/light1/$name Light 1
homie/examplehomiedev/nodeid2/light1/$settable false
homie/examplehomiedev/nodeid2/light1/$retained true
homie/examplehomiedev/nodeid2/light1/$datatype string
homie/examplehomiedev/nodeid2/light5/$name Light 5
homie/examplehomiedev/nodeid2/light5/$settable false
homie/examplehomiedev/nodeid2/light5/$retained true
homie/examplehomiedev/nodeid2/light5/$datatype string
homie/examplehomiedev/nodeid2/light4/$name Light 4
homie/examplehomiedev/nodeid2/light4/$settable false
homie/examplehomiedev/nodeid2/light4/$retained true
homie/examplehomiedev/nodeid2/light4/$datatype string
homie/examplehomiedev/nodeid2/light3/$name Light 3
homie/examplehomiedev/nodeid2/light3/$settable false
homie/examplehomiedev/nodeid2/light3/$retained true
homie/examplehomiedev/nodeid2/light3/$datatype string
homie/examplehomiedev/nodeid2/light10/$name Light 10
homie/examplehomiedev/nodeid2/light10/$settable false
homie/examplehomiedev/nodeid2/light10/$retained true
homie/examplehomiedev/nodeid2/light10/$datatype string
homie/examplehomiedev/nodeid2/light2/$name Light 2
homie/examplehomiedev/nodeid2/light2/$settable false
homie/examplehomiedev/nodeid2/light2/$retained true
homie/examplehomiedev/nodeid2/light2/$datatype string

That is exactly what I’m looking for as well – it definitely does not seem like it supports everything yet. It’s a chicken-and-egg problem, to be sure, but that makes documentation even more critical.

I’m not sure I’d say that actually, because it’s impossible to test without something to test against.

I had actually NOT seen that one! That thread ended at an inconvenient moment, especially so for Gudmund I think.

It did however clue me into one thing… my $homie version number is wrong. Changing it now.

Comment: the use of both % and 0:100 seems redundant. I note that other post claiming a working homie dimmer had 0:100 but not %

Thank you. I will remove % as well and report back.
I will also restart openHAB – it’s my lab setup with no z-wave devices. :slight_smile:

Edit: It did not make a difference.

homie/examplehomiedev/$homie 3.0.1
homie/examplehomiedev/$name Example Homie Device
homie/examplehomiedev/$state ready
homie/examplehomiedev/$stats uptime,signal
homie/examplehomiedev/$stats/uptime 300
homie/examplehomiedev/$stats/signal -32
homie/examplehomiedev/$stats/interval 30
homie/examplehomiedev/$localip 172.22.22.170
homie/examplehomiedev/$mac 84:0D:8E:AB:E0:72
homie/examplehomiedev/$nodes nodeid1,nodeid2
homie/examplehomiedev/nodeid1/$name Node One
homie/examplehomiedev/nodeid1/$type customtype
homie/examplehomiedev/nodeid1/$properties doorbell,doorsensor,dimmer,dimmer2,temp,hum,precip,wind
<snip>
homie/examplehomiedev/nodeid1/dimmer/$name Dimmer
homie/examplehomiedev/nodeid1/dimmer/$settable true
homie/examplehomiedev/nodeid1/dimmer/$retained true
homie/examplehomiedev/nodeid1/dimmer/$datatype integer
homie/examplehomiedev/nodeid1/dimmer/$format 0:100
<snip>
homie/examplehomiedev/nodeid1/dimmer/set 0.45000000

I’m trying the validator and it doesn’t seem to be particularly useful because it completely chokes on $stats.

If I include the full $stats block:

homie/examplehomiedev/$stats uptime,signal
homie/examplehomiedev/$stats/uptime "300"
homie/examplehomiedev/$stats/signal "32"
homie/examplehomiedev/$stats/interval "30"

…then the validator crashes (i think). It does nothing. No error message.
If I leave just the first line:

homie/examplehomiedev/$stats uptime,signal

then validation fails with the following message:
“The value ‘uptime,signal’ of ‘examplehomiedev/$stats’ does not conform to the convention!”

…which is an interesting point of view, because clearly it does.

|4|Device 'examplehomiedev' has the deprecated attribute '$localip' set! Please check with the newest version of the convention.|
|5|Device 'examplehomiedev' has the deprecated attribute '$mac' set! Please check with the newest version of the convention.|

Yes, i just did. The latest version of the convention has them as REQUIRED, right there on the same site, one click away

|n/a1|Property 'doorbell' requires '$name' to be set!|
|n/a1|Property 'temp' requires '$name' to be set!|
|n/a1|Property 'hum' requires '$name' to be set!|

Yes, all three of the properties DO have $name set.
That validator is utter garbage.

I will load latest OH test build and check one from my HE homie implementation as I use 0:100 dim devices a lot.

K

image

You’re doing better than me - this is not even discovered… but other nodes in this device are - will check mine over…

1 Like

It’s a bit weird but this appears to be working for me as 0-100 integer messages from HA in set
Not sure about UI presentation of a light though.

image
image

1 Like

Whoa! Why is it working for you and not for me? :slight_smile:

Are you using Paper UI? I was using Basic UI. Will try Paper UI now.

What is the actual MQTT payload, for completeness? There’s no inherent reason a 50 percentage cannot be transmitted as 0.50 and unpacked at either end.

The issue is really that homie3 defines it’s nodes and their value ranges - if the other controller discovers these nodes via homie it should really honour their ranges. homie3 does not define how brightness levels are represented eg 0-255 0-100 0.0 -1.0 - if you have to build conversion back from a reported value it all gets too complex and is not clear e.g is a set of 80 in the 0-100 or 0-255 range

The set payload (command) is 52 and the dim level payload (actual) is also 52

3 Likes

Here’s what it looks like for me in Paper UI:

It gave me a proper slider! But it still sets 0.16000000.

What fun we’re having ! I am just slightly concerned mine might be originating from a ‘parallel’ Home Assistant MQTT auto Discovery message which points to the same homie topic for control and state - let me double check

1 Like

I think I’d confirm my sanity by linking the same Dimmer Item to a manually conjured generic MQTT thing (as well) and just check that payload :crazy_face:

1 Like