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.1.8.tar.gz
(19.6 kB
view hashes)
Built Distribution
Close
Hashes for inmation-api-client-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f720163c8fe56af0932f226e1af94c98f9080aa5ef6dc5a89ebfb6cb7377a10d |
|
MD5 | 0622edd2457729ae2560951c022295f0 |
|
BLAKE2b-256 | cb425f3999dc7652faaaf2bf0594dc5f76b6eeda49144daa00b8ca4b95b452d7 |
Close
Hashes for inmation_api_client-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 455a5c9e5f1cfcc2932dd0543254cb99fecbee4809bd51aa9a71b8ca1accf3dd |
|
MD5 | 59f639be8bfdf558cf06efc202dd065c |
|
BLAKE2b-256 | 230bd8d811edcf32f44782d3fbb53174fee89ecea631901eb251a9df71d6334f |