Item Metadata | State Description | Options

  • Platform information:
    • Hardware: rockchip64/ 4 GB RAM/ 32 GB eMMc
    • OS: bookworm
    • Java Runtime Environment: temurin 21.0.12
    • openHAB version: 5.20

For the ChargingState Item (OH Android app), I receive the following states when the smartphone is charging:

Samsung: AC
Motorola: USB

When not charging, the OH Android app sends UNDEF for both Samsung and Motorola.

In the Item configuration | Metadata | Status Description | Options, I set the following:

AC=Charging
USB=Charging
UNDEF=Discharging

The AC and USB statuses work, but the UNDEF status never shows “Discharging”.

I would appreciate any guidance.

Have you tried:

AC=Charging
USB=Charging
=Discharging

This should use Discharging as default for all other values.

Hi!

I had tried it, but it didn’t work either.
It would be great to have a “default” option.
One that would be used if none of the previous ones were valid.

That’s what @DrRSatzteil’s example should do. But the State Description Options is a separate implementation from the Map transformation.

So I recommend installing the Map Transformation add-on, set the pattern in the state description to MAP(|AC=Charging; USB=Charging; =Discharging):%s for the short term.

Then file an issue on the openhab-webui (I think, maybe openhab-core) repo to make sure that State Description Options align with how the Map transformation works. Or that it at least supports NULL and UNDEF.

Thank you very much for your help, @rlkoshak and @DrRSatzteil.
It is working correctly now.