mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Philips Somneo
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
512e3b239b
commit
86955bc39f
@ -15,6 +15,7 @@ package org.openhab.binding.somneo.internal;
|
|||||||
import static org.openhab.binding.somneo.internal.SomneoBindingConstants.*;
|
import static org.openhab.binding.somneo.internal.SomneoBindingConstants.*;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -356,8 +357,8 @@ public class SomneoHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_ALARM_TIME:
|
case CHANNEL_ALARM_TIME:
|
||||||
if (command instanceof DateTimeType decimal) {
|
if (command instanceof DateTimeType dateTimeCommand) {
|
||||||
connector.setAlarmTime(alarmPosition, decimal);
|
connector.setAlarmTime(alarmPosition, dateTimeCommand.getZonedDateTime(ZoneId.systemDefault()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_ALARM_REPEAT_DAY:
|
case CHANNEL_ALARM_REPEAT_DAY:
|
||||||
|
@ -17,6 +17,7 @@ import static org.openhab.binding.somneo.internal.SomneoBindingConstants.*;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
@ -46,7 +47,6 @@ import org.openhab.binding.somneo.internal.model.SunsetData;
|
|||||||
import org.openhab.binding.somneo.internal.model.TimerData;
|
import org.openhab.binding.somneo.internal.model.TimerData;
|
||||||
import org.openhab.binding.somneo.internal.model.WifiData;
|
import org.openhab.binding.somneo.internal.model.WifiData;
|
||||||
import org.openhab.core.io.net.http.HttpUtil;
|
import org.openhab.core.io.net.http.HttpUtil;
|
||||||
import org.openhab.core.library.types.DateTimeType;
|
|
||||||
import org.openhab.core.library.types.DecimalType;
|
import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.library.types.PercentType;
|
import org.openhab.core.library.types.PercentType;
|
||||||
@ -373,7 +373,7 @@ public class SomneoHttpConnector {
|
|||||||
executeUrl("PUT", ALARM_EDIT_ENDPOINT, data);
|
executeUrl("PUT", ALARM_EDIT_ENDPOINT, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlarmTime(int position, DateTimeType time)
|
public void setAlarmTime(int position, ZonedDateTime time)
|
||||||
throws TimeoutException, InterruptedException, ExecutionException {
|
throws TimeoutException, InterruptedException, ExecutionException {
|
||||||
final AlarmSettingsData data = fetchAlarmSettingsData(position);
|
final AlarmSettingsData data = fetchAlarmSettingsData(position);
|
||||||
data.setConfigured(true);
|
data.setConfigured(true);
|
||||||
|
@ -148,8 +148,7 @@ public class AlarmSettingsData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlarmTime(DateTimeType timeState) {
|
public void setAlarmTime(ZonedDateTime zonedTime) {
|
||||||
final ZonedDateTime zonedTime = timeState.getZonedDateTime();
|
|
||||||
final LocalTime time = LocalTime.of(zonedTime.getHour(), zonedTime.getMinute());
|
final LocalTime time = LocalTime.of(zonedTime.getHour(), zonedTime.getMinute());
|
||||||
if (time == null) {
|
if (time == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user