mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
+7
-2
@@ -22,6 +22,7 @@ import org.openhab.binding.tado.internal.TadoBindingConstants;
|
|||||||
import org.openhab.binding.tado.internal.config.TadoMobileDeviceConfig;
|
import org.openhab.binding.tado.internal.config.TadoMobileDeviceConfig;
|
||||||
import org.openhab.binding.tado.swagger.codegen.api.ApiException;
|
import org.openhab.binding.tado.swagger.codegen.api.ApiException;
|
||||||
import org.openhab.binding.tado.swagger.codegen.api.model.MobileDevice;
|
import org.openhab.binding.tado.swagger.codegen.api.model.MobileDevice;
|
||||||
|
import org.openhab.binding.tado.swagger.codegen.api.model.MobileDeviceLocation;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
@@ -31,6 +32,7 @@ import org.openhab.core.thing.ThingStatusDetail;
|
|||||||
import org.openhab.core.thing.ThingStatusInfo;
|
import org.openhab.core.thing.ThingStatusInfo;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
import org.openhab.core.types.RefreshType;
|
import org.openhab.core.types.RefreshType;
|
||||||
|
import org.openhab.core.types.UnDefType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -107,8 +109,11 @@ public class TadoMobileDeviceHandler extends BaseHomeThingHandler {
|
|||||||
private void updateState() {
|
private void updateState() {
|
||||||
try {
|
try {
|
||||||
MobileDevice device = getMobileDevice();
|
MobileDevice device = getMobileDevice();
|
||||||
updateState(TadoBindingConstants.CHANNEL_MOBILE_DEVICE_AT_HOME,
|
if (device.getLocation() instanceof MobileDeviceLocation location) {
|
||||||
OnOffType.from(device.getLocation().isAtHome()));
|
updateState(TadoBindingConstants.CHANNEL_MOBILE_DEVICE_AT_HOME, OnOffType.from(location.isAtHome()));
|
||||||
|
} else {
|
||||||
|
updateState(TadoBindingConstants.CHANNEL_MOBILE_DEVICE_AT_HOME, UnDefType.UNDEF);
|
||||||
|
}
|
||||||
} catch (IOException | ApiException e) {
|
} catch (IOException | ApiException e) {
|
||||||
logger.debug("Status update of mobile device with id {} failed: {}", configuration.id, e.getMessage());
|
logger.debug("Status update of mobile device with id {} failed: {}", configuration.id, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -14,6 +14,8 @@ package org.openhab.binding.tado.swagger.codegen.api.model;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +71,7 @@ public class MobileDevice {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobileDeviceLocation getLocation() {
|
public @Nullable MobileDeviceLocation getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user