API client for system:inmation.
Project description
inmation API Client
This API client can only be used with the new inmation Web API server.
Installation
Install with pip install inmation-api-client
.
Dependencies
- websockets ^5.0, added to the requirements in setup.py.
Usage
import asyncio
from inmation_api_client import Client, Options, Item
def create_api_client(ioloop):
WS_URL = 'ws://127.0.0.1:8000/ws'
OPTIONS = Options("USERNAME", "PASSWORD")
client = Client(ioloop)
ioloop.run_until_complete(client.connect_ws(WS_URL, OPTIONS))
def connection_changed(conn_info):
""" closure """
print('Connection state: {}, authenticated: {}'.format(conn_info.state_string, conn_info.authenticated))
client.on_ws_connection_changed(connection_changed)
def on_error(err):
if err:
print("Error: {}".format(err.message))
client.on_error(on_error)
return client
EVENT_LOOP = asyncio.get_event_loop()
CLIENT = create_api_client(EVENT_LOOP)
async def read_items_at_once(items):
def read_cbk(*args):
"""read items callback"""
err = args[0]
if err:
print(err.message)
else:
_items = args[1]
if isinstance(_items, list):
print("{} - {}".format('Item', 'Value'))
for item in _items:
if 'error' in item:
print('Error: {}'.format(item['error']['msg']))
else:
item_val = item['v'] if 'v' in item else 'No Value'
print("{} - {}".format(item['p'], item_val))
await CLIENT.read(items, read_cbk)
def main():
items_path = "/System/Core/"
items = [
Item(items_path + 'Item01'),
Item(items_path + 'Item02'),
Item(items_path + 'Item03'),
]
# Read items
EVENT_LOOP.run_until_complete(read_items_at_once(items))
if __name__ == '__main__':
main()
inmation
inmation is a vendor-independent industrial system-integration specialist. Dedicated to modern technologies such as OPC UA (Unified Architecture) and document-oriented schema-less repositories, inmation opens up new horizons for enterprise real-time data management.
More information on inmation.com
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
inmation-api-client-0.2.1.tar.gz
(19.7 kB
view hashes)
Built Distribution
Close
Hashes for inmation-api-client-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2855f6430af3d6a9857653cbec5c02b1459085aaf9169379ca4a837cfc3815d1 |
|
MD5 | e03c23ba328bd60b96e4dfece1baa5f7 |
|
BLAKE2b-256 | 19b27d7fb147eb8278be9d783af330ee9b9bfd5ecea81acf7917552b1ebf584a |
Close
Hashes for inmation_api_client-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f78c0c29bb9ddf35f45439d9348fc445d0dafa1ab54faeb1b76f97cca4450cd7 |
|
MD5 | 6310b8512aeff67b01a394c1191f5af8 |
|
BLAKE2b-256 | fb0eb823046fc77a10757af3a033dd2231c184306150bac76e094d4855a90bf5 |