- Platform information:
- Hardware: Intel
- OS: Ubuntu
- Java Runtime Environment: Zulu 17
- openHAB version:3.4
Hi community!
Yeah, I’m still stuck with OH3.
I’ve got a device which is controlled via MQTT. It has it’s internal brightness value, which is publishes every time it’s switched on and off or when the brightness changes.
It has onboard controls, and I have now implemented mqtt commands to be sent outta OH to switch it on and off.
The brightness is a different story.
Typical dimmer item, by default, just sends a raw value to a specified mqtt command channel when the value changes.
That’s not suitable, as my device basically expects “UP” or “DOWN” text commands, changes the brightness and then publishes its current values to a dedicated channel.
How can I implement something like that? It feel like there must be some sort of elegant solution, possibly not even requiring rules…
What I’ve tried so far is:
- Trying to catch a receivedCommand in rules, as in here - didn’t work. In fact no matter what I did, receivedCommand always equals to current item value, and not ON or OFF or INCREASE or DECREASE etc.
- Tried smarter approach, like:
when
Item BRIGHTNESS received command
then
if (receivedCommand > BRIGHTNESS.state)
{
logInfo("TEST_DEVICE", "UP")
}
else
{
logInfo("TEST_DEVICE", "DOWN")
}
end
** I’ve omitted the mqtt commans being send after those log commands. There’s nothing interesing there.*
That works, but item BRIGHTNESS stops getting updated with actual brigtness from the divice, and only shows the value from BasicUI, where it is defined as follows:
Setpoint item=BRIGHTNESS label="Light brightness [%d %%]" minValue=20.0 maxValue=100.0 step=1.0
Please help. Regards!