Several questions about writing bindings

Hello dear maintainers! I am working now on another binding for yet another piece of equipment, supported by me and not supported by OH (yet). I’ve got several unconnected questions:

  1. The Thing in question outputs some datestamps . Is there any better way to represent a DateTime channel , rather than formatting it as a string ? If yes, how to specify it in the binding XML, how to configure the respective item ? What formatting specifiers are there to use ? If i want to get e. g. full “DD-MM-YYYY hh:mm” date/time. And the most important - what the underlying Number representation should be ?
  2. Is there any way for the Binding to know that a Channel is linked or unlinked to/from an item? In other words, starts or stops being used? The Thing in question talks over a serial port at rather slow speeds (9600 bps max), and almost each Channel needs to be polled separately by sending a specific query packet. It would be a waste of bus traffic to poll for unused channels. I know that when a channel starts being used, the Binding gets RefreshType command on the channel; this is how i detect that the channel is in use. But is there any notification on channel removal ?

There is a DateTimeType. You can use DateTime in the xml. See https://www.openhab.org/docs/concepts/items.html#datetimetype and see other bindings for examples for how to configure or set a pattern in the xml.

You can use the method isLinked to check if a channel is linked to an item. This method is available in your handler class, inherited via BaseThingHandler

Thank you for replies

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.