Successfully Migrating Patterns from OH2.5 to OH3.0

After spending considerable time migrating from OH2.5 to OH3.0, I encountered an issue where patterns defined in my *.items files were not being imported correctly using the ‘Add items via textual definition’ feature. The patterns were ignored, and the item labels included the pattern syntax, which wasn’t ideal.

Initially, I tried copying the content of my *.items files directly into the textual definition importer, but the patterns weren’t applied. I discovered that the patterns needed to be specified as metadata within the textual definition. Here’s how I resolved it:

  1. Identify the Pattern: Determine the pattern you want to apply, such as a time format or custom formatting.

  2. Modify the Textual Definition: Add the pattern as metadata in the textual definition. For example:

    DateTime vOS_Astro_Sunrise_Start “Begin Sunrise” (gOS_Astro) [“Point”] { channel=“astro:sun:local:rise#start”, stateDescription=" " [pattern=“%1$tR”] }

    Ensure there’s a space or text in the stateDescription to avoid issues.

  3. Import the Updated Definition: Copy the modified textual definition into the importer. This ensures the pattern is correctly applied during migration.

  4. Verify in Metadata: After importing, check the metadata in /var/lib/openhab/jsondb/*.metadata.json to confirm the pattern is correctly set.

This approach allows seamless migration of patterns from OH2.5 to OH3.0 without losing the desired formatting. It’s a straightforward solution once you know how to structure the metadata within the textual definition.

If anyone else has encountered similar issues or has alternative solutions, I’d love to hear about them! Happy migrating! :slight_smile: