I see this is an older topic but for me still actual.
I like to control the brightness of tradfri lightbulb, in OH3 and UI with MQTT.
Brughtness needs to be integer 0-255, Dimmer sends 0.00…-0.9999.
Where to put this function?
How to address this function?
How to use transformation?
Thanks in advance for some help!
Best regards
Piet
Maybe this might help?
Dear hafniumzinc, thanks, this helped a lot.
Major problem was I’ve chosen numbertype instead of percentage, and with creation of model changed number to dimmer. This resulted in publishing 0.99 when pointed to 99 on the scale from 0 to 254.==>brighness of bulb ± 1%
Still have issue: Publish 254 when pointing on 100 on the scale of 0 to 254 gives brightness of 100%.
Is there a solution to get a scale from 0% to 100% and publishing 254 when pointing to 100% ?
Did you carefully do this bit from that tutorial?
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
Click Save top-right.
Dear Hafniumzinc, SOLVED !!
Thanks a lot !!
Best regards
Piet
What am I missing here? My problem seems to be the same. I have added the “state description” “min/max” and configured my channel as follows. Setting the dimmer to 50 in Openhab3 will only send 0,1 to MQTT
UID: mqtt:topic:cb609d2f95
label: Hue White Ambiance 1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:e90f42a7f8
location: Kitchen Island
channels:
- id: state
channelTypeUID: mqtt:string
label: state
description: null
configuration:
commandTopic: zigbee2mqtt/0x001788010830795c/set/brightness
postCommand: true
step: 1
min: 0
stateTopic: zigbee2mqtt/0x001788010830795c/brightness
max: 255
Thanks in advance
You’re using a String type Channel for a dimmer? Is that deliberate? If not, you will need to delete this Channel and create a new one - you can’t change the type of an existing Channel via the UI.
It was a mistake. I deleted the channels and recreated the thing/item/channel with this configuration:
- id: state
channelTypeUID: mqtt:switch
label: state
description: ""
configuration:
commandTopic: zigbee2mqtt/0x001788010830795c/set/state
stateTopic: zigbee2mqtt/0x001788010830795c/state
off: OFF
on: ON
- id: brightness
channelTypeUID: mqtt:dimmer
label: brightness
description: ""
configuration:
commandTopic: zigbee2mqtt/0x001788010830795c/set/brightness
min: 0
stateTopic: zigbee2mqtt/0x001788010830795c/brightness
max: 254
off: OFF
on: ON
Now everything works as intended
Thanks