import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv logging.basicConfig(level=logging.ERROR) info = wsv(KEY, TOKEN).info(GENSET_ID) print('Information') print('-------------------------------------------') print(f'Name: {info["name"]}') print(f'Owner: {info["ownerLoginId"]}') print(f'Application: {info["applicationType"]}') print(f'Timezone: {info["timezone"]}') print(f'Airgate ID: {info["connection"]["airGateId"]}') print( f'Position: {info["position"]["latitude"]},{info["position"]["longitude"]}' )
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv logging.basicConfig(level=logging.ERROR) values = wsv(KEY, TOKEN).values(GENSET_ID) print('Genset values') print('-------------------------------------------') for value in values: print(f'{value["valueGuid"]} {value["name"]:<24} : {value["value"]} {value["unit"]}')
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv logging.basicConfig(level=logging.ERROR) # Please run the script test-files, pick a file name and fill it in here FILENAME = '2019-04-02_13-59_IL3 AMF25 - nahradnik - GSM.csv' print(f'Downloading file {FILENAME}') downloaded = wsv(KEY, TOKEN).download(GENSET_ID, FILENAME) print(f"{FILENAME} download {'SUCCESS' if downloaded else 'FAILED'}")
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv from comap.constants import VALUE_GUID logging.basicConfig(level=logging.ERROR) values = wsv(KEY, TOKEN).values( GENSET_ID, f'{VALUE_GUID["mode"]},' f'{VALUE_GUID["engine_state"]},' f'{VALUE_GUID["nominal_power"]}') print('Genset values') print('-------------------------------------------') for value in values: print(f'{value["name"]:<16} : {value["value"]} {value["unit"]}')
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv logging.basicConfig(level=logging.ERROR) comments = wsv(KEY, TOKEN).comments(GENSET_ID) print('Comments') for comment in comments: print(f'{comment["author"]:<18} {comment["date"]} {comment["text"]}')
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv from comap.constants import VALUE_GUID import timestring logging.basicConfig(level=logging.ERROR) VALUE_GUID = VALUE_GUID['engine_state'] history = wsv(KEY, TOKEN).history(GENSET_ID, '09/10/2019', '09/13/2019', VALUE_GUID) print('Engine State history') print('-------------------------------------------') for event in history[0]["history"]: print(f'{event["value"]:<8} valit to {event["validTo"]}')
print( 'You will need ComAp API, that you will find on the ComAp API developer portal under your profile.' ) print('Then you will need your WebSupervisor user name and password.') print( 'It will generate your security token and store it, together wit the key, in the config.py file.\n' ) proceed = str(input('Do you want to continue? (Yes/No)')).lower().strip()[0] if proceed == 'y': print( '\nFirst, go to your ComAp API profile (https://portal.websupervisor.net/developer) and get your Primary and Secondary Key.' ) comap_key = input("Enter your key (one of them): ") username = input("Enter your WebSupervisor user name: ") password = getpass.getpass("Enter your WebSupervisor password: "******"config.py", "w") f.write(f"KEY = '{comap_key}'\n") f.write(f"TOKEN = '{token}'\n") f.close() print( '\nThe KEY and TOKEN are stored in the config.py file. Copy this file to the directories with examples.\n' ) print( 'KEEP THIS FILE SECRET! Do not share it with anyone, do not post it on Internet!\nIt contains the information used to authenticate to ComAp API with your user account.\n' ) print( 'If your keys get compromised, generate a new KEY on the WebSupervisor portal!\nThe KEY will automatically become invalid if not used for 30 days!\n' ) else:
import logging from config import KEY, TOKEN, GENSET_ID from comap.api import wsv logging.basicConfig(level=logging.ERROR) files = wsv(KEY, TOKEN).files(GENSET_ID) print('Files') print('-------------------------------------------') for file in files: print(f'{file["generated"]} [{file["fileName"]}]')
import logging from config import KEY, TOKEN from comap.api import wsv logging.basicConfig(level=logging.ERROR) units = wsv(KEY, TOKEN).units() print('List of units available within user account') print('-------------------------------------------') for unit in units: print(f'{unit["unitGuid"]} : {unit["name"]}')