API Reference

DataMailbox

class pydatamailbox.client.DataMailbox(account, devid, timeout=None, **kwargs)

Talk2M DataMailbox api client. This client only supports: getstatus, getewons, getewon, syncdata, getdata

The authentication is done by providing either username and password or token.

getdata(ewon_id, tag_id, from_ts, to_ts, limit=None)

getdata is used as a “one-shot” request to retrieve filtered data based on specific criteria. It is not destined to grab historical data with the same timestamp or enormous data involving the use of the moreData filter.

Parameters:
  • ewon_id (int) – The ID of the single Ewon gateway for which data from DataMailbox is requested.
  • tag_id (int) – ID of the single tag for which data from DataMailbox is requested.
  • from_ts (str) – Timestamp after which data should be returned. No data older than this time stamp will be sent in ISO format.
  • to_ts (str) – Timestamp before which data should be returned. No data newer than this time stamp will be sent in ISO format
  • limit (int) – The maximum amount of historical data returned. The historical data is the historical tag values but also the historical alarms. If you set the limit to 4, the response will consist in 4 historical tag values and 4 historical alarms (if available) for each tag of each Ewon gateway allowed by the Talk2M token. If the size of the historical data saved in the DataMailbox exceeds this limit, only the oldest historical data will be returned and the result contains a moreDataAvailable value indicating that more data is available on the server. If limit is not used or is too high, the DataMailbox uses a limit pre-defined in the system (server-side).
getewon(ewonid=None, name=None)

Returns the configuration of the targeted Ewon as seen by the DataMailbox.

Parameters:
  • ewonid – ID of the Ewon as returned by the “getewons” API request.
  • name – Name of the Ewon as returned by the “getewons” API request.
getewons()

Returns the list of Ewons sending data to be stored in the DataMailbox. The result contains the following information for each Ewon:

  • its name and id,
  • its number of tags,
  • the date of its last data upload to the Data Mailbox.
getstatus()

Returns the storage consumption of the account and of each Ewon.

The result contains the following information:

  • number of history points currently stored in the DataMailbox for this account,
  • number of Ewons which send data to the DataMailbox.

The result also contains the following information for each Ewon listed:

  • its id,
  • its name,
  • its number of history points currently stored in the DataMailbox,
  • its date of the first history point currently saved in the DataMailbox,
  • its date of the last history point currently saved in the DataMailbox.
iterate_syncdata(last_transaction_id=None, ewon_ids=None)

Returns an iterator on syncdata.

The syncdata API returns partial data and indicates if there are more data to load with moreDataAvailable. This helper will act as an iterator and yield an api response until there are no more data.

Parameters:
  • last_transaction_id – The ID of the last set of data sent by the DataMailbox. By referencing the “lastTransactionId”, the DataMailbox will send a set of data more recent than the data linked to this transaction ID.
  • ewon_ids (list) – A list of Ewon gateway IDs. If ewonIds is used, DataMailbox sends values history of the targeted Ewon gateways. If not used, DataMailbox sends the values history of all Ewon gateways.
syncdata(last_transaction_id=None, create_transaction=True, ewon_ids=None)

Retrieves all data of a Talk2M account incrementally. You must be cautious when using the combination of last_transaction_id, create_transaction and ewon_ids. last_transaction_dd is first used to determine what set of data — newer than this transaction id and from all the Ewon gateways — must be returned from the DataMailbox, then ewon_dds filters this set of data to send data only from the desired Ewon gateways. If a first request is called with last_transaction_id, create_transaction and ewon_ids, the following request — implying a new last_transaction_id — does not contain values history from the previous last_transaction_id of the Ewon gateways that were not in the ewon_ids from previous request.

Parameters:
  • last_transaction_id (int) – The id of the last set of data sent by the DataMailbox. By referencing the last_transaction_id, the DataMailbox will send a set of data more recent than the data linked to this transaction ID.
  • create_transaction (bool) – The indication to the server that a new transaction ID should be created for this request.
  • ewon_ids (list) – A list of Ewon gateway IDs. If ewonIds is used, DataMailbox sends values history of the targeted Ewon gateways. If not used, DataMailbox sends the values history of all Ewon gateways.

M2Web

class pydatamailbox.client.M2Web(account, username, password, devid, timeout=None)

Talk2M M2Web api client.

This client only supports: getaccountinfo, getewons, getewon

getaccountinfo()

Retrieves the basic account information (reference, name, company).

It also retrieves the set of pools visible by user : pairs name/id as well as the name of each custom attribute. There are always 3 custom attributes listed. Some or all of them may be empty. The “accountType” attribute will either be “Free” (for non paying account) or “Pro” (for paying account).

getewon(ewonid=None, name=None)

Returns the configuration of the targeted Ewon as seen by the DataMailbox.

Parameters:
  • ewonid – ID of the Ewon as returned by the “getewons” API request.
  • name – Name of the Ewon as returned by the “getewons” API request.
getewons(pool=None)

Returns the set of Ewons visible by user along with their properties: displayable names, link names, status, description, the 3 custom attributes, preferred m2web server hostname (currently always m2web.talk2m.com).

Parameters:pool (int) – pool is the optional numerical id of the pool from which the Ewons should be retrieved. Pool id’s are retrieved using a getaccountinfo call. If pool is not specified, all visible Ewons are listed in the response.