Community Tip - You can change your system assigned username to something more personal in your community settings. X
hello,can i please ask how to listen on a thing property value change and coding in this thing service to save new value to db?
Solved! Go to Solution.
You would use a thing subscription for this. There is a tab called subscription in the Thing View in Composer. You can add a subscription there listening to the DataChange Event of a property of a thing. In the subscription, you can write code to perform, or call another service. Note the subscription has to be active to execute.
The property value is automatically saved to the DB, if the property has the "persist" flag. If you also want to record previous entries, you need to set the "log" flag on the property and provide a value stream in the thing configuration (on tab General Information).
If you want to write the value additionally to an external DB, you can run a SQL Command service from a DatabaseThing to do the INSERT in your subscription.
References:
https://community.ptc.com/t5/IoT-Tips/Thing-Subscription/ta-p/817695
You would use a thing subscription for this. There is a tab called subscription in the Thing View in Composer. You can add a subscription there listening to the DataChange Event of a property of a thing. In the subscription, you can write code to perform, or call another service. Note the subscription has to be active to execute.
The property value is automatically saved to the DB, if the property has the "persist" flag. If you also want to record previous entries, you need to set the "log" flag on the property and provide a value stream in the thing configuration (on tab General Information).
If you want to write the value additionally to an external DB, you can run a SQL Command service from a DatabaseThing to do the INSERT in your subscription.
References:
https://community.ptc.com/t5/IoT-Tips/Thing-Subscription/ta-p/817695
ok,thank you!