hi!
I’m trying to set up the alarm clock item from the openHAB Android App on my phone. As soon as i set my alarm clock the Number Item:
Number OnePlus7_AlarmClock
gets set. For tomorrow morning for example OnePlus7_AlarmClock.state is 1605072300000.
To use this proberly I want to convert this to a DateTime Type Object “OnePlus7_AlarmClock_time”. I read this: DateTime Conversion
but none of the solutions worked for me.
My alarmclock.rules looks like this at the moment:
rule "AlarmClock: Change Epoch to DateTime"
when
Item OnePlus7_AlarmClock changed
then
logInfo("OnePlus7_AlarmClock changed to","Millis: "+ (OnePlus7_AlarmClock.state as Number))
val DateTimeType OnePlus7_AlarmClock_time = new DateTimeType(new DateTime(OnePlus7_AlarmClock.state))
end
…which leads to the error:
Rule 'AlarmClock: Change Epoch to DateTime': Could not cast 1605072600000 to java.lang.String; line 6, column 79, length 35
I also tried:
val DateTimeType OnePlus7_AlarmClock_time = new DateTimeType(new DateTime(OnePlus7_AlarmClock).toString)
…like suggested in #2 in the Tutorial i linked, but this gives me:
Rule 'AlarmClock: Change Epoch to DateTime': No instant converter found for type: org.eclipse.smarthome.core.library.items.NumberItem
Can somebody help me with this?
best regards,
RockNLol