本文整理汇总了Java中org.openhab.binding.homematic.internal.model.HmDevice类的典型用法代码示例。如果您正苦于以下问题:Java HmDevice类的具体用法?Java HmDevice怎么用?Java HmDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HmDevice类属于org.openhab.binding.homematic.internal.model包,在下文中一共展示了HmDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterateAllDatapoints
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
Object[] result = rpcClient.getAllValues(getDefaultInterface());
try {
for (int i = 0; i < result.length; i++) {
@SuppressWarnings("unchecked")
Map<String, ?> entryMap = (Map<String, ?>) result[i];
HmDevice device = parseDevice(entryMap);
addBatteryInfo(device);
logger.trace("{}", device);
for (HmChannel channel : device.getChannels()) {
for (HmDatapoint dp : channel.getDatapoints()) {
logger.trace(" {}", dp.toDumpString());
DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(),
dp.getName());
callback.iterate(bindingConfig, dp);
}
}
}
} catch (Exception ex) {
throw new HomematicClientException(ex.getMessage(), ex);
}
}
示例2: parseDevice
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Parses the device informations into the binding model.
*/
@SuppressWarnings("unchecked")
private HmDevice parseDevice(Map<String, ?> deviceData) throws IllegalAccessException {
HmDevice device = new HmDevice();
FieldUtils.writeField(device, "address", deviceData.get("ADDRESS"), true);
FieldUtils.writeField(device, "type", deviceData.get("TYPE"), true);
FieldUtils.writeField(device, "hmInterface", HmInterface.HOMEGEAR, true);
Object[] channelList = (Object[]) deviceData.get("CHANNELS");
for (int i = 0; i < channelList.length; i++) {
Map<String, ?> channelData = (Map<String, ?>) channelList[i];
device.addChannel(parseChannel(device, channelData));
}
return device;
}
示例3: addBatteryInfo
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Adds the battery info datapoint to the specified device if the device has
* batteries.
*/
protected void addBatteryInfo(HmDevice device) throws HomematicClientException {
HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType());
if (battery != null) {
for (HmChannel channel : device.getChannels()) {
if ("0".equals(channel.getNumber())) {
try {
logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo());
HmDatapoint dp = new HmDatapoint();
FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true);
FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true);
FieldUtils.writeField(dp, "valueType", 20, true);
dp.setValue(battery.getInfo());
channel.addDatapoint(dp);
} catch (IllegalAccessException ex) {
throw new HomematicClientException(ex.getMessage(), ex);
}
}
}
}
}
示例4: updateStatus
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Updates the thing status based on device status.
*/
private void updateStatus(HmDevice device) throws BridgeHandlerNotAvailableException, IOException {
loadHomematicChannelValues(device.getChannel(0));
ThingStatus oldStatus = thing.getStatus();
ThingStatus newStatus = ThingStatus.ONLINE;
ThingStatusDetail newDetail = ThingStatusDetail.NONE;
if (device.isFirmwareUpdating()) {
newStatus = ThingStatus.OFFLINE;
newDetail = ThingStatusDetail.FIRMWARE_UPDATING;
} else if (device.isUnreach()) {
newStatus = ThingStatus.OFFLINE;
newDetail = ThingStatusDetail.COMMUNICATION_ERROR;
} else if (device.isConfigPending() || device.isUpdatePending()) {
newDetail = ThingStatusDetail.CONFIGURATION_PENDING;
}
if (thing.getStatus() != newStatus || thing.getStatusInfo().getStatusDetail() != newDetail) {
updateStatus(newStatus, newDetail);
}
if (oldStatus == ThingStatus.OFFLINE && newStatus == ThingStatus.ONLINE) {
initialize();
}
}
示例5: parse
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@Override
public HmDatapointInfo parse(Object[] message) throws IOException {
String address;
Integer channel = 0;
String addressWithChannel = toString(message[1]);
if ("".equals(addressWithChannel)) {
address = HmDevice.ADDRESS_GATEWAY_EXTRAS;
channel = HmChannel.CHANNEL_NUMBER_VARIABLE;
} else {
String[] configParts = StringUtils.trimToEmpty(addressWithChannel).split(":");
address = getAddress(configParts[0]);
if (configParts.length > 1) {
channel = NumberUtils.createInteger(configParts[1]);
}
}
String name = toString(message[2]);
value = message[3];
return new HmDatapointInfo(address, HmParamsetType.VALUES, channel, name);
}
示例6: initialize
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@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);
}
}
}
}
示例7: newDevices
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@Override
public void newDevices(List<String> adresses) {
if (initialized) {
for (String address : adresses) {
try {
logger.debug("New device '{}' detected on gateway with id '{}'", address, id);
List<HmDevice> deviceDescriptions = getDeviceDescriptions();
for (HmDevice device : deviceDescriptions) {
if (device.getAddress().equals(address)) {
for (HmChannel channel : device.getChannels()) {
addChannelDatapoints(channel, HmParamsetType.MASTER);
addChannelDatapoints(channel, HmParamsetType.VALUES);
}
prepareDevice(device);
gatewayAdapter.onNewDevice(device);
}
}
} catch (Exception ex) {
logger.error("{}", ex.getMessage(), ex);
}
}
}
}
示例8: prepareDevice
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Adds virtual datapoints to the device.
*/
private void prepareDevice(HmDevice device) {
for (VirtualDatapointHandler vdph : virtualDatapointHandlers) {
vdph.initialize(device);
}
devices.put(device.getAddress(), device);
logger.debug("Loaded device '{}' ({}) with {} datapoints", device.getAddress(), device.getType(),
device.getDatapointCount());
if (logger.isTraceEnabled()) {
logger.trace("{}", device);
for (HmChannel channel : device.getChannels()) {
logger.trace(" {}", channel);
for (HmDatapoint dp : channel.getDatapoints()) {
logger.trace(" {}", dp);
}
}
}
}
示例9: getDeviceName
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Returns the device name for the given device type.
*/
public static String getDeviceName(HmDevice device) {
if (device.isGatewayExtras()) {
return getDescription(HmDevice.TYPE_GATEWAY_EXTRAS);
}
String deviceDescription = null;
boolean isTeam = device.getType().endsWith("-Team");
String type = isTeam ? StringUtils.remove(device.getType(), "-Team") : device.getType();
deviceDescription = getDescription(type);
if (deviceDescription != null && isTeam) {
deviceDescription += " Team";
}
return deviceDescription == null ? "No Description" : deviceDescription;
}
示例10: iterateAllDatapoints
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
Object[] result = rpcClient.getAllValues(getDefaultInterface());
try {
for (int i = 0; i < result.length; i++) {
@SuppressWarnings("unchecked")
Map<String, ?> entryMap = (Map<String, ?>) result[i];
HmDevice device = parseDevice(entryMap);
addBatteryInfo(device);
logger.trace("{}", device);
for (HmChannel channel : device.getChannels()) {
for (HmDatapoint dp : channel.getDatapoints()) {
logger.trace(" {}", dp.toDumpString());
DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(),
dp.getName());
callback.iterate(bindingConfig, dp);
}
}
}
} catch (Exception ex) {
throw new HomematicClientException(ex.getMessage(), ex);
}
}
示例11: parseDevice
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Parses the device informations into the binding model.
*/
@SuppressWarnings("unchecked")
private HmDevice parseDevice(Map<String, ?> deviceData) throws IllegalAccessException {
HmDevice device = new HmDevice();
FieldUtils.writeField(device, "address", deviceData.get("ADDRESS"), true);
FieldUtils.writeField(device, "type", deviceData.get("TYPE"), true);
FieldUtils.writeField(device, "hmInterface", HmInterface.HOMEGEAR, true);
Object[] channelList = (Object[]) deviceData.get("CHANNELS");
for (int i = 0; i < channelList.length; i++) {
Map<String, ?> channelData = (Map<String, ?>) channelList[i];
device.addChannel(parseChannel(device, channelData));
}
return device;
}
示例12: addBatteryInfo
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Adds the battery info datapoint to the specified device if the device has
* batteries.
*/
protected void addBatteryInfo(HmDevice device) throws HomematicClientException {
HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType());
if (battery != null) {
for (HmChannel channel : device.getChannels()) {
if ("0".equals(channel.getNumber())) {
try {
logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo());
HmDatapoint dp = new HmDatapoint();
FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true);
FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true);
FieldUtils.writeField(dp, "valueType", 20, true);
dp.setValue(battery.getInfo());
channel.addDatapoint(dp);
} catch (IllegalAccessException ex) {
throw new HomematicClientException(ex.getMessage(), ex);
}
}
}
}
}
示例13: parseChannel
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Parses the channel informations into the binding model.
*/
@SuppressWarnings("unchecked")
private HmChannel parseChannel(HmDevice device, Map<String, ?> channelData) throws IllegalAccessException {
HmChannel channel = new HmChannel();
FieldUtils.writeField(channel, "device", device, true);
FieldUtils.writeField(channel, "number", String.valueOf(channelData.get("INDEX")), true);
Map<String, ?> paramsList = (Map<String, ?>) channelData.get("PARAMSET");
for (String name : paramsList.keySet()) {
channel.addDatapoint(parseDatapoint(channel, name, (Map<String, ?>) paramsList.get(name)));
}
return channel;
}
示例14: getDatapoint
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
private HmDatapoint getDatapoint(String name, Object value, Number min, Number max, String channelNumber,
String deviceType) throws Exception {
HmDatapoint dp = new HmDatapoint();
FieldUtils.writeField(dp, "name", name, true);
FieldUtils.writeField(dp, "minValue", min, true);
FieldUtils.writeField(dp, "maxValue", max, true);
Object convertedValue = new TypeGuessAdapter().unmarshal(value == null ? null : value.toString());
if (convertedValue instanceof Boolean) {
FieldUtils.writeField(dp, "valueType", 2, true);
} else if (convertedValue instanceof Integer) {
FieldUtils.writeField(dp, "valueType", 8, true);
} else if (convertedValue instanceof Double) {
FieldUtils.writeField(dp, "valueType", 4, true);
} else {
FieldUtils.writeField(dp, "valueType", -1, true);
}
dp.setValue(convertedValue);
HmChannel channel = new HmChannel();
FieldUtils.writeField(dp, "channel", channel, true);
FieldUtils.writeField(channel, "number", channelNumber, true);
HmDevice device = new HmDevice();
FieldUtils.writeField(device, "type", StringUtils.defaultString(deviceType, ""), true);
FieldUtils.writeField(channel, "device", device, true);
return dp;
}
示例15: updateThing
import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
* Updates the thing for the given Homematic device.
*/
private void updateThing(HmDevice device) {
Thing hmThing = getThingByUID(UidUtils.generateThingUID(device, getThing()));
if (hmThing != null && hmThing.getHandler() != null) {
HomematicThingHandler thingHandler = (HomematicThingHandler) hmThing.getHandler();
thingHandler.thingUpdated(hmThing);
for (Channel channel : hmThing.getChannels()) {
thingHandler.handleRefresh(channel.getUID());
}
}
}