Search in sources :

Example 1 with Device

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);
                    }
                }
            }
        }
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) Circuit(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit) DSID(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DSID)

Example 2 with Device

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));
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device)

Example 3 with Device

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);
                }
            }
        }
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) Circuit(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit) DSID(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DSID)

Example 4 with Device

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);
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 5 with 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());
        }
    }
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) HashMap(java.util.HashMap) Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Circuit(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit)

Aggregations

Device (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device)13 Circuit (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 DSID (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DSID)2 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 List (java.util.List)1 DeviceBinarayInputEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum)1 DeviceImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.impl.DeviceImpl)1 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)1 ThingStatusInfo (org.eclipse.smarthome.core.thing.ThingStatusInfo)1 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)1 ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)1