Module "urn_schemas-upnp-org_device_DimmableLight_1"

Standard device; "urn:schemas-upnp-org:device:DimmableLight:1". When required, it returns a single function which generates a new device table on every call (it takes no parameters). The upnp.devicefactory module takes the device/service tables to build device/service objects.

Requires to implement the following elements;

  • device.statetodevice handler to update device status when the target values have changed on the UPnP side

Tables

DimmableLight fields/properties Members of the DimmableLight object

Functions

statefromdevice (self, power, level) Sets provided values into the UPnP device (software representation).
statetodevice (self, power, level, callback) Sets provided values into the actual device (hardware).


Tables

DimmableLight fields/properties
Members of the DimmableLight object

Fields

  • dimlevels: (integer) the number of levels the device supports, indexed from 0 (eg. 15 means levels 0-15, so 16 levels)
  • zeroisoff: (boolean) when true then the device is completely off at dimlevel 0
  • lastpower: (boolean) the last power value set in/received from the hardware
  • lastlevel: (integer) the last dimlevel value set in/received from the hardware

Functions

statefromdevice (self, power, level)
Sets provided values into the UPnP device (software representation). This method must be called from the devicedriver to update changes from the hardware to the UPnP device.

Parameters:

  • self: (table) dimmablelight device object
  • power: (boolean) powerstate to set (true = on)
  • level: (integer) dim level to set (0 to dimlevels)
statetodevice (self, power, level, callback)
Sets provided values into the actual device (hardware). This method must be overriden to communicate with the hardware.
NOTE: setting values in hardware might require use of a coroutine for a socket/IO scheduler. Hence the callback to allow the creation of (for example) a Copas task to send the command to the hardware over an outgoing TCP connection. If you do not do this when using possibly blocking IO calls, then the call might become a blocking call, freezing the entire engine.

Parameters:

  • self: (table) dimmablelight device object
  • power: (boolean) powerstate to set (true = on)
  • level: (integer) dim device level to set (0 to dimlevels)
  • callback: (function) callback function to call when hardware has been updated (has no arguments)

Valid XHTML 1.0!