org.teleal.cling.model.meta.RemoteDevice Java Examples

The following examples show how to use org.teleal.cling.model.meta.RemoteDevice. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpnpMovie.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
	if (device.getType().getNamespace().equals("schemas-upnp-org")
			&& device.getType().getType().equals("MediaServer")) {
		if (!found) {
			try {
				if (!TextUtils.isEmpty(device.getDetails().getSerialNumber())) {
					if (device.getDetails().getSerialNumber().equals(mFileSource.getUpnpSerialNumber())) {
						startBrowse(device);
						found = true;
					}
				} else {
					if (device.getIdentity().getUdn().toString().equals(mFileSource.getUpnpSerialNumber())) {
						startBrowse(device);
						found = true;
					}
				}
			} catch (Exception e) {}
		}
	}
}
 
Example #2
Source File: UpnpTvShow.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
    if (device.getType().getNamespace().equals("schemas-upnp-org")
            && device.getType().getType().equals("MediaServer")) {
        if (!found) {
            try {
                if (!TextUtils.isEmpty(device.getDetails().getSerialNumber())) {
                    if (device.getDetails().getSerialNumber().equals(mFileSource.getUpnpSerialNumber())) {
                        startBrowse(device);
                        found = true;
                    }
                } else {
                    if (device.getIdentity().getUdn().toString().equals(mFileSource.getUpnpSerialNumber())) {
                        startBrowse(device);
                        found = true;
                    }
                }
            } catch (Exception e) {}
        }
    }
}
 
Example #3
Source File: UpnpManager.java    From HomeGenie-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
        public void remoteDeviceDiscoveryFailed(Registry registry, final RemoteDevice device, final Exception ex) {
            _hgcontext.runOnUiThread(new Runnable() {
                public void run() {
//                    Toast.makeText(_hgcontext.getApplicationContext(), "UpNP FAILED Discovery: " + device.getDisplayString(), 2000).show();
                }
            });
            deviceRemoved(device);
        }
 
Example #4
Source File: AddUpnpFilesourceDialog.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
	if (device.getType().getNamespace().equals("schemas-upnp-org")
			&& device.getType().getType().equals("MediaServer")) {
		deviceAdded(new UpnpDevice(device));
	}
}
 
Example #5
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {

    // add only Sonos devices
    if (device.getDetails().getManufacturerDetails().getManufacturer().toUpperCase().contains("SONOS")) {

        UDN udn = device.getIdentity().getUdn();
        boolean existingDevice = false;

        logger.info("Found a Sonos device ({}) with UDN {}",
                device.getDetails().getModelDetails().getModelNumber(), udn);

        // Check if we already received a configuration for this
        // device through the .cfg
        SonosZonePlayer thePlayer = sonosZonePlayerCache.getByUDN(udn.getIdentifierString());

        if (thePlayer == null) {
            // Add device to the cached Configs
            thePlayer = new SonosZonePlayer(udn.getIdentifierString(), self);
            thePlayer.setUdn(udn);

            sonosZonePlayerCache.add(thePlayer);
        }

        thePlayer.setDevice(device);
        thePlayer.setService(upnpService);
        thePlayer.updateCurrentZoneName();

        // add GENA service to capture zonegroup information
        Service service = device.findService(new UDAServiceId("ZoneGroupTopology"));
        SonosSubscriptionCallback callback = new SonosSubscriptionCallback(service, interval);
        upnpService.getControlPoint().execute(callback);
    } else {
        logger.debug("A non-Sonos device ({}) is found and will be ignored", device.getDisplayString());
    }
}
 
Example #6
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
public SonosZonePlayer getByDevice(RemoteDevice device) {
    if (device != null) {
        Iterator<SonosZonePlayer> it = this.iterator();
        while (it.hasNext()) {
            SonosZonePlayer aPlayer = it.next();
            if (aPlayer.getDevice() != null && aPlayer.getDevice().equals(device)) {
                return aPlayer;
            }
        }
    }
    return null;
}
 
