Spent about an hour looking around how to remove the Time Zone from zonedDateTime.now() without any luck.
Here’s my variables in .rules:
var Cal_Date0 = new DateTimeType().zonedDateTime.now().plusDays(0)
var Cal_Date1 = new DateTimeType().zonedDateTime.now().plusDays(1)
var Cal_Date2 = new DateTimeType().zonedDateTime.now().plusDays(2)
var Cal_Date3 = new DateTimeType().zonedDateTime.now().plusDays(3)
var Cal_Date4 = new DateTimeType().zonedDateTime.now().plusDays(4)
Here’s the results from it:
2021-11-13 11:10:09.472 [INFO ] [rg.openhab.core.model.script.STARTUP] - Cal_Date0 is 2021-11-13T11:10:06.031673-06:00[America/Chicago]
2021-11-13 11:10:09.770 [INFO ] [rg.openhab.core.model.script.STARTUP] - Cal_Date1 is 2021-11-14T11:10:06.033016-06:00[America/Chicago]
2021-11-13 11:10:09.775 [INFO ] [rg.openhab.core.model.script.STARTUP] - Cal_Date2 is 2021-11-15T11:10:06.034169-06:00[America/Chicago]
2021-11-13 11:10:09.778 [INFO ] [rg.openhab.core.model.script.STARTUP] - Cal_Date3 is 2021-11-16T11:10:06.035307-06:00[America/Chicago]
2021-11-13 11:10:09.781 [INFO ] [rg.openhab.core.model.script.STARTUP] - Cal_Date4 is 2021-11-17T11:10:06.036415-06:00[America/Chicago]
Here’s the issue at hand with Time Zone appended to Date Time variables to use else where:
2021-11-13 11:10:09.866 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-11-13T11:10:06.031673-06:00[America/Chicago]' to a state type which item 'FIOWeather_ObservationTime0' accepts: [DateTimeType, UnDefType].
2021-11-13 11:10:09.875 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-11-14T11:10:06.033016-06:00[America/Chicago]' to a state type which item 'FIOWeather_ObservationTime1' accepts: [DateTimeType, UnDefType].
2021-11-13 11:10:09.880 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-11-15T11:10:06.034169-06:00[America/Chicago]' to a state type which item 'FIOWeather_ObservationTime2' accepts: [DateTimeType, UnDefType].
2021-11-13 11:10:09.885 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-11-16T11:10:06.035307-06:00[America/Chicago]' to a state type which item 'FIOWeather_ObservationTime3' accepts: [DateTimeType, UnDefType].
2021-11-13 11:10:09.890 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-11-17T11:10:06.036415-06:00[America/Chicago]' to a state type which item 'FIOWeather_ObservationTime4' accepts: [DateTimeType, UnDefType].
FIOWeather_ObservationTime fields are all defined as DateTime.
Here’s the syntax for update FIOWeather_ObservationTime fields:
if (gInternet.state == ON && Cal_Date0 !== null && Cal_Date0 != NULL && Cal_Date0 != UNDEF) { FIOWeather_ObservationTime0.postUpdate(Cal_Date0.toString()) }
if (gInternet.state == ON && Cal_Date1 !== null && Cal_Date1 != NULL && Cal_Date1 != UNDEF) { FIOWeather_ObservationTime1.postUpdate(Cal_Date1.toString()) }
if (gInternet.state == ON && Cal_Date2 !== null && Cal_Date2 != NULL && Cal_Date2 != UNDEF) { FIOWeather_ObservationTime2.postUpdate(Cal_Date2.toString()) }
if (gInternet.state == ON && Cal_Date3 !== null && Cal_Date3 != NULL && Cal_Date3 != UNDEF) { FIOWeather_ObservationTime3.postUpdate(Cal_Date3.toString()) }
if (gInternet.state == ON && Cal_Date4 !== null && Cal_Date4 != NULL && Cal_Date4 != UNDEF) { FIOWeather_ObservationTime4.postUpdate(Cal_Date4.toString()) }
Best, Jay