Skip to end of metadata
Go to start of metadata

Key-Value pairs typically are used for Poll models, enabling flexibility for device models.

  • Facilitate value substitution without the need to change models
  • Simplify multiple web service requests

This structure is well-suited for poll models, when there is one web service that is going to be called multiple times with different parameters. 

Key-Value Storage

With Key-Value Storage, there is no need to write the actual logic for a device parameter. Instead, you can change it with the help of a pre-defined Key-Value pair.

To enable variable substitution, add a key and values in the Key-Value Storage dialog and then, in the poll model, use the key instead of the specific values, as described in Key-Value Examples.

Key-Value Examples

The following high-level steps illustrate how to use key-value pairs in a poll model.

  1. Go to Configuration > Key-Value.
  2. Add a new key with the name, Key1.
  3. Add a list of values
  4. In a poll model configuration, set the Request URL to{Key1}. In an actual call, {Key1} will be replaced with a value.

Key-Value Weather Example

The following, more specific example, relates to the Yahoo weather service described in the Transformation Web Service Use Case. Imagine that the REST service accepts only one parameter: city_code. But, you need to know the weather forecast for several cities.

For this use case:

  1. Add a key named city_code with a list of values: NewYorkParisSanJose
  2. In the poll model, use {city_code} as the Request URL parameter. 
  3. When you deploy a device based on the poll model and its timer is triggered, the web service will be called three times with three different values (NewYorkParisSanJose), which are substituted for {city_code}.

  • No labels