Dynamic Mappings possible?

I have an Item with the type DateTime (last time the mailbox was opened)
In my sitemap I want to map the date to a string if it was today or yesterday. If it was before yesterday it should be the datestring like it is currently configured:

DateTime BriefkastenGeoeffnet “Post eingeworfen [%1$td.%1$tm.%1$tY]” (Briefkasten)

So a dynamic mapping would be great like:
03.06.2020 = today
02.06.2020 = yesterday
everyting else = date

Another wish would be to have today in the green color, yesterday yellow and everything else grey.

Is this possible? A rule would work as a workaround when I use 2 Items (one for the datetime, one ofr the string) and set the stringitem to today if the mailbox was opened and have a cronjob at 12 oclock checking the datetime item and change the string one. But maybe there is another solution

1 Like

Your other option is going to be pretty much the same as your Rule in terms of complexity and effort. It’s to basically use the JavaScript transformation instead of the Rule.

Though I don’t think you can get to the color coding this way. Ultimately I think the only way to get both the word and the color coding is through two Items and a Rule.

1 Like