use of org.openhab.core.thing.Bridge in project org.openhab.binding.zwave by openhab.
the class ZWaveThingHandler method initialize.
@Override
public void initialize() {
logger.debug("Initializing ZWave thing handler {}.", getThing().getUID());
final BigDecimal cfgNodeId = (BigDecimal) getConfig().get(ZWaveBindingConstants.CONFIGURATION_NODEID);
if (cfgNodeId == null) {
logger.debug("NodeID is not set in {}", getThing().getUID());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, ZWaveBindingConstants.OFFLINE_NODEID_UNSET);
return;
}
nodeId = cfgNodeId.intValue();
if (nodeId < 1 || nodeId > 232) {
logger.debug("NodeID ({}) out of range for {}", cfgNodeId, getThing().getUID());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, ZWaveBindingConstants.OFFLINE_NODEID_INVALID);
return;
}
// We need to set the status to OFFLINE so that the framework calls our notification handlers
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, ZWaveBindingConstants.OFFLINE_CTLR_OFFLINE);
// Make sure the thingType is set correctly from the database
if (updateThingType() == true) {
// The thing will have been disposed of so let's exit!
return;
}
// TODO: Shouldn't the framework do this for us???
Bridge bridge = getBridge();
if (bridge != null) {
ThingHandler handler = bridge.getHandler();
if (handler instanceof ZWaveControllerHandler) {
ZWaveControllerHandler bridgeHandler = (ZWaveControllerHandler) handler;
if (bridgeHandler.getOwnNodeId() != 0) {
bridgeStatusChanged(bridge.getStatusInfo());
}
}
}
}
use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.
the class AlarmDecoderHandlerFactory method createHandler.
// Marked as Nullable only to fix incorrect redundant null check complaints from null annotations
@Override
@Nullable
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (THING_TYPE_IPBRIDGE.equals(thingTypeUID)) {
IPBridgeHandler bridgeHandler = new IPBridgeHandler((Bridge) thing);
registerDiscoveryService(bridgeHandler);
return bridgeHandler;
} else if (THING_TYPE_SERIALBRIDGE.equals(thingTypeUID)) {
SerialBridgeHandler bridgeHandler = new SerialBridgeHandler((Bridge) thing, serialPortManager);
registerDiscoveryService(bridgeHandler);
return bridgeHandler;
} else if (THING_TYPE_ZONE.equals(thingTypeUID)) {
return new ZoneHandler(thing);
} else if (THING_TYPE_RFZONE.equals(thingTypeUID)) {
return new RFZoneHandler(thing);
} else if (THING_TYPE_VZONE.equals(thingTypeUID)) {
return new VZoneHandler(thing);
} else if (THING_TYPE_KEYPAD.equals(thingTypeUID)) {
return new KeypadHandler(thing);
} else if (THING_TYPE_LRR.equals(thingTypeUID)) {
return new LRRHandler(thing);
}
return null;
}
use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.
the class ADThingHandler method initDeviceState.
/**
* Initialize device state and set status for handler. Should be called at the end of initialize(). Also called by
* bridgeStatusChanged() when bridge status changes from OFFLINE to ONLINE. Calls initChannelState() to initialize
* channels if setting status to ONLINE.
*/
protected void initDeviceState() {
logger.trace("Initializing device state");
Bridge bridge = getBridge();
if (bridge == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "No bridge configured");
} else if (bridge.getStatus() == ThingStatus.ONLINE) {
initChannelState();
updateStatus(ThingStatus.ONLINE);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
}
}
use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.
the class Cm11aLampHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("**** Cm11aLampHandler handleCommand command = {}, channelUID = {}", command.toString(), channelUID.getAsString());
x10Function = 0;
Bridge bridge = getBridge();
if (bridge == null) {
logger.debug("Unable to handle command. Bridge is null.");
return;
}
this.channelUID = channelUID;
Cm11aBridgeHandler cm11aHandler = (Cm11aBridgeHandler) bridge.getHandler();
if (cm11aHandler != null && cm11aHandler.getThing().getStatus().equals(ThingStatus.ONLINE)) {
if (OnOffType.ON.equals(command)) {
desiredState = OnOffType.ON;
} else if (OnOffType.OFF.equals(command)) {
desiredState = OnOffType.OFF;
} else if (command instanceof PercentType) {
desiredState = (PercentType) command;
} else if (command instanceof RefreshType) {
// Refresh is triggered by framework during startup.
// Force the lamp off by indicating it is currently on and we want it off
// Start with it off
desiredState = PercentType.ZERO;
logger.info("Received REFRESH command for switch {}", houseUnitCode);
} else {
logger.error("Ignoring unknown command received for device: {}", houseUnitCode);
}
if (!(desiredState instanceof UnDefType)) {
X10Interface x10Interface = cm11aHandler.getX10Interface();
x10Interface.scheduleHWUpdate(this);
}
} else {
logger.error("Attempted to change switch {} cm11a is not online", houseUnitCode);
}
}
use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.
the class CBusGroupHandler method getCBusNetworkHandler.
@Nullable
private CBusNetworkHandler getCBusNetworkHandler() {
Bridge bridge = getBridge();
if (bridge == null) {
logger.debug("Required bridge not defined for device .");
return null;
}
ThingHandler handler = bridge.getHandler();
if (handler instanceof CBusNetworkHandler) {
return (CBusNetworkHandler) handler;
}
logger.debug("No available bridge handler found for bridge: {}", bridge.getUID());
return null;
}
Aggregations