Hi Elwin @Whininie
I am using the same method for a local date time; get the same error and could not find a solution.
Did you find a solution for this?
Regards, Bert
no sorry, i bring it back to english
Hi @Whininie and @deltabert
A solution for this could be a little rule like this:
rule "test_change_day_of_the_week"
when
Item Current_DateTime changed
then
var vDay = transform("MAP","de.map",now.toString("EEEE")) // for test
logInfo("Day","Day is: {}",vDay) // for test
CurrentTime4.postUpdate(transform("MAP","de.map",now.toString("EEEE")))
end
Just create a second Item (i.g. CurrentTime4) in your ntp.items-File
DateTime Current_DateTime "Heute [%1$tA, %1$td.%1$tm.%1$ty,%1$tH:%1$tM]" <calendar> {channel="ntp:ntp:local:dateTime"}
String CurrentTime4 "Heute ist [%s]" <time>
and using your Transformation-Map-File as above
The rule will trigger always when your “Original-Item” change and gives you the translated Day-Name without any Warning-Message in the Log.
In the Sitemap you have to insert the:
Text item=CurrentTime4 valuecolor=["green"] labelcolor=["green"]
and the result will look like:
Cheers,
Peter
I do see various topics regarding translation. The suggestion is always to create mapping files.
These (same!) mapping files are created again and again by the users, I guess the content is the same.
I started a topic sometime ago, b/c HABmin was using the correct translation for the astro binding - w/o a mapping file! But only HABmin did show these translations, non of the other UIs did. After some hints from Chris I’ve found the code which did the translation - it’s from the astro binding itself!
Currently there are two questions on my mind:
- Why isn’t translation not used more within the bindings?
- Why is only HABmin using the translation?
My coding skills are pretty small and haven’t been used for decades. Also I know this is an opensource project and nobody gets paid. I am just asking with the opportunity to optimize.
Thank You Jorg, thank You Peter. Finally it worked in Bulgarian.
I have the same problem here with item definitions like:
DateTime Weather_Forecast_Day1_Day "[MAP(sv_weekday.map):%1$tA]" <time> {channel="mqtt:topic:weather:forecast_day_1_day"}
However if I skip the MAP coversion, e.g.
DateTime Weather_Forecast_Day1_Day "[%1$tA]" <time> {channel="mqtt:topic:weather:forecast_day_1_day"}
It works great. No errors.
My MAP file:
Sunday=Söndag
Monday=Måndag
Tuesday=Tisdag
Wednesday=Onsdag
Thursday=Torsdag
Friday=Fredag
Saturday=Lördag
-=Okänt
NULL=Okänt
Seems to be identical problem as @deltabert has …
I haven’t found a solution to it. The errors are occurring in the log but the MAP conversion is actually carried out and seems to work.
Yes, the MAP returns a string. Though it happens to look like a datetime, it is just a string of characters.
The java formatter datetime operator $tA cannot work with a string, it needs a datetime object. Hence the error.
You can really only use %s with transforms.
Do any formatting you want in your MAP file.
However, I don’t really see what you are trying to do with trying to lookup a datetime in a MAP list.
A datetime Item state is something like 2019-02-27T17:29:47.288+0100 and that isn’t going to match in a list of monday, tuesday etc.