use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class AbstractHomematicGateway method loadAllDeviceMetadata.
@Override
public void loadAllDeviceMetadata() throws IOException {
cancelLoadAllMetadata = false;
// load all device descriptions
List<HmDevice> deviceDescriptions = getDeviceDescriptions();
// loading datapoints for all channels
Set<String> loadedDevices = new HashSet<String>();
Map<String, Collection<HmDatapoint>> datapointsByChannelIdCache = new HashMap<String, Collection<HmDatapoint>>();
for (HmDevice device : deviceDescriptions) {
if (!cancelLoadAllMetadata) {
try {
logger.trace("Loading metadata for device '{}' of type '{}'", device.getAddress(), device.getType());
if (device.isGatewayExtras()) {
loadChannelValues(device.getChannel(HmChannel.CHANNEL_NUMBER_VARIABLE));
loadChannelValues(device.getChannel(HmChannel.CHANNEL_NUMBER_SCRIPT));
} else {
for (HmChannel channel : device.getChannels()) {
logger.trace(" Loading channel {}", channel);
// speed up metadata generation a little bit for equal channels in the gateway devices
if ((DEVICE_TYPE_VIRTUAL.equals(device.getType()) || DEVICE_TYPE_VIRTUAL_WIRED.equals(device.getType())) && channel.getNumber() > 1) {
HmChannel previousChannel = device.getChannel(channel.getNumber() - 1);
cloneAllDatapointsIntoChannel(channel, previousChannel.getDatapoints());
} else {
String channelId = String.format("%s:%s:%s", channel.getDevice().getType(), channel.getDevice().getFirmware(), channel.getNumber());
Collection<HmDatapoint> cachedDatapoints = datapointsByChannelIdCache.get(channelId);
if (cachedDatapoints != null) {
// clone all datapoints
cloneAllDatapointsIntoChannel(channel, cachedDatapoints);
} else {
logger.trace(" Loading datapoints into channel {}", channel);
addChannelDatapoints(channel, HmParamsetType.MASTER);
addChannelDatapoints(channel, HmParamsetType.VALUES);
// the data point set might change depending on the selected mode.
if (!channel.isReconfigurable()) {
datapointsByChannelIdCache.put(channelId, channel.getDatapoints());
}
}
}
}
}
prepareDevice(device);
loadedDevices.add(device.getAddress());
gatewayAdapter.onDeviceLoaded(device);
} catch (IOException ex) {
logger.warn("Can't load device with address '{}' from gateway '{}': {}", device.getAddress(), id, ex.getMessage());
}
}
}
if (!cancelLoadAllMetadata) {
devices.keySet().retainAll(loadedDevices);
}
initialized = true;
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class RpcClientTest method valuesParamsetIsLoadedForChannel.
@Test
public void valuesParamsetIsLoadedForChannel() throws IOException {
HmChannel channel = createDimmerHmChannel();
rpcClient.setChannelDatapointValues(channel, HmParamsetType.VALUES);
assertThat(rpcClient.numberOfCalls.get(GET_PARAMSET_NAME), is(1));
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class BaseConverterTest method setup.
@Before
public void setup() {
HmChannel stubChannel = new HmChannel("stubChannel", 0);
stubChannel.setDevice(new HmDevice("LEQ123456", HmInterface.RF, "HM-STUB-DEVICE", "", "", ""));
floatDp.setChannel(stubChannel);
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class UidUtilsTest method testGeneratedChannelGroupTypeUIDHasExpectedFormat.
@Test
public void testGeneratedChannelGroupTypeUIDHasExpectedFormat() {
HmChannel hmChannel = createDimmerHmChannel();
ChannelGroupTypeUID channelGroupTypeUID = UidUtils.generateChannelGroupTypeUID(hmChannel);
assertThat(channelGroupTypeUID.getAsString(), is("homematic:HM-LC-Dim1-Pl3_1"));
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class DimmerHelper method createDimmerHmChannel.
public static HmChannel createDimmerHmChannel() {
HmChannel hmChannel = new HmChannel("HM-LC-Dim1-Pl3", 1);
hmChannel.setDevice(createDimmerHmDevice());
return hmChannel;
}
Aggregations