Dweeting with SiteWhere and Dweet.io

//Dweeting with SiteWhere and Dweet.io

Dweeting with SiteWhere and Dweet.io

SiteWhere 1.3.0 introduces integration with dweet.io, a service that acts like Twitter for your devices. By sending SiteWhere data to dweet.io, you can integrate with many other services that support it as a data source. For instance freeboard.io can use dweet data as the basis of its visualizations.

Getting Started

There is no requirement to set up an account in order to send “dweets”. Anyone can post data to the service by posting REST calls targeted at a unique device name. Dweet.io will allow you to “lock” a device name so that others can not post to or view data from a device unless they have a key to do so.

Configuring SiteWhere to Forward Data

Configuring SiteWhere to send device data as dweets is very simple. Open the configuration file for the tenant whose data you wish to start forwarding (the default tenant configuration is located in conf/sitewhere/default-tenant.xml). Scroll down to the outbound-processing-chain section and look for a commented entry dweet-io-event-processor. Uncomment the XML fragment, save the configuration, then restart your tenant. When the tenant restarts, data events for all devices will be forwarded as dweets.

Generate Device Data with the Emulator

The SiteWhere administrative console contains an emulator application that allows data to be generated into the system as if it were coming from the device itself. This is handy for testing processing logic and will also be helpful in sending some test dweets. From the Sites page in the admin application, navigate to the device assignment list and click on the detail page for a device assignment. Click on the Emulate Assignment button at the top of the page, click Connect to connect to your local MQTT server, then click on the map to generate a new location event for the device assignment. The data will automatically be forwarded to dweet.io.

Unique Data Identifier

Each dweet is targeted at a “thing” based on a unique identifier. Rather using device hardware ids as the identifier, SiteWhere uses the token for the current device assignmentas the identifier. SiteWhere does not associate device events directly with a device since a single device can be assigned to many different assets over time. Each device assignment has a unique token that can be used to find the events generated while the assignment was active. To locate dweets, the device assignment token should be used as the “thing” name.

Viewing Data on Dweet.io

Now that SiteWhere data has been forwarded, we can open the dweet.io website and view it. When SiteWhere data is forwarded to dweet.io, the unique device name is the assignment token the event data is associated with.

The dweet.io website includes an interface for interacting with the REST services it provides, allowing you to view the data that SiteWhere has forwarded. Navigate to the playarea to interact with the services. Enter the device assignment token to find the latest dweets associated with it:

The response will include all of the SiteWhere context data associated with the event including the device hardware id, assignment information, asset information, and detailed location information. Other event types such as measurements and alerts can be posted in the same way.

Dweeting with SiteWhere and Dweet.io | SiteWhere

Next Steps

Now that you have successfully forwarded location data to dweet.io, try other information such as measurements and alerts. Play around with the REST services that dweet.io offers and see how easy it is to use them to access your SiteWhere data in a new way. Finally, take a look at the integration options that dweet.io opens up for your SiteWhere data. Have fun!

By | 2017-10-17T21:58:01-04:00 November 1st, 2015|Developer Blog|0 Comments