use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class HomematicTypeGeneratorImpl method generate.
@Override
public void generate(HmDevice device) {
if (thingTypeProvider != null) {
ThingTypeUID thingTypeUID = UidUtils.generateThingTypeUID(device);
ThingType tt = thingTypeProvider.getInternalThingType(thingTypeUID);
if (tt == null || device.isGatewayExtras()) {
logger.debug("Generating ThingType for device '{}' with {} datapoints", device.getType(), device.getDatapointCount());
List<ChannelGroupType> groupTypes = new ArrayList<ChannelGroupType>();
for (HmChannel channel : device.getChannels()) {
List<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>();
// those will be populated dynamically during thing initialization
if (!channel.isReconfigurable()) {
// generate channel
for (HmDatapoint dp : channel.getDatapoints()) {
if (!isIgnoredDatapoint(dp) && dp.getParamsetType() == HmParamsetType.VALUES) {
ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(dp);
ChannelType channelType = channelTypeProvider.getInternalChannelType(channelTypeUID);
if (channelType == null) {
channelType = createChannelType(dp, channelTypeUID);
channelTypeProvider.addChannelType(channelType);
}
ChannelDefinition channelDef = new ChannelDefinitionBuilder(dp.getName(), channelType.getUID()).build();
channelDefinitions.add(channelDef);
}
}
}
// generate group
ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
ChannelGroupType groupType = channelGroupTypeProvider.getInternalChannelGroupType(groupTypeUID);
if (groupType == null || device.isGatewayExtras()) {
String groupLabel = String.format("%s", WordUtils.capitalizeFully(StringUtils.replace(channel.getType(), "_", " ")));
groupType = ChannelGroupTypeBuilder.instance(groupTypeUID, groupLabel).withChannelDefinitions(channelDefinitions).build();
channelGroupTypeProvider.addChannelGroupType(groupType);
groupTypes.add(groupType);
}
}
tt = createThingType(device, groupTypes);
thingTypeProvider.addThingType(tt);
}
addFirmware(device);
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class StateContactVirtualDatapointHandler method initialize.
@Override
public void initialize(HmDevice device) {
if (isApplicable(device)) {
HmChannel channelOne = device.getChannel(1);
if (channelOne != null) {
HmDatapointInfo dpStateInfo = HmDatapointInfo.createValuesInfo(channelOne, DATAPOINT_NAME_STATE);
HmDatapoint dpState = channelOne.getDatapoint(dpStateInfo);
if (dpState != null) {
addDatapoint(device, 1, getName(), HmValueType.BOOL, convertState(dpState.getValue()), true);
}
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class DisplayTextVirtualDatapoint method initialize.
@Override
public void initialize(HmDevice device) {
if (isDisplay(device)) {
for (HmChannel channel : device.getChannels()) {
if (channel.hasDatapoint(new HmDatapointInfo(HmParamsetType.VALUES, channel, DATAPOINT_NAME_SUBMIT))) {
for (int i = 1; i <= getLineCount(device); i++) {
addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_LINE + i, HmValueType.STRING, null, false);
addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_ICON + i, Icon.class);
if (!isEpDisplay(device)) {
addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_COLOR + i, Color.class);
}
}
if (isEpDisplay(device)) {
addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPER, Beeper.class);
HmDatapoint bc = addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPCOUNT, HmValueType.INTEGER, 1, false);
bc.setMinValue(0);
bc.setMaxValue(15);
HmDatapoint bd = addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPINTERVAL, HmValueType.INTEGER, 1, false);
bd.setMinValue(10);
bd.setMaxValue(160);
bd.setStep(10);
addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_LED, Led.class);
}
addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_SUBMIT, HmValueType.BOOL, false, false);
}
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class HmwIoModuleVirtualDatapointHandler method initialize.
@Override
public void initialize(HmDevice device) {
if (device.getType().startsWith(DEVICE_TYPE_WIRED_IO_MODULE)) {
for (HmChannel channel : device.getChannels()) {
if (channel.getNumber() >= 7) {
HmDatapointInfo dpInfoState = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_STATE);
HmDatapointInfo dpInfoValue = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_VALUE);
boolean hasStateDatapoint = channel.hasDatapoint(dpInfoState);
boolean hasValueDatapoint = channel.hasDatapoint(dpInfoValue);
if (hasStateDatapoint && !hasValueDatapoint) {
HmDatapoint dp = addDatapoint(channel.getDevice(), channel.getNumber(), DATAPOINT_NAME_VALUE, HmValueType.FLOAT, 0.0, false);
dp.setMinValue(0.0);
dp.setMaxValue(1000.0);
dp.setVirtual(false);
} else if (hasValueDatapoint && !hasStateDatapoint) {
HmDatapoint dp = addDatapoint(channel.getDevice(), channel.getNumber(), DATAPOINT_NAME_STATE, HmValueType.BOOL, false, false);
dp.setVirtual(false);
}
}
if (channel.getNumber() >= 21) {
HmDatapointInfo dpInfoCalibration = new HmDatapointInfo(HmParamsetType.MASTER, channel, DATAPOINT_NAME_CALIBRATION);
if (!channel.hasDatapoint(dpInfoCalibration)) {
HmDatapoint dp = new HmDatapoint(DATAPOINT_NAME_CALIBRATION, DATAPOINT_NAME_CALIBRATION, HmValueType.INTEGER, 0, false, HmParamsetType.MASTER);
dp.setMinValue(-127);
dp.setMaxValue(127);
addDatapoint(channel, dp);
dp.setVirtual(false);
}
}
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmChannel in project smarthome by eclipse.
the class ButtonVirtualDatapointHandler method initialize.
@Override
public void initialize(HmDevice device) {
for (HmChannel channel : device.getChannels()) {
if (channel.hasPressDatapoint()) {
HmDatapoint dp = addDatapoint(device, channel.getNumber(), getName(), HmValueType.STRING, null, false);
dp.setTrigger(true);
dp.setOptions(new String[] { CommonTriggerEvents.SHORT_PRESSED, CommonTriggerEvents.LONG_PRESSED, CommonTriggerEvents.DOUBLE_PRESSED });
}
}
}
Aggregations