Example #7
Source File: SonosZonePlayer.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param device the device to set
 */
public void setDevice(RemoteDevice device) {
    this.device = device;
    if (upnpService != null && device != null) {
        isConfigured = true;
        enableGENASubscriptions();
    }
}
 
Example #8
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device) {
    logger.debug("Discovery started: " + device.getDisplayString());
}
 
Example #9
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice device, Exception ex) {
    logger.debug("Discovery failed: " + device.getDisplayString() + " => " + ex);
}
 
Example #10
Source File: SonosZonePlayer.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @return the device
 */
public RemoteDevice getDevice() {
    return device;
}
 
Example #11
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceUpdated(Registry registry, RemoteDevice device) {
    logger.trace("Remote device updated: " + device.getDisplayString());
}
 
Example #12
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
    logger.trace("Remote device removed: " + device.getDisplayString());
}
 
Example #13
Source File: SonosBinding.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
public void processVariableMap(RemoteDevice device, Map<String, StateVariableValue> values) {

    if (device != null && values != null) {

        SonosZonePlayer associatedPlayer = sonosZonePlayerCache.getByDevice(device);

        if (associatedPlayer == null) {
            logger.debug("There is no Sonos Player defined matching the device {}", device);
            return;
        }

        for (String stateVariable : values.keySet()) {

            // find all the CommandTypes that are defined for each
            // StateVariable
            List<SonosCommandType> supportedCommands = SonosCommandType.getCommandByVariable(stateVariable);

            StateVariableValue status = values.get(stateVariable);

            for (SonosCommandType sonosCommandType : supportedCommands) {

                // create a new State based on the type of Sonos Command and
                // the status value in the map
                Type newState = null;
                try {
                    newState = createStateForType((Class<? extends State>) sonosCommandType.getTypeClass(),
                            status.getValue().toString());
                } catch (BindingConfigParseException e) {
                    logger.error("Error parsing a value {} to a state variable of type {}", status.toString(),
                            sonosCommandType.getTypeClass().toString());
                }

                for (SonosBindingProvider provider : providers) {
                    List<String> qualifiedItems = provider.getItemNames(
                            sonosZonePlayerCache.getByDevice(device).getId(), sonosCommandType.getSonosCommand());
                    List<String> qualifiedItemsByUDN = provider.getItemNames(
                            sonosZonePlayerCache.getByDevice(device).getUdn().getIdentifierString(),
                            sonosCommandType.getSonosCommand());

                    for (String item : qualifiedItemsByUDN) {
                        if (!qualifiedItems.contains(item)) {
                            qualifiedItems.add(item);
                        }
                    }

                    for (String anItem : qualifiedItems) {
                        // get the openHAB commands attached to each Item at
                        // this given Provider
                        List<Command> commands = provider.getCommands(anItem, sonosCommandType.getSonosCommand());

                        if (provider.getAcceptedDataTypes(anItem).contains(sonosCommandType.getTypeClass())) {
                            if (newState != null) {
                                eventPublisher.postUpdate(anItem, (State) newState);
                            } else {
                                throw new IllegalClassException("Cannot process update for the command of type "
                                        + sonosCommandType.toString());
                            }
                        } else {
                            logger.warn("Cannot cast {} to an accepted state type for item {}",
                                    sonosCommandType.getTypeClass().toString(), anItem);
                        }
                    }
                }
            }
        }
    }
}
 
Example #14
Source File: UpnpManager.java    From HomeGenie-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
    deviceRemoved(device);
}
 
Example #15
Source File: AddUpnpFilesourceDialog.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
	deviceRemoved(new UpnpDevice(device));
}
 
Example #16
Source File: UpnpManager.java    From HomeGenie-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
    deviceAdded(device);
}
 
Example #17
Source File: UpnpTvShow.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {}
 
Example #18
Source File: UpnpManager.java    From HomeGenie-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice device) {
    deviceAdded(device);
}
 
Example #19
Source File: UpnpMovie.java    From Mizuu with Apache License 2.0 4 votes vote down vote up
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {}