IoticAgent.IOT.RemotePoint module

class IoticAgent.IOT.RemotePoint.RemoteControl(client, subid, pointid, lid)

Bases: IoticAgent.IOT.RemotePoint.RemotePoint

Helper object for Control Subscription. A subscription the connection you have to another Thing’s control. This object allows you to pass data to the other Things control in two ways, ask and tell:

ask where you “fire and forget” - the receiving object doesn’t have to let you know whether it has actioned your request

tell where you expect the receiving object to let you know whether or not has actioned your request

When you attach to a Control this object will be returned from IoticAgent.IOT.Thing module Thing.attach.

ask(data, mime=None)

Request a remote control to do something. Ask is “fire-and-forget” in that you won’t receive any notification of the success or otherwise of the action at the far end.

Raises:
  • IOTException – Infrastructure problem detected
  • LinkException – Communications problem between you and the infrastructure
Parameters:
  • data – The data you want to share
  • mime (string, optional) – The mime type of the data you’re sharing. See: IoticAgent.IOT.Point module Feed.share)
ask_async(data, mime=None)
get_template()

Retreive IoticAgent.IOT.PointValueHelper module PointDataObject instance to use with this control.

tell(data, timeout=10, mime=None)

Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback

Example

data = {"thermostat":18.0}
retval = r_thermostat.tell(data, timeout=10, mime=None)
if retval is not True:
    print("Thermostat not reset - reason: {reason}".format(reason=retval))
Returns:
Return type:True on success or else returns the reason (string) one of
"timeout"     # The request-specified timeout has been reached.
"unreachable" # The remote control is not associated with an agent
              #     or is not reachable in some other way.
"failed"      # The remote control indicates it did not perform
              #     the request.
Raises:
  • IOTException – Infrastructure problem detected
  • LinkException – Communications problem between you and the infrastructure
Parameters:
  • data – The data you want to share
  • timeout (int, optional) – Default 10. The delay in seconds before your tell request times out
  • mime (string, optional) – See: IoticAgent.IOT.Point module Feed.share
tell_async(data, timeout=10, mime=None)

Asyncronous version of IoticAgent.IOT.RemotePoint module RemoteControl.tell.

Note

payload contains the success and reason keys they are not separated out as in the synchronous version

class IoticAgent.IOT.RemotePoint.RemoteFeed(client, subid, pointid, lid)

Bases: IoticAgent.IOT.RemotePoint.RemotePoint

Helper object for Feed Subscription.

A subscription the connection you have to another Thing’s feed. This object allows you to simulate a feed being received by your Thing and also to return you the last known received feed data.

When you subscribe to a Feed this object will be returned from IoticAgent.IOT.Thing module Thing.follow. This helper object provides simulate() and get_last()

get_last()
Returns:None if no recent data is available for this point or a dict.

Dict contains:

'data' # (decoded or raw bytes)
'mime' # (None, unless payload was not decoded and has a mime type)
'time' # (datetime representing UTC timestamp of share)

Note

Shorthand for get_recent(1).

get_recent(count)

Get the last instance(s) of feeddata from the feed. Useful if the remote Thing doesn’t publish very often.

Returns:An iterable of dicts (in chronologically ascending order) containing
'data' # (decoded or raw bytes)
'mime' # (None, unless payload was not decoded and has a mime type)
'time' # (datetime representing UTC timestamp of share)
Parameters:count (integer) – How many recent instances to retrieve. High values might be floored to a maximum as defined by the container.

Note

Feed data is iterable as soon as it arrives, rather than when the request completes.

get_recent_async(count, callback)

Similar to get_recent except instead of returning an iterable, passes each dict to the given function which must accept a single argument.

Returns:The request.
Parameters:callback (function) – instead of returning an iterable, pass each dict (as described above) to the given function which must accept a single argument. Nothing is returned.
simulate(data, mime=None)

Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn’t publish very often.

Parameters:
  • data – The data you want to use to simulate the arrival of remote feed data
  • mime (string, optional) – The mime type of your data. See: IoticAgent.IOT.Point module Feed.share
class IoticAgent.IOT.RemotePoint.RemotePoint(client, subid, pointid, lid)

Bases: object

Base class for remote point types

guid

The Globally Unique ID of the Point you’ve followed (or attached to) in hex form (undashed).

lid

Local id of thing which is following to this feed / attached to this control

subid

Advanced users only The global subscription ID for the connection to this remote point in hex form (undashed).