import org.openhab.binding.bticinosmarther.internal.api.dto.Enums.MeasureUnit;
import org.openhab.binding.bticinosmarther.internal.api.exception.SmartherIllegalPropertyValueException;
import org.openhab.binding.bticinosmarther.internal.util.DateUtil;
+import org.openhab.core.i18n.TimeZoneProvider;
import com.google.gson.annotations.SerializedName;
* @return a string containing the module operational activation time label, or {@code null} if the activation time
* cannot be parsed to a valid date/time
*/
- public @Nullable String getActivationTimeLabel() {
+ public @Nullable String getActivationTimeLabel(TimeZoneProvider timeZoneProvider) {
String timeLabel = TIME_FOREVER;
if (activationTime != null) {
try {
- final ZonedDateTime dateActivationTime = DateUtil.parseZonedTime(activationTime, DTF_DATETIME_EXT);
- final ZonedDateTime dateTomorrow = DateUtil.getZonedStartOfDay(1, dateActivationTime.getZone());
+ boolean dateActivationTimeIsZoned = activationTime.length() > 19;
+
+ final ZonedDateTime dateActivationTime = DateUtil.parseZonedTime(activationTime,
+ dateActivationTimeIsZoned ? DTF_DATETIME_EXT : DTF_DATETIME);
+ final ZonedDateTime dateTomorrow = DateUtil.getZonedStartOfDay(1,
+ dateActivationTimeIsZoned ? dateActivationTime.getZone() : timeZoneProvider.getTimeZone());
if (dateActivationTime.isBefore(dateTomorrow)) {
timeLabel = DateUtil.format(dateActivationTime, DTF_TODAY);
import org.openhab.binding.bticinosmarther.internal.handler.SmartherDynamicStateDescriptionProvider;
import org.openhab.binding.bticinosmarther.internal.handler.SmartherModuleHandler;
import org.openhab.core.auth.client.oauth2.OAuthFactory;
+import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.scheduler.CronScheduler;
import org.openhab.core.thing.Bridge;
private final HttpClient httpClient;
private final CronScheduler cronScheduler;
private final SmartherDynamicStateDescriptionProvider dynamicStateDescriptionProvider;
+ private final TimeZoneProvider timeZoneProvider;
@Activate
public SmartherHandlerFactory(@Reference OAuthFactory oAuthFactory, @Reference SmartherAccountService authService,
@Reference HttpClientFactory httpClientFactory, @Reference CronScheduler cronScheduler,
- @Reference SmartherDynamicStateDescriptionProvider dynamicStateDescriptionProvider) {
+ @Reference SmartherDynamicStateDescriptionProvider dynamicStateDescriptionProvider,
+ final @Reference TimeZoneProvider timeZoneProvider) {
this.oAuthFactory = oAuthFactory;
this.authService = authService;
this.httpClient = httpClientFactory.getCommonHttpClient();
this.cronScheduler = cronScheduler;
this.dynamicStateDescriptionProvider = dynamicStateDescriptionProvider;
+ this.timeZoneProvider = timeZoneProvider;
}
@Override
this.authService.addSmartherAccountHandler(handler);
return handler;
} else if (SmartherBindingConstants.THING_TYPE_MODULE.equals(thingTypeUID)) {
- return new SmartherModuleHandler(thing, cronScheduler, dynamicStateDescriptionProvider);
+ return new SmartherModuleHandler(thing, cronScheduler, dynamicStateDescriptionProvider, timeZoneProvider);
} else {
logger.debug("Unsupported thing {}", thing.getThingTypeUID());
return null;
import org.openhab.binding.bticinosmarther.internal.model.ModuleSettings;
import org.openhab.binding.bticinosmarther.internal.util.StringUtil;
import org.openhab.core.cache.ExpiringCache;
+import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
private final SmartherDynamicStateDescriptionProvider dynamicStateDescriptionProvider;
private final ChannelUID programChannelUID;
private final ChannelUID endDateChannelUID;
+ private final TimeZoneProvider timeZoneProvider;
// Module configuration
private SmartherModuleConfiguration config;
* @param provider
* the {@link SmartherDynamicStateDescriptionProvider} dynamic state description provider to be used
*/
- public SmartherModuleHandler(Thing thing, CronScheduler scheduler,
- SmartherDynamicStateDescriptionProvider provider) {
+ public SmartherModuleHandler(Thing thing, CronScheduler scheduler, SmartherDynamicStateDescriptionProvider provider,
+ final TimeZoneProvider timeZoneProvider) {
super(thing);
this.cronScheduler = scheduler;
this.dynamicStateDescriptionProvider = provider;
+ this.timeZoneProvider = timeZoneProvider;
this.programChannelUID = new ChannelUID(thing.getUID(), CHANNEL_SETTINGS_PROGRAM);
this.endDateChannelUID = new ChannelUID(thing.getUID(), CHANNEL_SETTINGS_ENDDATE);
this.config = new SmartherModuleConfiguration();
updateChannelState(CHANNEL_STATUS_MODE,
new StringType(StringUtil.capitalize(localChrono.getMode().toLowerCase())));
updateChannelState(CHANNEL_STATUS_TEMPERATURE, localChrono.getSetPointTemperature().toState());
- updateChannelState(CHANNEL_STATUS_ENDTIME, new StringType(localChrono.getActivationTimeLabel()));
+ updateChannelState(CHANNEL_STATUS_ENDTIME,
+ new StringType(localChrono.getActivationTimeLabel(timeZoneProvider)));
updateChannelState(CHANNEL_STATUS_TEMP_FORMAT, new StringType(localChrono.getTemperatureFormat()));
final Program localProgram = localChrono.getProgram();
if (localProgram != null) {