Search in sources :

Example 6 with Device

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.

the class DeviceDiscoveryService method getThingUID.

private ThingUID getThingUID(GeneralDeviceInformation device) {
    ThingUID bridgeUID = bridgeHandler.getThing().getUID();
    ThingTypeUID thingTypeUID = null;
    if (device instanceof Device) {
        Device tempDevice = (Device) device;
        thingTypeUID = new ThingTypeUID(BINDING_ID, tempDevice.getHWinfo().substring(0, 2));
        if (tempDevice.isSensorDevice() && deviceType.equals(tempDevice.getHWinfo().replaceAll("-", ""))) {
            thingTypeUID = new ThingTypeUID(BINDING_ID, deviceType);
        }
    } else {
        thingTypeUID = new ThingTypeUID(BINDING_ID, DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString());
    }
    if (getSupportedThingTypes().contains(thingTypeUID)) {
        String thingDeviceId = device.getDSID().toString();
        ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, thingDeviceId);
        return thingUID;
    } else {
        return null;
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID)

Example 7 with Device

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.

the class DeviceStatusManagerImpl method handleEvent.

@Override
public void handleEvent(EventItem eventItem) {
    if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName()) || EventNames.DEVICE_BINARY_INPUT_EVENT.equals(eventItem.getName())) {
        logger.debug("Detect {} eventItem = {}", eventItem.getName(), eventItem.toString());
        Device dev = getDeviceOfEvent(eventItem);
        if (dev != null) {
            if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())) {
                dev.setDeviceSensorByEvent(eventItem);
            } else {
                DeviceBinarayInputEnum binaryInputType = DeviceBinarayInputEnum.getdeviceBinarayInput(Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_TYPE)));
                Short newState = Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_STATE));
                if (binaryInputType != null) {
                    dev.setBinaryInputState(binaryInputType, newState);
                }
            }
        }
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) DeviceBinarayInputEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum)

Example 8 with Device

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.

the class DeviceStatusManagerImpl method getDeviceOfEvent.

private Device getDeviceOfEvent(EventItem eventItem) {
    if (eventItem.getSource().get(EventResponseEnum.DSID) != null) {
        String dSID = eventItem.getSource().get(EventResponseEnum.DSID);
        Device dev = strucMan.getDeviceByDSID(dSID);
        if (dev == null) {
            dev = strucMan.getDeviceByDSUID(dSID);
        }
        return dev;
    }
    return null;
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device)

Example 9 with Device

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.

the class StructureManagerImpl method updateDevice.

@Override
public void updateDevice(Device device) {
    if (device != null) {
        int oldZoneID = -1;
        List<Short> oldGroups = null;
        Device internalDevice = this.getDeviceByDSID(device.getDSID());
        if (internalDevice != null) {
            if (device.getZoneId() != internalDevice.getZoneId()) {
                oldZoneID = internalDevice.getZoneId();
                internalDevice.setZoneId(device.getZoneId());
            }
            if (!internalDevice.getGroups().equals(device.getGroups())) {
                oldGroups = internalDevice.getGroups();
                internalDevice.setGroups(device.getGroups());
            }
            if (deleteDevice(oldZoneID, oldGroups, internalDevice)) {
                addDeviceToStructure(internalDevice);
            }
        }
    }
}
Also used : Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device)

Example 10 with Device

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device in project smarthome by eclipse.

the class StructureManagerImpl method handleStructure.

/**
 * This method build the digitalSTROM structure as an {@link HashMap} with the zone id as key
 * and an {@link HashMap} as value. This {@link HashMap} has the group id as key and a {@link List}
 * with all digitalSTROM {@link Device}s.<br>
 * <br>
 * <b>Note:</b> the zone id 0 is the broadcast address and the group id 0, too.
 */
private void handleStructure(List<Device> deviceList) {
    HashMap<Short, List<Device>> groupXHashMap = new HashMap<Short, List<Device>>();
    groupXHashMap.put((short) 0, deviceList);
    zoneGroupDeviceMap.put(0, groupXHashMap);
    for (Device device : deviceList) {
        addDeviceToStructure(device);
    }
}
Also used : HashMap(java.util.HashMap) Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) List(java.util.List) LinkedList(java.util.LinkedList)

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