use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo in project smarthome by eclipse.
the class CcuValueParser method parse.
@Override
public Void parse(TclScriptDataList resultList) throws IOException {
if (resultList.getEntries() != null) {
for (TclScriptDataEntry entry : resultList.getEntries()) {
HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, entry.name);
HmDatapoint dp = channel.getDatapoint(dpInfo);
if (dp != null) {
dp.setValue(convertToType(dp, entry.value));
adjustRssiValue(dp);
} else {
// should never happen, but in case ...
logger.warn("Can't set value for datapoint '{}'", dpInfo);
}
}
}
return null;
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo in project smarthome by eclipse.
the class DisplayOptionsVirtualDatapointHandler method sendDatapoint.
private void sendDatapoint(VirtualGateway gateway, HmChannel channel, String dpName, Object newValue) throws IOException, HomematicClientException {
HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, dpName);
HmDatapoint dp = gateway.getDatapoint(dpInfo);
gateway.sendDatapoint(dp, new HmDatapointConfig(), newValue, null);
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo in project smarthome by eclipse.
the class OnTimeAutomaticVirtualDatapointHandler method initialize.
@Override
public void initialize(HmDevice device) {
for (HmChannel channel : device.getChannels()) {
HmDatapointInfo dpInfoOnTime = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_ON_TIME);
if (channel.hasDatapoint(dpInfoOnTime)) {
HmDatapointInfo dpInfoLevel = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_LEVEL);
HmDatapointInfo dpInfoState = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_STATE);
if (channel.hasDatapoint(dpInfoLevel) || channel.hasDatapoint(dpInfoState)) {
HmDatapoint dpOnTime = channel.getDatapoint(dpInfoOnTime);
HmDatapoint dpOnTimeAutomatic = dpOnTime.clone();
dpOnTimeAutomatic.setName(getName());
dpOnTimeAutomatic.setDescription(getName());
addDatapoint(channel, dpOnTimeAutomatic);
}
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo in project smarthome by eclipse.
the class DisplayOptionsParser method getAvailableOptions.
/**
* Returns all possible options from the given datapoint.
*/
private String[] getAvailableOptions(HmChannel channel, String datapointName) {
HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, datapointName);
HmDatapoint dp = channel.getDatapoint(dpInfo);
if (dp != null) {
String[] options = (String[]) ArrayUtils.remove(dp.getOptions(), 0);
for (String onOffString : onOff) {
int onIdx = ArrayUtils.indexOf(options, onOffString);
if (onIdx != -1) {
options[onIdx] = datapointName + "_" + onOffString;
}
}
return options;
}
return new String[0];
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo in project smarthome by eclipse.
the class HomematicThingHandler method handleConfigurationUpdate.
@Override
public void handleConfigurationUpdate(Map<String, Object> configurationParameters) throws ConfigValidationException {
super.handleConfigurationUpdate(configurationParameters);
try {
HomematicGateway gateway = getHomematicGateway();
HmDevice device = gateway.getDevice(UidUtils.getHomematicAddress(getThing()));
for (Entry<String, Object> configurationParameter : configurationParameters.entrySet()) {
String key = configurationParameter.getKey();
Object newValue = configurationParameter.getValue();
if (key.startsWith("HMP_")) {
key = StringUtils.removeStart(key, "HMP_");
Integer channelNumber = NumberUtils.toInt(StringUtils.substringBefore(key, "_"));
String dpName = StringUtils.substringAfter(key, "_");
HmDatapointInfo dpInfo = new HmDatapointInfo(device.getAddress(), HmParamsetType.MASTER, channelNumber, dpName);
HmDatapoint dp = device.getChannel(channelNumber).getDatapoint(dpInfo);
if (dp != null) {
try {
if (newValue != null) {
if (newValue instanceof BigDecimal) {
final BigDecimal decimal = (BigDecimal) newValue;
if (dp.isIntegerType()) {
newValue = decimal.intValue();
} else if (dp.isFloatType()) {
newValue = decimal.doubleValue();
}
}
if (ObjectUtils.notEqual(dp.isEnumType() ? dp.getOptionValue() : dp.getValue(), newValue)) {
sendDatapoint(dp, new HmDatapointConfig(), newValue);
}
}
} catch (IOException ex) {
logger.error("Error setting thing property {}: {}", dpInfo, ex.getMessage());
}
} else {
logger.error("Can't find datapoint for thing property {}", dpInfo);
}
}
}
gateway.triggerDeviceValuesReload(device);
} catch (HomematicClientException | GatewayNotAvailableException ex) {
logger.error("Error setting thing properties: {}", ex.getMessage(), ex);
}
}
Aggregations