Module "urn_schemas-upnp-org_service_SwitchPower_1"

Standard service; "urn:schemas-upnp-org:service:SwitchPower:1". When required, it returns a single function which generates a new service 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;

  • service.serviceStateTable.Target.afterset = function(self, oldval) ... end to process the changed Target value

Functions

afterset (self, oldval) Implement this handler to add SwitchPower capability.


Functions

afterset (self, oldval)
Implement this handler to add SwitchPower capability. The handler should implement the actual switch behaviour and set the 'Status' variable to the new value when done.

Parameters:

  • self: statevariable object for the 'Target' statevariable
  • oldval: the previous value of 'Target'

Example:

-- Create a new SwitchPower service
local service = require("upnp.services.urn_schemas-upnp-org_service_SwitchPower_1")()


-- add implementation
service.serviceStateTable[1].afterset = function(self, oldval)
    -- do something useful here...
    print("Setting the SwitchPower value to", self:get(), "from", oldval)


    -- When done update value of Status to reflect the change
    self:getstatevariable("status"):set(self:get())
end

Valid XHTML 1.0!