eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
866 stars 782 forks source link

[MQTT Generic Things] Homie define channel type #6795

Open esdeboer opened 5 years ago

esdeboer commented 5 years ago

It would be nice to be able to define the channel type for discovered homie things in paper ui.

At the moment you can't define percent value or rollershutter for homie integer data types, they will always be numbers. and I would like my dimmer to actually be a dimmer in Open Hab.

davidgraeff commented 5 years ago

I don't think that manually editing the channels is the right way to go. If you define a range via $format, the code should generate a percentage value.

If not, that's a bug then that will get fixed :)

esdeboer commented 5 years ago

I've got this homie dimmer homie/crownstones/crownstone7/dimmer/$name Dimmer homie/crownstones/crownstone7/dimmer/$unit % homie/crownstones/crownstone7/dimmer/$datatype integer homie/crownstones/crownstone7/dimmer/$settable true homie/crownstones/crownstone7/dimmer/$format 0:100

this all gets set correctly in openHab 2.4, but as type number so I can't assign dimmer items to it.

I wonder if you can make an automatic distinction between number and dimmer based on the currently available input

davidgraeff commented 5 years ago

If there's a range the binding should create a dimmer channel instead. I don't know if there's any scenario where you would like to have a number channel when a range is given.

esdeboer commented 5 years ago

Maybe if you want to display gauges, you would need to have a number and a range.

esdeboer commented 5 years ago

If it should create a percentage value, it looks like a bug, as Property.java looks like it always sets value to NumberValue for floats and integers in createChannelFromAttribute

davidgraeff commented 5 years ago

Yup that need to be changed. I'd happily accept a patch if you want it done fast :)

Bonus would be another test case that checks if a min/max formatted homie property indeed creates a percentage value (so that this bug never appears again).

I haven't got time right now unfortunately.

esdeboer commented 5 years ago

I might take a look at it if I can get openhab to build/test correctly