coherence.upnp.core.device (module) — Cohen3 0.8.0 documentation

# coherence.upnp.core.device (module)

## Devices

This module contains two classes describing UPnP devices.

### `Device`

The base class for all devices.

### `RootDevice`

A device representing a root device.

class `Device`(parent=None, udn=None)

  Bases: `eventdispatcher.eventdispatcher.EventDispatcher`, `coherence.log.LogAble`

  Represents a UPnP’s device, but this is not a root device, it’s the base class used for any device. See `RootDevice` if you want a root device.

  Changed in version 0.9.0:

  - Migrated from louie/dispatcher to EventDispatcher

  - The emitted events changed:

    > - Coherence.UPnP.Device.detection_completed => device_detection_completed
    > - Coherence.UPnP.Device.remove_client => device_remove_client

  - New events: device_service_notified, device_got_client

  - Changes some class variables to benefit from the EventDispatcher’s properties:

    > - `client`
    > - `devices`
    > - `services`
    > - `client`
    > - `detection_completed`

  `logCategory` = 'device'
  `client`

    Defined by `ControlPoint`. It should be one of:

    > - Initialized instance of a class `MediaServerClient`
    > - Initialized instance of a class `MediaRendererClient`
    > - Initialized instance of a class `InternetGatewayDeviceClient`

    Whenever a client is set an event will be sent notifying it by `on_client()`.

  `icons`

    A list of the device icons.

  `devices`

    A list of the device devices.

  `services`

    A list of the device services.

  `detection_completed`

    To know whenever the device detection has completed. Defaults to False and it will be set automatically to True by the class method `receiver()`.

  `as_dict`()
  `remove`(*args)
  `receiver`(*args, **kwargs)
  `service_detection_failed`(device)
  `get_id`()
  `get_uuid`()
  `get_embedded_devices`()
  `get_embedded_device_by_type`(type)
  `get_services`()
  `get_service_by_type`(type)
  `add_service`(service)

    Add a service to the device. Also we check if service already notified, and trigger the callback if needed. We also connect the device to service in case the service still not completed his detection in order that the device knows when the service has completed his detection.

    Parameters: | service (object) – A service which should be an initialized instance of `Service`

  `remove_service_with_usn`(service_usn)
  `add_device`(device)
  `get_friendly_name`()
  `get_device_type`()
  `get_friendly_device_type`()
  `get_markup_name`()
  `get_device_type_version`()
  `set_client`(client)
  `get_client`()
  `on_client`(*args)

    Automatically triggered whenever a client is set or changed. Emmit an event notifying that the client has changed.

    New in version 0.9.0.

  `renew_service_subscriptions`()

    iterate over device’s services and renew subscriptions

  `unsubscribe_service_subscriptions`()

    Iterate over device’s services and unsubscribe subscriptions

  `parse_device`(d)
  `get_location`()
  `get_usn`()
  `get_upnp_version`()
  `get_urlbase`()
  `get_presentation_url`()
  `get_parent_id`()
  `make_fullyqualified`(url)
  `as_tuples`()

class `RootDevice`(infos)

  Bases: `coherence.upnp.core.device.Device`

  Description for a root device.

  Changed in version 0.9.0:

  - Migrated from louie/dispatcher to EventDispatcher

  - The emitted events changed:

    > - Coherence.UPnP.RootDevice.detection_completed => root_device_detection_completed
    > - Coherence.UPnP.RootDevice.removed => root_device_removed

  `root_detection_completed`

    To know whenever the root device detection has completed. Defaults to False and it will be set automatically to True by the class method `device_detect()`.

  `remove`(*args)
  `get_usn`()
  `get_st`()
  `get_location`()
  `get_upnp_version`()
  `get_urlbase`()
  `get_host`()
  `is_local`()
  `is_remote`()
  `device_detect`(*args, **kwargs)

    This method is automatically triggered whenever the property of the base class `Device.detection_completed` is set to True. Here we perform some more operations, before the `RootDevice` emits an event notifying that the root device detection has completed.

  `add_device`(device)
  `get_devices`()
  `parse_description`()
  `make_fullyqualified`(url)

    Be aware that this function returns a byte string