Search in sources :

Example 21 with HmChannel

use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.

the class OnTimeAutomaticVirtualDatapointHandler method handleCommand.

@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
    if (!getName().equals(dp.getName())) {
        HmChannel channel = dp.getChannel();
        HmDatapoint dpOnTime = channel.getDatapoint(HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_ON_TIME));
        if (dpOnTime != null) {
            gateway.sendDatapoint(dpOnTime, new HmDatapointConfig(), getVirtualDatapointValue(channel), null);
        } else {
            logger.warn("Can't find ON_TIME datapoint in channel '{}' in device '{}', ignoring virtual datapoint '{}'", channel.getNumber(), channel.getDevice().getAddress(), getName());
        }
        gateway.sendDatapointIgnoreVirtual(dp, dpConfig, value);
    } else {
        dp.setValue(value);
    }
}
Also used : HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 22 with HmChannel

use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.

the class RssiVirtualDatapointHandler method handleEvent.

@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
    HmChannel channel = dp.getChannel();
    Object value = getRssiValue(channel);
    HmDatapoint vdpRssi = getVirtualDatapoint(channel);
    vdpRssi.setValue(value);
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 23 with HmChannel

use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel 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();
}
Also used : HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)

Example 24 with HmChannel

use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.

the class SignalStrengthVirtualDatapointHandler method handleEvent.

@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
    HmChannel channel = dp.getChannel();
    Integer value = getRssiValue(channel);
    if (value != null) {
        Integer strength = Math.max(Math.abs(value), RSSI_START);
        strength = strength > RSSI_START + RSSI_STEP * RSSI_UNITS ? 0 : RSSI_UNITS - ((strength - RSSI_START) / RSSI_STEP);
        HmDatapoint vdpRssi = getVirtualDatapoint(channel);
        vdpRssi.setValue(strength);
    }
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 25 with HmChannel

use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.

the class AbstractHomematicGateway method triggerDeviceValuesReload.

@Override
public void triggerDeviceValuesReload(HmDevice device) {
    logger.debug("Triggering values reload for device '{}'", device.getAddress());
    for (HmChannel channel : device.getChannels()) {
        channel.setInitialized(false);
    }
    gatewayAdapter.reloadDeviceValues(device);
}
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