Search in sources :

Example 11 with HmChannel

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;
}
Also used : HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) HashMap(java.util.HashMap) Collection(java.util.Collection) IOException(java.io.IOException) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HashSet(java.util.HashSet) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 12 with HmChannel

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));
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) DimmerHelper.createDimmerHmChannel(org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerHmChannel) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Example 13 with HmChannel

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);
}
Also used : HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) Before(org.junit.Before)

Example 14 with HmChannel

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"));
}
Also used : ChannelGroupTypeUID(org.eclipse.smarthome.core.thing.type.ChannelGroupTypeUID) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) DimmerHelper.createDimmerHmChannel(org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerHmChannel) Test(org.junit.Test)

Example 15 with HmChannel

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;
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)

Aggregations

HmChannel (org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)35 HmDatapoint (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)19 HmDevice (org.eclipse.smarthome.binding.homematic.internal.model.HmDevice)9 DimmerHelper.createDimmerHmChannel (org.eclipse.smarthome.binding.homematic.test.util.DimmerHelper.createDimmerHmChannel)7 Test (org.junit.Test)7 HmDatapointInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo)6 JavaTest (org.eclipse.smarthome.test.java.JavaTest)5 ArrayList (java.util.ArrayList)4 HomematicClientException (org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException)4 HashMap (java.util.HashMap)3 HmDatapointConfig (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig)3 IOException (java.io.IOException)2 BatteryTypeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.BatteryTypeVirtualDatapointHandler)2 ButtonVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ButtonVirtualDatapointHandler)2 DeleteDeviceModeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceModeVirtualDatapointHandler)2 DeleteDeviceVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceVirtualDatapointHandler)2 DisplayOptionsVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DisplayOptionsVirtualDatapointHandler)2 FirmwareVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.FirmwareVirtualDatapointHandler)2 HmwIoModuleVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.HmwIoModuleVirtualDatapointHandler)2 OnTimeAutomaticVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.OnTimeAutomaticVirtualDatapointHandler)2