|
| 1 | +# this follows the steps to get the various OCID's and so on. |
| 2 | +# it is basically all of the steps in the instructions.txt but |
| 3 | +# with none of the create or modify steps |
| 4 | +# Each step should work if the one before it suceeds PROVIDED |
| 5 | +# that the object at that step exists. I.e. if the adaptor has |
| 6 | +# not been created (or has been destriyed) then you probaly don't |
| 7 | +# have an instance so can't retrieve the instance OCID |
| 8 | +# note that in some cases you may need to set some environment |
| 9 | +# variables as they use things like names to work. |
| 10 | +# |
| 11 | +# Things you may need to change are here |
| 12 | +# |
| 13 | +export IOT_COMPARTMENT_OCID=<compartment ocid> |
| 14 | +export DEVICE_VAULT_SECRET_OCID=<the secret ocid> |
| 15 | + |
| 16 | +# change these names as required |
| 17 | +export IOT_DOMAIN_GROUP_NAME=iot-domain-group-timg |
| 18 | +export IOT_DOMAIN_NAME=iot-domain-timg |
| 19 | +export DEVICE_ID=timssonnen |
| 20 | +# note that this is set for homebattery (the generic model), but it might well be sonnenbattery for the sonnen specific model |
| 21 | +export DIGITAL_TWIN_MODEL_NAME=homebattery |
| 22 | +# DIGITAL_TWIN_MODEL_FILE_NAME should be the name of the file containing the model for example HomeBatteryDTMI.json for the generic home battery, SonnenSpecificDTMI.json for the sonnen specific version |
| 23 | +export DIGITAL_TWIN_MODEL_FILE_NAME=HomeBatteryDTMI.json |
| 24 | +# this will be one of sonnen-direct-mapping, sonnen-single-route or sonnen-multiple-routes |
| 25 | +export DIGITAL_TWIN_ADAPTER_NAME=sonnen-multiple-routes |
| 26 | +# get the domain group info |
| 27 | +# get the domain group ocid (only run this once it has been created) |
| 28 | +export IOT_DOMAIN_GROUP_OCID=`oci iot domain-group list --display-name $IOT_DOMAIN_GROUP_NAME --compartment-id $IOT_COMPARTMENT_OCID | jq -r '.data.items[]| select (."lifecycle-state" == "ACTIVE") | ."id"'` |
| 29 | + |
| 30 | +# get the data host |
| 31 | +export IOT_DOMAIN_GROUP_DATA_HOST=`oci iot domain-group get --iot-domain-group-id $IOT_DOMAIN_GROUP_OCID | jq -r '.data."data-host"'` |
| 32 | +export IOT_DOMAIN_GROUP_SHORT_ID=`echo $IOT_DOMAIN_GROUP_DATA_HOST| tr '.' ' ' | awk '{print $1}'` |
| 33 | +# Now get the domain stuff |
| 34 | +export IOT_DOMAIN_OCID=`oci iot domain list --display-name $IOT_DOMAIN_NAME --compartment-id $IOT_COMPARTMENT_OCID --iot-domain-group-id $IOT_DOMAIN_GROUP_OCID | jq -r '.data.items[]| select (."lifecycle-state" == "ACTIVE") | ."id"'` |
| 35 | +export IOT_DOMAIN_HOST=`oci iot domain get --iot-domain-id $IOT_DOMAIN_OCID | jq -r '.data."device-host"'` |
| 36 | +export IOT_DOMAIN_SHORT_ID=`echo $IOT_DOMAIN_HOST| tr '.' ' ' | awk '{print $1}'` |
| 37 | + |
| 38 | +# these are only relevant if you have setup the digital twin model |
| 39 | +# the DIGITAL_TWIN_MODEL_NAME should relate to the model you are creating, e.g. homebattery for the generic model, sonnenbattery for the sonnen specific one |
| 40 | +export DIGITAL_TWIN_MODEL_ID=`oci iot digital-twin-model list --iot-domain-id $IOT_DOMAIN_OCID --display-name $DIGITAL_TWIN_MODEL_NAME | jq -r '.data.items[]| select (."lifecycle-state" == "ACTIVE") | ."id"'` |
| 41 | + |
| 42 | +# these are only relevant if you have setup a digital twin adaptor |
| 43 | +# DIGITAL_TWIN_MODEL_FILE_NAME should be the name of the file containing the model for example HomeBatteryDTMI.json for the generic home battery, SonnenSpecificDTMI.json for the sonnen specific version |
| 44 | +export DIGITAL_TWIN_MODEL_IDENTIFIER=`cat $DIGITAL_TWIN_MODEL_FILE_NAME | jq -r '.["@id"]'` |
| 45 | +export DIGITAL_TWIN_ADAPTER_OCID=`oci iot digital-twin-adapter list --iot-domain-id $IOT_DOMAIN_OCID --display-name $DIGITAL_TWIN_ADAPTER_NAME | jq -r '.data.items[]| select (."lifecycle-state" == "ACTIVE") | ."id"'` |
| 46 | + |
| 47 | +# the digital twin instance itself |
| 48 | +# this can work if there is not a model or adaptor configured |
| 49 | +# get the OCID of the digital twin |
| 50 | +export DIGITAL_TWIN_INSTANCE_OCID=`oci iot digital-twin-instance list --iot-domain-id $IOT_DOMAIN_OCID --display-name $DEVICE_ID | jq -r '.data.items[]| select (."lifecycle-state" == "ACTIVE") | ."id"'` |
| 51 | +# and the external key |
| 52 | +export DEVICE_EXTERNAL_KEY=`oci iot digital-twin-instance get --digital-twin-instance-id $DIGITAL_TWIN_INSTANCE_OCID | jq -r '.data."external-key"'` |
| 53 | +echo Device external key $DEVICE_EXTERNAL_KEY |
| 54 | +# needed to setup the client code |
| 55 | +export DEVICE_SECRET_BASE64=`oci secrets secret-bundle get --secret-id $DEVICE_VAULT_SECRET_OCID --stage CURRENT | jq -r '.data."secret-bundle-content".content'` |
| 56 | +export DEVICE_SECRET=`echo $DEVICE_SECRET_BASE64 | base64 --decode` |
| 57 | + |
| 58 | +# this is for APEX, only relevant if APEX has been setup |
| 59 | +#Get the apex URL |
| 60 | +echo APEX_URL "https://$IOT_DOMAIN_GROUP_DATA_HOST/ords/apex/" |
| 61 | +#get the user id and workspace |
| 62 | +echo APEX_Workspace "$IOT_DOMAIN_SHORT_ID"__WKSP |
| 63 | +echo APEX_User "$IOT_DOMAIN_SHORT_ID"__WKSP |
| 64 | +echo APEX_Schema "$IOT_DOMAIN_SHORT_ID"__IOT |
0 commit comments