use of org.eclipse.smarthome.binding.homematic.internal.model.HmDevice in project smarthome by eclipse.
the class UidUtilsTest method testGeneratedThingUIDHasExpectedFormat.
@Test
public void testGeneratedThingUIDHasExpectedFormat() {
HmDevice hmDevice = createDimmerHmDevice();
Bridge bridge = createHomematicBridge();
ThingUID thingUID = UidUtils.generateThingUID(hmDevice, bridge);
assertThat(thingUID.getAsString(), is("homematic:HM-LC-Dim1-Pl3:myBridge:ABC12345678"));
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDevice in project smarthome by eclipse.
the class HomematicBridgeHandler method reloadAllDeviceValues.
@Override
public void reloadAllDeviceValues() {
for (Thing hmThing : getThing().getThings()) {
try {
HmDevice device = gateway.getDevice(UidUtils.getHomematicAddress(hmThing));
gateway.triggerDeviceValuesReload(device);
} catch (HomematicClientException ex) {
logger.warn("{}", ex.getMessage());
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDevice in project smarthome by eclipse.
the class DeleteDeviceVirtualDatapointHandler method handleCommand.
@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
dp.setValue(value);
if (MiscUtils.isTrueValue(dp.getValue())) {
try {
HmDatapoint deleteMode = dp.getChannel().getDatapoint(HmDatapointInfo.createValuesInfo(dp.getChannel(), VIRTUAL_DATAPOINT_NAME_DELETE_DEVICE_MODE));
HmDevice device = dp.getChannel().getDevice();
int flag = -1;
switch(deleteMode.getOptionValue()) {
case MODE_RESET:
flag = 1;
break;
case MODE_FORCE:
flag = 2;
break;
case MODE_DEFER:
flag = 4;
}
if (flag == -1) {
logger.info("Can't delete device '{}' from gateway '{}', DELETE_MODE is LOCKED", device.getAddress(), gateway.getId());
} else {
gateway.getRpcClient(device.getHmInterface()).deleteDevice(device, flag);
}
} finally {
gateway.disableDatapoint(dp, AbstractHomematicGateway.DEFAULT_DISABLE_DELAY);
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDevice in project smarthome by eclipse.
the class ListDevicesParser method parse.
@Override
@SuppressWarnings("unchecked")
public Collection<HmDevice> parse(Object[] message) throws IOException {
message = (Object[]) message[0];
Map<String, HmDevice> devices = new HashMap<String, HmDevice>();
for (int i = 0; i < message.length; i++) {
Map<String, ?> data = (Map<String, ?>) message[i];
boolean isDevice = !StringUtils.contains(toString(data.get("ADDRESS")), ":");
if (isDevice) {
String address = getSanitizedAddress(data.get("ADDRESS"));
String type = MiscUtils.validateCharacters(toString(data.get("TYPE")), "Device type", "-");
String id = toString(data.get("ID"));
String firmware = toString(data.get("FIRMWARE"));
HmDevice device = new HmDevice(address, hmInterface, type, config.getGatewayInfo().getId(), id, firmware);
device.addChannel(new HmChannel(type, CONFIGURATION_CHANNEL_NUMBER));
devices.put(address, device);
} else {
// channel
String deviceAddress = getSanitizedAddress(data.get("PARENT"));
HmDevice device = devices.get(deviceAddress);
String type = toString(data.get("TYPE"));
Integer number = toInteger(data.get("INDEX"));
device.addChannel(new HmChannel(type, number));
}
}
return devices.values();
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDevice in project smarthome by eclipse.
the class AbstractHomematicGateway method createGatewayDevice.
/**
* Creates a virtual device for handling variables, scripts and other special gateway functions.
*/
private HmDevice createGatewayDevice() {
String type = String.format("%s-%s", HmDevice.TYPE_GATEWAY_EXTRAS, StringUtils.upperCase(id));
HmDevice device = new HmDevice(HmDevice.ADDRESS_GATEWAY_EXTRAS, getDefaultInterface(), type, config.getGatewayInfo().getId(), null, null);
device.setName(HmDevice.TYPE_GATEWAY_EXTRAS);
device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_EXTRAS, HmChannel.CHANNEL_NUMBER_EXTRAS));
device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_VARIABLE, HmChannel.CHANNEL_NUMBER_VARIABLE));
device.addChannel(new HmChannel(HmChannel.TYPE_GATEWAY_SCRIPT, HmChannel.CHANNEL_NUMBER_SCRIPT));
return device;
}
Aggregations