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;
}
}
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);
}
}
}
}
}
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;
}
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);
}
}
}
}
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);
}
}
Aggregations