openhab-addons icon indicating copy to clipboard operation
openhab-addons copied to clipboard

[mqtt.generic] Send ON/OFF for dimmer channels when so configured

Open ccutrer opened this issue 1 year ago • 7 comments

Similar to how UP/DOWN are processed for rollershutters.

Fixes #7991

ccutrer avatar Nov 19 '23 18:11 ccutrer

As a general question: Wouldn't it make sense to use the converters introduced in https://github.com/openhab/openhab-core/pull/3355?

J-N-K avatar Nov 19 '23 19:11 J-N-K

I was not aware of their existence. Yes, it probably would make sense to use those, but I would prefer to get this PR in as is, and then do a separate (much larger!) PR converting to those. It will need to consider how all the "downstream" MQTT bindings rely on their conversions, and possibly add more capabilities to core. In particular, some of the recent Home Assistant components I've added rely on non-round-trippable conversions. I.e. Cover/Rollershutter you send OPEN, but the state is open (or fully configurable command and state values). I have a WIP I haven't opened a PR for yet for Lock where you send LOCK, UNLOCK, or OPEN, but the states are LOCKED, UNLOCKED, LOCKING, UNLOCKING, JAMMED.

ccutrer avatar Nov 19 '23 19:11 ccutrer

Note that this conflicts with #15925. I'd rather that one merge first. Once that's done, I'll rebase this one.

ccutrer avatar Nov 19 '23 20:11 ccutrer

I just tested this, and it's ready for review

ccutrer avatar Jan 30 '24 20:01 ccutrer

ping @antroids @jlaur @lolodomo

ccutrer avatar Feb 07 '24 16:02 ccutrer

Ping @antroids @jlaur @lolodomo

ccutrer avatar Mar 21 '24 01:03 ccutrer

Please rebase.

lsiepel avatar Apr 30 '24 18:04 lsiepel

ping @ccutrer

lsiepel avatar Jul 16 '24 20:07 lsiepel

rebased, conflicts resolved, which then required some changes to tests, and squashed it all together

ccutrer avatar Jul 16 '24 20:07 ccutrer

Looking through this again, there's nothing that prevents you from still entering a number for the special ON/OFF values. They'll just be treated as a string --- exactly as before. The only difference is that on/off no longer have a default (of 1/0). Which isn't actually a difference, because ON/OFF (on sending a command) will first be translated to PercentType.HUNDRED/PercentType.ZERO, and then scaled to the min/max, ending up at 100/0 or 1/0 as appropriate. On return back from MQTT with a current state, this commit will actually fix a bug if your min/max is 0-100, but you leave the on string as the default of "1", "1" would inadvertently get treated as 100%, not 1%.

ccutrer avatar Jul 23 '24 19:07 ccutrer