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