cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Get Started with ThingWorx for IoT Guide Part 4

100% helpful (3/3)

Get Started with ThingWorx for IoT Guide Part 4

 

Step 10: Display Data

 

Now that you have configured the visual part of your application, you need to bind the Widgets in your Mashup to a data source, and enable your application to display data from your connected devices.

 

Add Services to Mashup

 

  1. Click the Data tab in the top-right section of the Mashup Builder.
  2. Click on the green + symbol in the Data tab.IoTProductMgmt_0-1659628881678.png

     

  3. Type MyHouse in the Entity textbox.

    Step 10 Add Services to Mashup Step 3.png

  4. Click MyHouse.
  5. In the Filter textbox below Services, type GetPropertyValues.
  6. Click the arrow to the right of the GetPropertyValues service to add it.IoTProductMgmt_2-1659628881681.png

     

  7. Select the checkbox under Execute on Load.

NOTE: If you check the Execute on Load option, the service will execute when the Mashup starts.

8. In the Filter textbox under Services, type QueryProperty.

9. Add the QueryPropertyHistory service by clicking the arrow to the right of the service name.IoTProductMgmt_3-1659628881682.png

10. Click the checkbox under Execute on Load.

11. Click Done.

Step 10 Add Services to Mashup Step 11.png

12. Click Save.

 

Bind Data to Widgets

 

We will now connect the Services we added to the Widgets in the Mashup that will display their data.

 

Gauge

 

Configure the Gauge to display the current power value.

  1. Expand the GetPropertyValues Service as well as the Returned Data and All Data sections.
  2. Drag and drop the watts property onto the Gauge Widget.IoTProductMgmt_5-1659628881701.png

     

  3. When the Select Binding Target dialogue box appears, select # Data.

 

Map

 

Configure Google Maps to display the location of the home.

  1. Expand the GetPropertyValues service as well as the Returned Data section.
  2. Drag and drop All Data onto the map widget.IoTProductMgmt_6-1659628881710.png

     

  3. When the Select Binding Target dialogue box appears, select Data.
  4. Click on the Google Map Widget on the canvas to display properties that can configured in the lower left panel.
  5. Set the LocationField property in the lower left panel by selecting building_lat_lng from the drop-down menu.IoTProductMgmt_7-1659628881719.png

     

Chart

 

Configure the Chart to display property values changing over time.

  1. Expand the QueryPropertyHistory Service as well as the Returned Data section.
  2. Drag and drop All Data onto the Line Chart Widget.
  3. When the Select Binding Target dialogue box appears, select Data.
  4. In the Property panel in the lower left, select All from the Category drop-down.
  5. Enter series in Filter Properties text box then enter 1 in NumberOfSeries .
  6. Enter field in Filter Properties text box then click XAxisField.
  7. Select the timestamp property value from the XAxisField drop-down.
  8. Select temperature from the DataField1 drop-down.
IoTProductMgmt_8-1659628881727.png

 

Verify Data Bindings

 

You can see the configuration of data sources bound to widgets displayed in the Connections pane.

  1. Click on GetPropertyValues in the data source panel then check the diagram on the bottom of the screen to confirm a data source is bound to the Gauge and Map widget.IoTProductMgmt_9-1659628881735.png

     

  2. Click on the QueryPropertyHistory data source and confirm that the diagram shows the Chart is bound to it.
  3. Click Save.

 

Step 11: Simulate a Data Source

 

At this point, you have created a Value Stream to store changing property value data and applied it to the BuildingTemplate. This guide does not include connecting edge devices and another guide covers choosing a connectivity method. We will import a pre-made Thing that creates simulated data to represent types of information from a connected home. The imported Thing uses Javascript code saved in a Subscription that updates the power and temperature properties of the MyHouse Thing every time it is triggered by its timer Event

 

Import Data Simulation Entities

 

  1. Download the attached sample:  Things_House_data_simulator.xml.
  2. In Composer, click the Import/Export icon at the lower-left of the page.

    Step 11 Import Step 2.png

  3. Click Import.

    Step 11 Import Step 3.png

  4. Leave all default values and click Browse to select the Things_House_data_simulator.xml file that you just downloaded.
  5. Click Open, then Import, and once you see the success message, click Close.

 

Explore Imported Entities

 

  1. Navigate to the House_data_simulator Thing by using the search bar at the top of the screen.
  2. Click the Subscriptions tab.

    Step 11 Explore Step 2.png

  3. Click Event.Timer under Name.
  4. Select the Subscription Info tab.

    Step 11 Explore Step 4.png

NOTE: Every 30 seconds, the timer event will trigger this subscription and the Javascript code in the Script panel will run. The running script updates the temperature and watts properties of the MyHouse Thing using logic based on both the temperature property from MyHouse and the isACrunning property of the simulator itself.

5. Expand the Subscription Info menu. The simulator will send data when the Enabled checkbox is checked.

6. Click Done then Save to save any changes.

 

Verify Data Simulation

 

  1. Open the MyHouse Thing and click Properties an Alerts tab
  2. Click the Refresh button above where the current property values are shownIoTProductMgmt_14-1659628881743.png

     

  3. Notice that the temperature property value changes every 30 seconds when the triggered service runs. The watts property value is 100 when the temperature exceeds 72 to simulate an air conditioner turning on.

 

Step 12: Test Application

 

  1. Browse to your Mashup and click View Mashup to launch the application.

    Step 12 Step 1.png

     

NOTE: You may need to enable pop-ups in your browser to see the Mashup.

      2. Confirm that data is being displayed in each of the sections.

      Step 12 Step 2.png

Test Alert

 

  1. Open MyHouse Thing
  2. Click the Properties and Subscriptions Tab.
  3. Find the temperature Property and click on pencil icon in the Value column.
  4. Enter the temperature property of 29 in the upper right panel.
  5. Click Check mark icon to save value. This will trigger the freezeWarning alert.IoTProductMgmt_17-1659628881775.png

     

  6. Click Refresh to see the value of the message property automatically set.IoTProductMgmt_18-1659628881777.png

     

7. Click the the Monitoring icon on the left, then click ScriptLog to see your message written to the script log.

IoTProductMgmt_19-1659628902307.png

 

Click here to view Part 5 of this guide. 

Version history
Last update:
‎Nov 15, 2022 01:17 PM
Updated by:
Attachments
Contributors