DateTime item issue

Hello -

Need some assistance with configuration of DateTime item. In my item file I have the following two items:

DateTime Sunrise “Sunrise [%1$tH:%1$tM]” {http=“<[meteohub:10000:XPATH(/meteohub/data[@timeframe=‘actual’]/item[@sensor=‘sunrise’ and @cat=‘standard’ and @unit=‘local’])]”}

String Sunset “Sunset [%s]” {http=“<[meteohub:10000:XPATH(/meteohub/data[@timeframe=‘actual’]/item[@sensor=‘sunset’ and @cat=‘standard’ and @unit=‘local’])]”}

The String item (Sunset) works perfectly the DateTime one (Sunrise) does not. When changed to a string item it works.

The format of the sting provided by the binding is hh:mm as in 08:23 for example.

Any advice appreciated.

Thanks,

Baobab

From the docs: Items | openHAB

DateTimeType objects are parsed using Java’s SimpleDateFormat.parse() using the first matching pattern:

  1. yyyy-MM-dd'T'HH:mm:ss.SSSZ
  2. yyyy-MM-dd'T'HH:mm:ss.SSSz
  3. yyyy-MM-dd'T'HH:mm:ss.SSSX
  4. yyyy-MM-dd'T'HH:mm:ssz
  5. yyyy-MM-dd'T'HH:mm:ss

Notice that 08:23 doesn’t match any of the supported date time patterns. In specific, there is no date and not seconds. A DateTime represents a specific instant in time. You can’t create a DateTime without the date.

1 Like

Understood. Thank you for the response and pointing me to the documentation - sometimes its a bit challenging to find especially if the underlying concept isn’t clear understood.

  • Baobab.