Created
August 12, 2022 14:33
-
-
Save eercanayar/fc95b5bd1ead1658baaeb4ac2f4e487a to your computer and use it in GitHub Desktop.
sitewise batch_put_asset_property_value() example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import time | |
import json | |
import uuid | |
propert_alias_list = [ | |
'Test_Asset_01/Crest', | |
'Test_Asset_01/Fatigue_inps', | |
'Test_Asset_01/Fatigue_mmps', | |
'Test_Asset_01/Fatigue_mps', | |
'Test_Asset_01/Friction_g0', | |
'Test_Asset_01/Friction_mg0', | |
'Test_Asset_01/Friction_mps2', | |
'Test_Asset_01/Impact_g0', | |
'Test_Asset_01/Impact_mg0', | |
'Test_Asset_01/Impact_mps2' | |
] | |
request_payload = {} | |
request_payload["entries"] = [] | |
for property in propert_alias_list: | |
entry = {} | |
entry["entryId"] = str(uuid.uuid4()) | |
entry["propertyAlias"] = property | |
entry["propertyValues"] = [] | |
for val in range(1,11): | |
property_value = { | |
"quality": "GOOD", | |
"timestamp": { | |
"timeInSeconds": int(time.time())-val # values goes back in time by 1 seconds, from t to t-10 | |
}, | |
"value": { | |
"doubleValue": val, | |
} | |
} | |
entry["propertyValues"].append(property_value) | |
request_payload['entries'].append(entry) | |
print(json.dumps(request_payload)) | |
sw_client = boto3.client('iotsitewise') | |
response = sw_client.batch_put_asset_property_value(entries = request_payload["entries"]) | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment