I am in the process of migrating from mqtt v1.0 plugins to 2.0 plugins, and I am running into an issue I cannot solve. I have searched high and low and cannot find an answer. Unfortunately I do not really understand the documentation either.
The issue I have is that I have some custom build devices that is expecting to receive a value from 1 to 100. (A percentage), but all I can get openhab2 to send is a float. 1.0 - 100.0. How can I get rid of the “.0” suffix?
I think the problem is that I do not understand the format I am supposed to write the transformations in.
Second problem is regarding the same functionality. I would like to have a “%”-sign after a value I receive from a device, but I cannot figure out how to escape the %-sign so that openhab will stop tripping over it.
This is an Item definition, in the format used in xxx.items files
Number myItem "some label [%d %%]" <someIcon> (channel= ....
The label is the part in " " "some label [%d %%]"
which contains a format in [ ] [%d %%]
and that’s the default format to display this Item’s state.
In this case, it means “show a decimal number with a percent sign”
Maybe you use PaperUI to create and edit Items. The principle is the same, it all goes in the Label box in the form.
If you use a sitemap based UI, you can optionally add a label in each line, which in turn can contain a [ format ], and that will override the default in the Item definition.
Dimmer OG_bad_l_led1_dim "Bad OG: LED - Dimmer" <light> (gM,gR,Glicht) {channel="mqtt:topic:mosquitto:h801_2550:h801_2550_dimmer"}
In OH log it seems to work fine
[ome.event.ItemCommandEvent] - Item 'OG_bad_l_led1_dim' received command 75
[nt.ItemStatePredictedEvent] - OG_bad_l_led1_dim predicted to become 75
[vent.ItemStateChangedEvent] - OG_bad_l_led1 changed from 38 to 75
But the output in MQTT is : 0.75000000
(which leads to switch off the LED (dimmer =0) - instead of setting the dimmer to 75)
Doesn’t have anything to do with sitemaps or formatting. I recommend starting a new thread with an MQTT related topic.
What are you using to monitor that?
Looks like the binding is taking the 75% command and using it as a fraction (of one).
I don’t think that should happen with a dimmer type channel.
You should identify your MQTT binding version, there have been changes with this.