Hi,
i’m trying to parse a string that i receive from my weather station each time data is updated. As the string is utc based and the time needs to be adopted to the correct time zone, I want to convert it from String to DateTimeType and then assign to a DateTime Item.
The item are defined like this:
String Weather_Local_dateutc “Letzte Aktualisierung [%s]” (Weather_Local)
DateTime Weather_Local_lastupdate “Letzte Aktualisierung [%1$d.%1$m.%1$y %1$Tp]” (Weather_Local)
Weather_Local_dateutc is updated via a REST API Call and triggers the rule below. Unfortunately the rule causes an error like this:
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘ParseWeatherDate’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
import org.joda.time
import org.joda.datetime
rule "ParseWeatherDate"
when
Item Weather_Local_dateutc changed
then
var str = Weather_Local_dateutc.state.toString().split(" ")
var dtstr = str.get(0) + "T" + str.get(1);
var DateTimeType dt = parse(dtstr);
postUpdate(Weather_Local_lastupdate, dt);
end