Is there any possible way to update the "isConnected" Property (in the "Connectable" Thing Shape) from within ThingWorx?
This property/TS is part of the "RemoteThing" Template and is great for visualizing if a Thing is connected, like in Composer -> Monitoring -> Remote Things. I'd like to extend this capability to API connections we make in ThingWorx that do not have a native ThingWorx connection or remote agent. Essentially I have defined a "connector" Thing in ThingWorx that makes REST calls on an API via scheduler/timer; I want to utilize the "isConnected" property as an indicator of whether the API connection is "healthy." If an API call is successful, "isConnected" would be set to 'true'; if an API call fails or has a particular error code, "isConnected" would be set to 'false.'
Is it possible to define this logic within ThingWorx, or must it be done via SDK, or some other method?
Solved! Go to Solution.
Hi @Ascherer17 ,
The RemoteThing isConnected is not update-able manually. It represents whether the specific RemoteThing has a live AlwaysOn Websocket connection to one of the ThingWorx agents, so it will never allow you to set it manually (via isConnected=true).
Composer / Monitoring Things shows you only the status for agents that are connected via AlwaysOn.
Considering this definition, I suggest to define your own "isCustomConnected" property, define it in the way required for your use-case and implement your own Mashup to monitor for that property.
Hi @Ascherer17
You can create a service in your "connector" Thing that performs the API call and evaluates the response. Based on the result of the API call, you can set the "isConnected" property accordingly. For instance, if the API call is successful, you would set me.isConnected = true. If it fails or returns a specific error code, you would set me.isConnected = false.
To ensure that the "isConnected" property is defined in your Thing, you can use the AddPropertyDefinition service. Additionally, the EvaluateReporting service can be utilized to assess the reporting state of your Thing based on the API connection status.
For more information on managing properties and creating services, you can refer to the following resources:
Regards.
--Sharon
Sharon, Thank you for the reply.
My issue is that the "isConnected" property, which is already on the "Connectable" Thing Shape, is a read-only property. I'm not able to change it via custom service.
I'm aware of the "isReporting" property (on the "Reportable" Thing Shape) and updating it via a custom reporting strategy. Is there mechanism, similar to the reporting strategy, available that would allow me to define when my Thing is "connected", since I cannot directly update isConnected?
I agree that I could add my own "isConnected" property, but would the "connected" icon in Composer reflect the status appropriately simply based on the property name? Out of curiosity, I might try this and report back.
Icons shown in Composer for remote Things that are Disconnected (isConnected=false) or Connected (isConnected=true):
I did a quick proof-of-concept. I created a GenericThing and added a boolean property called "isConnected". As expected, it's not a remote thing so the connection icon doesn't show up. Changing value has no effect.
To take this further, I added the Reportable Thing Shape and created a basic reporting algorithm (ReportingByConnection Thing) that always returns true for Reporting. When I execute "EvaluateReporting," isReporting is set to true, and notably, the connection icon changes to the "Reporting" icon below. That gives a green indicator in Composer, at least, but it doesn't add my generic thing to the Monitoring list in Composer, which is what I really want.
Hi @Ascherer17 ,
The RemoteThing isConnected is not update-able manually. It represents whether the specific RemoteThing has a live AlwaysOn Websocket connection to one of the ThingWorx agents, so it will never allow you to set it manually (via isConnected=true).
Composer / Monitoring Things shows you only the status for agents that are connected via AlwaysOn.
Considering this definition, I suggest to define your own "isCustomConnected" property, define it in the way required for your use-case and implement your own Mashup to monitor for that property.
