Thing.xml option label erratic behavior

I have a number of channels that come in as integer values that represent a limited and countable set of states. I’ve setup these items as described here. On my working OpenHab instance running on a RasPi, some channels are working and displaying the mapped strings, some are showing the integer and some are formatting as dates. In the Eclipse IDE, it was showing dates, then decided to start working correctly with no traceable change to explain why. I’m baffled as to where these timedate formats are coming from. Thank you in advance for any help.

Pool Items

I’ve tried this both with and without the [%s] formatter

String PoolBackyardStatus “Status [%s]” { channel = “haywardomnilogic:backyard:04b2ed08:35940:backyardStatus”}
String PoolBackyardState “State [%s]” { channel = “haywardomnilogic:backyard:04b2ed08:35940:backyardState”}

Sitemap

Text item=PoolBackyardStatus
Text item=PoolBackyardState

PaperUI Control Showing integer, not option mapping string
image

Sitemap showing integer, not option mapping string

This is a number channel showing a date in PaperUI (no option mapping)
image

Error log when opening sitemap. This specific channel is a number in the thing.xml file, but I’ve seen this same error with a string item with option mapping.
09:10:07.172 [WARN ] [.ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘1969-12-31T19:00:00.000-0500’ of item PoolChlorError with format ‘%.0f’: f != java.time.ZonedDateTime

ThingHandler

public State toState(String type, String value) throws NumberFormatException {
    if ("Number".equals(type)) {
        return new DecimalType(value);
    } else if ("Switch".equals(type)) {
        return Integer.parseInt(value) > 0 ? OnOffType.ON : OnOffType.OFF;
    } else if ("Number:Dimensionless".equals(type)) {
        return new DecimalType(value);
    } else {
        return StringType.valueOf(value);
    }
}

public void updateData(String systemID, String channelID, String data) {
    Channel chan = getThing().getChannel(channelID);
    if (chan != null) {
        String acceptedItemType = chan.getAcceptedItemType();
        if (acceptedItemType != null) {
            State state = toState(acceptedItemType, data);
            updateState(chan.getUID(), state);
        }
    }
}

Code Repository

Sounds like you’ve linked number type channels to String type Items. As I recall, that produces unexpected date related grumbles.

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