本文整理汇总了Java中org.eclipse.smarthome.core.thing.Thing.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Thing.setProperty方法的具体用法?Java Thing.setProperty怎么用?Java Thing.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.smarthome.core.thing.Thing
的用法示例。
在下文中一共展示了Thing.setProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNewConfig
import org.eclipse.smarthome.core.thing.Thing; //导入方法依赖的package包/类
@Override
public void onNewConfig(LxServer server) {
logger.trace("Processing new configuration");
Thing thing = getThing();
thing.setProperty(MINISERVER_PROPERTY_MINISERVER_NAME, server.getMiniserverName());
thing.setProperty(MINISERVER_PROPERTY_PROJECT_NAME, server.getProjectName());
thing.setProperty(MINISERVER_PROPERTY_CLOUD_ADDRESS, server.getCloudAddress());
thing.setProperty(MINISERVER_PROPERTY_PHYSICAL_LOCATION, server.getLocation());
ArrayList<Channel> channels = new ArrayList<>();
ThingBuilder builder = editThing();
controls.clear();
logger.trace("Building new channels ({} controls)", server.getControls().size());
for (LxControl control : server.getControls().values()) {
List<Channel> newChannels = createChannelsForControl(control);
if (newChannels != null) {
channels.addAll(newChannels);
for (Channel channel : newChannels) {
ChannelUID id = channel.getUID();
controls.put(id, control);
}
}
}
logger.trace("Sorting channels");
channels.sort(new Comparator<Channel>() {
@Override
public int compare(Channel c1, Channel c2) {
String label = c1.getLabel();
if (label == null) {
return 1;
}
return label.compareTo(c2.getLabel());
}
});
logger.trace("Updating thing");
builder.withChannels(channels);
updateThing(builder.build());
}
示例2: updateThingFromDevice
import org.eclipse.smarthome.core.thing.Thing; //导入方法依赖的package包/类
/**
* Updates things from device model.
*
* @param thing Thing to be updated.
* @param device Device model with new data.
*/
private void updateThingFromDevice(Thing thing, DeviceModel device) {
if (thing == null || device == null) {
throw new IllegalArgumentException("thing or device is null, cannot perform update");
}
if (device.getPresent() == 1) {
thing.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null));
thing.setProperty(PROPERTY_FIRMWARE_VERSION, device.getFirmwareVersion());
if (device.isTempSensor() && device.getTemperature() != null) {
updateThingChannelState(thing, CHANNEL_TEMP, new DecimalType(device.getTemperature().getCelsius()));
}
if (device.isPowermeter() && device.getPowermeter() != null) {
updateThingChannelState(thing, CHANNEL_ENERGY, new DecimalType(device.getPowermeter().getEnergy()));
updateThingChannelState(thing, CHANNEL_POWER, new DecimalType(device.getPowermeter().getPower()));
}
if (device.isSwitchableOutlet() && device.getSwitch() != null) {
updateThingChannelState(thing, CHANNEL_MODE, new StringType(device.getSwitch().getMode()));
updateThingChannelState(thing, CHANNEL_LOCKED,
BigDecimal.ZERO.equals(device.getSwitch().getLock()) ? OpenClosedType.OPEN
: OpenClosedType.CLOSED);
updateThingChannelState(thing, CHANNEL_DEVICE_LOCKED,
BigDecimal.ZERO.equals(device.getSwitch().getDevicelock()) ? OpenClosedType.OPEN
: OpenClosedType.CLOSED);
if (device.getSwitch().getState() == null) {
updateThingChannelState(thing, CHANNEL_SWITCH, UnDefType.UNDEF);
} else {
updateThingChannelState(thing, CHANNEL_SWITCH,
SwitchModel.ON.equals(device.getSwitch().getState()) ? OnOffType.ON : OnOffType.OFF);
}
}
if (device.isHeatingThermostat() && device.getHkr() != null) {
updateThingChannelState(thing, CHANNEL_MODE, new StringType(device.getHkr().getMode()));
updateThingChannelState(thing, CHANNEL_LOCKED,
BigDecimal.ZERO.equals(device.getHkr().getLock()) ? OpenClosedType.OPEN
: OpenClosedType.CLOSED);
updateThingChannelState(thing, CHANNEL_DEVICE_LOCKED,
BigDecimal.ZERO.equals(device.getHkr().getDevicelock()) ? OpenClosedType.OPEN
: OpenClosedType.CLOSED);
updateThingChannelState(thing, CHANNEL_ACTUALTEMP,
new DecimalType(HeatingModel.toCelsius(device.getHkr().getTist())));
updateThingChannelState(thing, CHANNEL_SETTEMP,
new DecimalType(HeatingModel.toCelsius(device.getHkr().getTsoll())));
updateThingChannelState(thing, CHANNEL_ECOTEMP,
new DecimalType(HeatingModel.toCelsius(device.getHkr().getAbsenk())));
updateThingChannelState(thing, CHANNEL_COMFORTTEMP,
new DecimalType(HeatingModel.toCelsius(device.getHkr().getKomfort())));
updateThingChannelState(thing, CHANNEL_RADIATOR_MODE,
new StringType(device.getHkr().getRadiatorMode()));
if (device.getHkr().getNextchange() != null) {
if (device.getHkr().getNextchange().getEndperiod() == 0) {
updateThingChannelState(thing, CHANNEL_NEXTCHANGE, UnDefType.UNDEF);
} else {
final Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(device.getHkr().getNextchange().getEndperiod() * 1000L));
updateThingChannelState(thing, CHANNEL_NEXTCHANGE, new DateTimeType(calendar));
}
if (HeatingModel.TEMP_FRITZ_UNDEFINED.equals(device.getHkr().getNextchange().getTchange())) {
updateThingChannelState(thing, CHANNEL_NEXTTEMP, UnDefType.UNDEF);
} else {
updateThingChannelState(thing, CHANNEL_NEXTTEMP,
new DecimalType(HeatingModel.toCelsius(device.getHkr().getNextchange().getTchange())));
}
}
if (device.getHkr().getBatterylow() == null) {
updateThingChannelState(thing, CHANNEL_BATTERY, UnDefType.UNDEF);
} else {
updateThingChannelState(thing, CHANNEL_BATTERY,
HeatingModel.BATTERY_ON.equals(device.getHkr().getBatterylow()) ? OnOffType.ON
: OnOffType.OFF);
}
}
} else {
thing.setStatusInfo(new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Device not present"));
}
}
示例3: onNewConfig
import org.eclipse.smarthome.core.thing.Thing; //导入方法依赖的package包/类
@Override
public void onNewConfig(LxServer server) {
logger.trace("Processing new configuration");
Thing thing = getThing();
thing.setProperty(MINISERVER_PROPERTY_MINISERVER_NAME, server.getMiniserverName());
thing.setProperty(MINISERVER_PROPERTY_PROJECT_NAME, server.getProjectName());
thing.setProperty(MINISERVER_PROPERTY_CLOUD_ADDRESS, server.getCloudAddress());
thing.setProperty(MINISERVER_PROPERTY_PHYSICAL_LOCATION, server.getLocation());
thing.setProperty(Thing.PROPERTY_FIRMWARE_VERSION, server.getSwVersion());
thing.setProperty(Thing.PROPERTY_SERIAL_NUMBER, server.getSerial());
thing.setProperty(Thing.PROPERTY_MAC_ADDRESS, server.getMacAddress());
ArrayList<Channel> channels = new ArrayList<>();
ThingBuilder builder = editThing();
controls.clear();
dynamicStateDescriptionProvider.removeAllDescriptions();
logger.trace("Building new channels ({} controls)", server.getControls().size());
for (LxControl control : server.getControls().values()) {
List<Channel> newChannels = createChannelsForControl(control);
if (newChannels != null) {
channels.addAll(newChannels);
for (Channel channel : newChannels) {
ChannelUID id = channel.getUID();
controls.put(id, control);
}
}
}
logger.trace("Sorting channels");
channels.sort(new Comparator<Channel>() {
@Override
public int compare(Channel c1, Channel c2) {
String label = c1.getLabel();
if (label == null) {
return 1;
}
return label.compareTo(c2.getLabel());
}
});
logger.trace("Updating thing");
builder.withChannels(channels);
updateThing(builder.build());
}