use of org.openhab.binding.hue.internal.handler.HueBridgeHandler in project openhab-addons by openhab.
the class HueCommandExtension method execute.
@Override
public void execute(String[] args, Console console) {
if (args.length == 2) {
Thing thing = null;
try {
ThingUID thingUID = new ThingUID(args[0]);
thing = thingRegistry.get(thingUID);
} catch (IllegalArgumentException e) {
thing = null;
}
ThingHandler thingHandler = null;
HueBridgeHandler bridgeHandler = null;
HueGroupHandler groupHandler = null;
if (thing != null) {
thingHandler = thing.getHandler();
if (thingHandler instanceof HueBridgeHandler) {
bridgeHandler = (HueBridgeHandler) thingHandler;
} else if (thingHandler instanceof HueGroupHandler) {
groupHandler = (HueGroupHandler) thingHandler;
}
}
if (thing == null) {
console.println("Bad thing id '" + args[0] + "'");
printUsage(console);
} else if (thingHandler == null) {
console.println("No handler initialized for the thingUID '" + args[0] + "'");
printUsage(console);
} else if (bridgeHandler == null && groupHandler == null) {
console.println("'" + args[0] + "' is neither a Hue bridgeUID nor a Hue groupThingUID");
printUsage(console);
} else {
switch(args[1]) {
case USER_NAME:
if (bridgeHandler != null) {
String userName = bridgeHandler.getUserName();
console.println("Your user name is " + (userName != null ? userName : "undefined"));
} else {
console.println("'" + args[0] + "' is not a Hue bridgeUID");
printUsage(console);
}
break;
case SCENES:
if (bridgeHandler != null) {
bridgeHandler.listScenesForConsole().forEach(console::println);
} else if (groupHandler != null) {
groupHandler.listScenesForConsole().forEach(console::println);
}
break;
default:
printUsage(console);
break;
}
}
} else {
printUsage(console);
}
}
use of org.openhab.binding.hue.internal.handler.HueBridgeHandler in project openhab-addons by openhab.
the class HueDeviceDiscoveryService method setThingHandler.
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof HueBridgeHandler) {
HueBridgeHandler localHandler = (HueBridgeHandler) handler;
hueBridgeHandler = localHandler;
bridgeUID = handler.getThing().getUID();
i18nProvider = localHandler.getI18nProvider();
localeProvider = localHandler.getLocaleProvider();
}
}
use of org.openhab.binding.hue.internal.handler.HueBridgeHandler in project openhab-addons by openhab.
the class HueDeviceDiscoveryService method deactivate.
@Override
public void deactivate() {
removeOlderResults(new Date().getTime(), bridgeUID);
final HueBridgeHandler handler = hueBridgeHandler;
if (handler != null) {
handler.unregisterDiscoveryListener();
}
}
use of org.openhab.binding.hue.internal.handler.HueBridgeHandler in project openhab-addons by openhab.
the class HueDeviceDiscoveryService method stopScan.
@Override
protected synchronized void stopScan() {
super.stopScan();
final HueBridgeHandler handler = hueBridgeHandler;
if (handler != null) {
removeOlderResults(getTimestampOfLastScan(), handler.getThing().getUID());
}
}
use of org.openhab.binding.hue.internal.handler.HueBridgeHandler in project openhab-addons by openhab.
the class HueDeviceDiscoveryService method startScan.
@Override
public void startScan() {
final HueBridgeHandler handler = hueBridgeHandler;
if (handler != null) {
List<FullLight> lights = handler.getFullLights();
for (FullLight l : lights) {
addLightDiscovery(l);
}
List<FullSensor> sensors = handler.getFullSensors();
for (FullSensor s : sensors) {
addSensorDiscovery(s);
}
List<FullGroup> groups = handler.getFullGroups();
for (FullGroup g : groups) {
addGroupDiscovery(g);
}
// search for unpaired lights
handler.startSearch();
}
}
Aggregations