use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.
the class DeviceStatusManagerImpl method unregisterDeviceListener.
@Override
public void unregisterDeviceListener(DeviceStatusListener deviceListener) {
if (deviceListener != null) {
String id = deviceListener.getDeviceStatusListenerID();
logger.debug("unregister DeviceListener with id: {}", id);
if (id.equals(DeviceStatusListener.DEVICE_DISCOVERY)) {
this.deviceDiscovery = null;
} else {
Device intDevice = strucMan.getDeviceByDSID(deviceListener.getDeviceStatusListenerID());
if (intDevice != null) {
intDevice.unregisterDeviceStatusListener();
} else {
Circuit intCircuit = strucMan.getCircuitByDSID(new DSID(deviceListener.getDeviceStatusListenerID()));
if (intCircuit != null) {
intCircuit.unregisterDeviceStatusListener();
if (deviceDiscovery != null) {
deviceDiscovery.onDeviceAdded(intCircuit);
}
}
}
}
}
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.
the class DeviceStatusManagerImpl method removeDevice.
@Override
public void removeDevice(String dSID) {
Device intDevice = strucMan.getDeviceByDSID(dSID);
if (intDevice != null) {
strucMan.deleteDevice(intDevice);
trashDevices.add(new TrashDevice(intDevice));
}
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.
the class DeviceStatusManagerImpl method registerDeviceListener.
@Override
public void registerDeviceListener(DeviceStatusListener deviceListener) {
if (deviceListener != null) {
String id = deviceListener.getDeviceStatusListenerID();
if (id.equals(DeviceStatusListener.DEVICE_DISCOVERY)) {
this.deviceDiscovery = deviceListener;
logger.debug("register Device-Discovery ");
for (Device device : strucMan.getDeviceMap().values()) {
deviceDiscovery.onDeviceAdded(device);
}
for (Circuit circuit : strucMan.getCircuitMap().values()) {
deviceDiscovery.onDeviceAdded(circuit);
}
} else {
Device intDevice = strucMan.getDeviceByDSID(deviceListener.getDeviceStatusListenerID());
if (intDevice != null) {
logger.debug("register DeviceListener with id: {} to Device ", id);
intDevice.registerDeviceStatusListener(deviceListener);
} else {
Circuit intCircuit = strucMan.getCircuitByDSID(new DSID(deviceListener.getDeviceStatusListenerID()));
if (intCircuit != null) {
logger.debug("register DeviceListener with id: {} to Circuit ", id);
intCircuit.registerDeviceStatusListener(deviceListener);
} else {
deviceListener.onDeviceRemoved(null);
}
}
}
}
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.
the class DeviceHandler method onDeviceAdded.
@Override
public synchronized void onDeviceAdded(GeneralDeviceInformation device) {
if (device instanceof Device) {
this.device = (Device) device;
if (this.device.isPresent()) {
ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
logger.debug("Set status to {}", getThing().getStatus());
// load scene configurations persistently into the thing
for (Short i : this.device.getSavedScenes()) {
onSceneConfigAdded(i);
}
logger.debug("Load saved scene specification into device");
this.device.saveConfigSceneSpecificationIntoDevice(getThing().getProperties());
checkDeviceInfoProperties(this.device);
// load sensor priorities into the device and load sensor channels of the thing
if (!this.device.isShade()) {
loadSensorChannels();
// check and load output channel of the thing
checkOutputChannel();
} else if (this.device.isBlind()) {
// load channel for set the angle of jalousie devices
String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(((Device) device).getFunctionalColorGroup(), ((Device) device).getOutputMode());
loadOutputChannel(new ChannelTypeUID(BINDING_ID, channelTypeID), DsChannelTypeProvider.getItemType(channelTypeID));
}
// load first channel values
onDeviceStateInitial(this.device);
return;
}
}
onDeviceRemoved(device);
}
use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.
the class DeviceDiscoveryService method onDeviceAddedInternal.
private void onDeviceAddedInternal(GeneralDeviceInformation device) {
boolean isSupported = false;
if (device instanceof Device) {
Device tempDevice = (Device) device;
if ((tempDevice.isSensorDevice() && deviceType.equals(tempDevice.getHWinfo().replaceAll("-", ""))) || (deviceType.equals(tempDevice.getHWinfo().substring(0, 2)) && (tempDevice.isDeviceWithOutput() || tempDevice.isBinaryInputDevice()) && tempDevice.isPresent())) {
isSupported = true;
}
} else if (device instanceof Circuit && DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString().equals(deviceType)) {
isSupported = true;
}
if (isSupported) {
ThingUID thingUID = getThingUID(device);
if (thingUID != null) {
Map<String, Object> properties = new HashMap<>(1);
properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue());
String deviceName = null;
if (StringUtils.isNotBlank(device.getName())) {
deviceName = device.getName();
} else {
// if no name is set, the dSID will be used as name
deviceName = device.getDSID().getValue();
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withBridge(bridgeUID).withLabel(deviceName).build();
thingDiscovered(discoveryResult);
} else {
if (device instanceof Device) {
logger.debug("Discovered unsupported device hardware type '{}' with uid {}", ((Device) device).getHWinfo(), device.getDSUID());
}
}
} else {
if (device instanceof Device) {
logger.debug("Discovered device with disabled or no output mode. Device was not added to inbox. " + "Device information: hardware info: {}, dSUID: {}, device-name: {}, output value: {}", ((Device) device).getHWinfo(), device.getDSUID(), device.getName(), ((Device) device).getOutputMode());
}
}
}
Aggregations