if (command.getItem().startsWith("Location")) { logger.debug("Received command for location [" + command.getItem() + "] from openhab"); remote = locationRegistry.get(getIdFromOpenHABCommand(command)); } else if (command.getItem().startsWith("Connection")) { logger.debug("Received command for connection [" + command.getItem() + "] from openhab"); remote = connectionRegistry.get(getIdFromOpenHABCommand(command)); } else if (command.getItem().startsWith("UnitGroup")) { logger.debug("Received command for unitgroup [" + command.getItem() + "] from openhab"); remote = unitGroupRegistry.get(getIdFromOpenHABCommand(command));
public SceneBindingOpenHABImpl() throws InstantiationException, JPNotAvailableException, InterruptedException { super(); try { registry = new RemoteControllerRegistryImpl<>(); factory = new SceneRemoteFactoryImpl(); hardwareSimulationMode = JPService.getProperty(JPHardwareSimulationMode.class).getValue(); this.registrySynchronizer = new RegistrySynchronizer<String, SceneRemote, UnitConfig, UnitConfig.Builder>(registry, Registries.getSceneRegistry().getSceneConfigRemoteRegistry(), Registries.getSceneRegistry(), factory) { @Override public boolean verifyConfig(final UnitConfig config) throws VerificationFailedException { return config.getEnablingState().getValue() == EnablingState.State.ENABLED; } }; } catch (final CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
try { hardwareSimulationMode = JPService.getProperty(JPHardwareSimulationMode.class).getValue(); locationRegistry = new RemoteControllerRegistryImpl<>(); connectionRegistry = new RemoteControllerRegistryImpl<>(); locationRemoteFactory = new LocationRemoteFactoryImpl(); connectionRemoteFactory = new ConnectionRemoteFactoryImpl(); unitGroupRegistry = new RemoteControllerRegistryImpl<>(); unitGroupRemoteFactory = new UnitGroupRemoteFactoryImpl(); unitGroupRegistrySynchronizer = new RegistrySynchronizer<String, UnitGroupRemote, UnitConfig, UnitConfig.Builder>(unitGroupRegistry, Registries.getUnitRegistry().getUnitGroupUnitConfigRemoteRegistry(), Registries.getUnitRegistry(), unitGroupRemoteFactory) {
@Override public void internalReceiveCommand(OpenhabCommandType.OpenhabCommand command) throws CouldNotPerformException { try { if (!command.hasOnOff() || !command.getOnOff().hasState()) { throw new CouldNotPerformException("Command does not have an onOff value required for scenes"); } logger.debug("Received command for scene [" + command.getItem() + "] from openhab"); sceneRegistry.get(getSceneIdFromOpenHABItem(command)).setActivationState(ActivationStateTransformer.transform(command.getOnOff().getState())); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Skip item update [" + command.getItem() + " = " + command.getOnOff() + "]!", ex); } }
public AppBindingOpenHABImpl() throws InstantiationException, JPNotAvailableException, InterruptedException { super(); try { registry = new RemoteControllerRegistryImpl<>(); factory = new AppRemoteFactoryImpl(); hardwareSimulationMode = JPService.getProperty(JPHardwareSimulationMode.class).getValue(); this.registrySynchronizer = new RegistrySynchronizer<String, AppRemote, UnitConfig, UnitConfig.Builder>(registry, Registries.getAppRegistry().getAppConfigRemoteRegistry(), Registries.getAppRegistry(), factory) { @Override public boolean verifyConfig(final UnitConfig config) throws VerificationFailedException { return config.getEnablingState().getValue() == EnablingState.State.ENABLED; } }; } catch (final CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
@Override public void internalReceiveCommand(OpenhabCommandType.OpenhabCommand command) throws CouldNotPerformException { try { if (!command.hasOnOff() || !command.getOnOff().hasState()) { throw new CouldNotPerformException("Command does not have an onOff value required for apps"); } logger.debug("Received command for app [" + command.getItem() + "] from openhab"); appRegistry.get(getIdFromOpenHABItem(command)).setActivationState(ActivationStateTransformer.transform(command.getOnOff().getState())); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Skip item update [" + command.getItem() + " = " + command.getOnOff() + "]!", ex); } }