本文整理汇总了Java中org.eclipse.smarthome.core.thing.binding.ThingHandler类的典型用法代码示例。如果您正苦于以下问题:Java ThingHandler类的具体用法?Java ThingHandler怎么用?Java ThingHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThingHandler类属于org.eclipse.smarthome.core.thing.binding包,在下文中一共展示了ThingHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(THING_TYPE_HOME)) {
TadoHomeHandler tadoHomeHandler = new TadoHomeHandler((Bridge) thing);
TadoDiscoveryService discoveryService = new TadoDiscoveryService(tadoHomeHandler);
bundleContext.registerService(DiscoveryService.class.getName(), discoveryService,
new Hashtable<String, Object>());
return tadoHomeHandler;
} else if (thingTypeUID.equals(THING_TYPE_ZONE)) {
return new TadoZoneHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_MOBILE_DEVICE)) {
return new TadoMobileDeviceHandler(thing);
}
return null;
}
示例2: removeHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected synchronized void removeHandler(ThingHandler thingHandler) {
if (thingHandler instanceof ZigBeeCoordinatorHandler) {
ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
if (serviceReg != null) {
// remove discovery service, if bridge handler is removed
ZigBeeDiscoveryService service = (ZigBeeDiscoveryService) bundleContext
.getService(serviceReg.getReference());
if (service != null) {
service.deactivate();
}
serviceReg.unregister();
discoveryServiceRegs.remove(thingHandler.getThing().getUID());
}
}
}
示例3: getBridgeHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
private synchronized WMBusBridgeHandler getBridgeHandler() {
if (this.bridgeHandler == null) {
Bridge bridge = getBridge();
if (bridge == null) {
return null;
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof WMBusBridgeHandler) {
this.bridgeHandler = (WMBusBridgeHandler) handler;
this.bridgeHandler.registerWMBusMessageListener(this);
} else {
return null;
}
}
return this.bridgeHandler;
}
示例4: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(WMBusBindingConstants.THING_TYPE_BRIDGE)) {
// create handler for WMBus bridge
logger.debug("Creating (handler for) WMBus bridge.");
if (thing instanceof Bridge) {
WMBusBridgeHandler handler = new WMBusBridgeHandler((Bridge) thing);
registerDiscoveryService(handler);
return handler;
} else {
return null;
}
} else if (thingTypeUID.equals(WMBusBindingConstants.THING_TYPE_TECHEM_HKV)) {
// create handler for Techem HKV device
logger.debug("Creating (handler for) TechemHKV device.");
return new WMBusTechemHKVHandler(thing);
} else {
return null;
}
}
示例5: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(MegaDBindingConstants.THING_TYPE_UID_BRIDGE)) {
MegaDBridgeHandler handler = new MegaDBridgeHandler((Bridge) thing);
return handler;
}
if (supportsThingType(thingTypeUID)) {
return new MegaDHandler(thing);
}
return null;
}
示例6: getMaxCubeBridgeHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
private synchronized MaxCubeBridgeHandler getMaxCubeBridgeHandler() {
if (this.bridgeHandler == null) {
Bridge bridge = getBridge();
if (bridge == null) {
logger.debug("Required bridge not defined for device {}.", maxDeviceSerial);
return null;
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof MaxCubeBridgeHandler) {
this.bridgeHandler = (MaxCubeBridgeHandler) handler;
this.bridgeHandler.registerDeviceStatusListener(this);
} else {
logger.debug("No available bridge handler found for {} bridge {} .", maxDeviceSerial,
bridge.getUID());
return null;
}
}
return this.bridgeHandler;
}
示例7: getBridgeHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
private synchronized Ip2WireBridgeHandler getBridgeHandler() {
if (this.bridgeHandler == null) {
Bridge bridge = getBridge();
if (bridge == null) {
logger.debug("Required bridge not defined for device {}.", deviceWhereAddress);
return null;
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof Ip2WireBridgeHandler) {
this.bridgeHandler = (Ip2WireBridgeHandler) handler;
this.bridgeHandler.registerDeviceStatusListener(this);
} else {
logger.debug("No available bridge handler found for {} bridge {} .", deviceWhereAddress,
bridge.getUID());
return null;
}
}
return this.bridgeHandler;
}
示例8: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ElementsDiscoveryService discoveryService = null;
if (ElementsBindingConstants.THING_TYPE_BASE.equals(thing.getThingTypeUID())) {
logger.debug("discovery service register");
ElementsBridgeHandler bridgetHandler = new ElementsBridgeHandler(thing, discoveryService);
discoveryService = new ElementsDiscoveryService((Bridge) thing, 15);
this.discoveryServiceReg = bundleContext.registerService(DiscoveryService.class.getName(), discoveryService,
new Hashtable<String, Object>());
logger.debug("done ElementsDiscoveryService");
return bridgetHandler;
}
return new ElementsThingHandler(thing);
}
示例9: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
logger.debug("MeteoStick thing factory: createHandler {} of type {}", thing.getThingTypeUID(), thing.getUID());
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (MeteostickBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new MeteostickBridgeHandler((Bridge) thing);
}
if (MeteostickSensorHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new MeteostickSensorHandler(thing);
}
return null;
}
示例10: updatePlayer
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
/**
* Update Listeners and child Squeeze Player Things
*
* @param event
*/
private void updatePlayer(PlayerUpdateEvent event) {
// update listeners like disco services
for (SqueezeBoxPlayerEventListener listener : squeezeBoxPlayerListeners) {
event.updateListener(listener);
}
// update our children
Bridge bridge = getThing();
if (bridge == null) {
return;
}
List<Thing> things = bridge.getThings();
for (Thing thing : things) {
ThingHandler handler = thing.getHandler();
if (handler instanceof SqueezeBoxPlayerEventListener && !squeezeBoxPlayerListeners.contains(handler)) {
event.updateListener((SqueezeBoxPlayerEventListener) handler);
}
}
}
示例11: getXiaomiBridgeHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
synchronized XiaomiBridgeHandler getXiaomiBridgeHandler() {
if (this.bridgeHandler == null) {
Bridge bridge = getBridge();
if (bridge == null) {
return null;
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof XiaomiBridgeHandler) {
this.bridgeHandler = (XiaomiBridgeHandler) handler;
this.bridgeHandler.registerItemListener(this);
} else {
return null;
}
}
return this.bridgeHandler;
}
示例12: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(THING_TYPE_STICK)) {
PlugwiseStickHandler handler = new PlugwiseStickHandler((Bridge) thing);
registerDiscoveryService(handler);
return handler;
} else if (thingTypeUID.equals(THING_TYPE_CIRCLE) || thingTypeUID.equals(THING_TYPE_CIRCLE_PLUS)
|| thingTypeUID.equals(THING_TYPE_STEALTH)) {
return new PlugwiseRelayDeviceHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SCAN)) {
return new PlugwiseScanHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SENSE)) {
return new PlugwiseSenseHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SWITCH)) {
return new PlugwiseSwitchHandler(thing);
}
return null;
}
示例13: childChanged
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
/**
* Helper method to recreate the {@link RioConstants#CHANNEL_CTLZONES} channel
*
* @param childHandler a non-null child handler that changed
* @param added true if the handler was added, false otherwise
* @throw IllegalArgumentException if childHandler is null
*/
private void childChanged(ThingHandler childHandler, boolean added) {
if (childHandler == null) {
throw new IllegalArgumentException("childHandler cannot be null");
}
if (childHandler instanceof RioZoneHandler) {
final RioHandlerCallback callback = ((RioZoneHandler) childHandler).getCallback();
if (callback != null) {
if (added) {
callback.addListener(RioConstants.CHANNEL_ZONENAME, handlerCallbackListener);
} else {
callback.removeListener(RioConstants.CHANNEL_ZONENAME, handlerCallbackListener);
}
}
refreshNamedHandler(gson, RioZoneHandler.class, RioConstants.CHANNEL_CTLZONES);
}
}
示例14: createHandler
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
@Nullable
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
SmartHomeDevice device;
if (HS110.is(thingTypeUID)) {
device = new EnergySwitchDevice();
} else if (LB130.is(thingTypeUID) || LB230.is(thingTypeUID)) {
device = new BulbDevice(thingTypeUID, COLOR_TEMPERATURE_LB130_MIN, COLOR_TEMPERATURE_LB130_MAX);
} else if (LB120.is(thingTypeUID)) {
device = new BulbDevice(thingTypeUID, COLOR_TEMPERATURE_LB120_MIN, COLOR_TEMPERATURE_LB120_MAX);
} else if (TPLinkSmartHomeThingType.isSwitchingDevice(thingTypeUID)) {
device = new SwitchDevice();
} else if (TPLinkSmartHomeThingType.isBulbDevice(thingTypeUID)) {
device = new BulbDevice(thingTypeUID);
} else {
return null;
}
return new SmartHomeHandler(thing, device);
}
示例15: initializeBridge
import org.eclipse.smarthome.core.thing.binding.ThingHandler; //导入依赖的package包/类
private void initializeBridge(ThingHandler thingHandler, ThingStatus bridgeStatus) {
logger.debug("initializeBridge {} for thing {}", bridgeStatus, getThing().getUID());
config = getConfigAs(RFXComDeviceConfiguration.class);
if (config.deviceId == null || config.subType == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"RFXCOM device missing deviceId or subType");
} else if (thingHandler != null && bridgeStatus != null) {
bridgeHandler = (RFXComBridgeHandler) thingHandler;
bridgeHandler.registerDeviceStatusListener(this);
if (bridgeStatus == ThingStatus.ONLINE) {
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
}
} else {
updateStatus(ThingStatus.OFFLINE);
}
}