Polling & Response Parsing

Control It can periodically query any HTTP endpoint and update button states (Title, Color, On/Off) based on the response.

Performance Note: Polling runs on a background thread. While efficient, setting very short intervals (e.g., < 500ms) for many buttons simultaneously can impact battery life and network performance.

Parsing Strategy

The app attempts to parse responses in the following order of precedence:

  1. JSONPath: If the response is valid JSON and a JSONPath is provided.
  2. JSON Key: If a simple top-level key is provided.
  3. Status Code: Checks if the HTTP status code matches the rule (e.g., "200").
  4. Full Body: Checks if the raw response body exactly matches a string.

JSONPath Cheat Sheet

Control It uses a standard implementation of JSONPath. Below are common patterns for extracting data:

Example JSON:

{
  "store": {
    "book": [ 
      { "category": "fiction", "price": 8.95 }, 
      { "category": "science", "price": 12.99 }
    ],
    "isOpen": true
  }
}
Expression Result Description
$.store.isOpen true Direct object access.
$.store.book[0].price 8.95 First item in an array.
$.store.book[-1].category "science" Last item in an array.
$..price [8.95, 12.99] Recursive descent (find all prices).
$.store.book[?(@.price < 10)].category "fiction" Filter expression.