wotpy.wot.exposed.thing

Classes that represent Things exposed by a servient.

Classes

ExposedThing(servient, thing) An entity that serves to define the behavior of a Thing.
class wotpy.wot.exposed.thing.ExposedThing(servient, thing)

Bases: object

An entity that serves to define the behavior of a Thing. An application uses this class when it acts as the Thing ‘server’.

class HandlerKeys

Bases: wotpy.utils.enums.EnumListMixin

Enumeration of handler keys.

INVOKE_ACTION = 'invoke_action'
OBSERVE = 'observe'
RETRIEVE_PROPERTY = 'retrieve_property'
UPDATE_PROPERTY = 'update_property'
class InteractionStateKeys

Bases: wotpy.utils.enums.EnumListMixin

Enumeration of interaction state keys.

PROPERTY_VALUES = 'property_values'
actions

Returns a dictionary of ThingAction items.

add_action(name, action_init, action_handler=None)

Adds an Action to the Thing object as defined by the action argument of type ThingActionInit and updates th,e Thing Description.

add_event(name, event_init)

Adds an event to the Thing object as defined by the event argument of type ThingEventInit and updates the Thing Description.

add_property(name, property_init, value=None)

Adds a Property defined by the argument and updates the Thing Description. Takes an instance of ThingPropertyInit as argument.

destroy()

Stop serving external requests for the Thing and destroy the object. Note that eventual unregistering should be done before invoking this method.

emit_event(event_name, payload)

Emits an the event initialized with the event name specified by the event_name argument and data specified by the payload argument.

events

Returns a dictionary of ThingEvent items.

expose()

Start serving external requests for the Thing, so that WoT interactions using Properties, Actions and Events will be possible.

id

Returns the ID of the Thing.

invoke_action(name, input_value=None)

Invokes an Action with the given parameters and yields with the invocation result.

on_event(name)

Returns an Observable for the Event specified in the name argument, allowing subscribing to and unsubscribing from notifications.

on_property_change(name)

Returns an Observable for the Property specified in the name argument, allowing subscribing to and unsubscribing from notifications.

on_td_change()

Returns an Observable, allowing subscribing to and unsubscribing from notifications to the Thing Description.

properties

Returns a dictionary of ThingProperty items.

read_property(name)

Takes the Property name as the name argument, then requests from the underlying platform and the Protocol Bindings to retrieve the Property on the remote Thing and return the result. Returns a Future that resolves with the Property value or rejects with an Error.

remove_action(name)

Removes the Action specified by the name argument, updates the Thing Description and returns the object.

remove_event(name)

Removes the event specified by the name argument, updates the Thing Description and returns the object.

remove_property(name)

Removes the Property specified by the name argument, updates the Thing Description and returns the object.

servient

Servient that contains this ExposedThing.

set_action_handler(name, action_handler)

Takes name as string argument and action_handler as argument of type ActionHandler. Sets the handler function for the specified Action matched by name. Throws on error. Returns a reference to the same object for supporting chaining.

set_property_read_handler(name, read_handler)

Takes name as string argument and read_handler as argument of type PropertyReadHandler. Sets the handler function for reading the specified Property matched by name. Throws on error. Returns a reference to the same object for supporting chaining.

set_property_write_handler(name, write_handler)

Takes name as string argument and write_handler as argument of type PropertyWriteHandler. Sets the handler function for writing the specified Property matched by name. Throws on error. Returns a reference to the same object for supporting chaining.

subscribe(*args, **kwargs)

Subscribes to changes on the TD of this thing.

thing

Returns the object that represents the Thing beneath this ExposedThing.

write_property(name, value)

Takes the Property name as the name argument and the new value as the value argument, then requests from the underlying platform and the Protocol Bindings to update the Property on the remote Thing and return the result. Returns a Future that resolves on success or rejects with an Error.