Data from scripts and services

Data from scripts and services

Gauge, Chart and Breakdown tiles can draw numbers from outside your Homey: a server’s CPU, a NAS’s free space, the jobs waiting in a queue. A data feed is JSON for your Homey’s tiles: sent to a secret address in Tiledash by a script or a service, or fetched by Tiledash from a web address. Tiles read the last JSON it brought.

First choice: a Homey app

When what you want to show has a Homey app, or you can write one, use that. The app makes a device, and a device’s readings are recorded with their history, work in flows and alerts, and show on any tile.

A data feed keeps only the last JSON it brought. A Chart of a feed draws the points in that JSON, and nothing older. Use a feed for data no app brings: your own scripts, a service that calls a webhook, numbers worked out somewhere else.

Make a feed

  1. Go to Settings › Home › Data feeds and choose New data feed. Or, in a tile’s Data setting, choose Data feed and then New data feed….
  2. Give it a name, such as NAS CPU.
  3. Leave Ask for an API key too on, unless the sender can’t set headers.
  4. Choose Make the feed.

Tiledash shows the feed’s Address and API key once, with examples to copy. Keep them somewhere safe: Tiledash itself keeps neither, only a fingerprint of each. Lost one? Choose New address or New API key in the feed’s menu. The old one stops working at once.

Free has one data feed, Pro has 25. Only the Homey’s owner makes and changes feeds; everyone using the Homey can draw them.

Send JSON

Send the JSON with POST or PUT to the address, with the key in an Authorization: Bearer header (or an X-Api-Key header):

curl -X POST 'https://my.tiledash.app/api/feeds/in/your-feed-address' \  -H 'Authorization: Bearer tdk_your-api-key' \  -H 'Content-Type: application/json' \  -d '{"cpu": 37, "load": 0.42}'
  • Any JSON works: one number, a list, objects inside objects. At most 256 KB and 32 levels deep.
  • At most once every 5 seconds. A send that comes sooner is refused, with a Retry-After header that says when to try again.
  • Each send replaces the last. Tiles on your dashboards, share links and paired screens show it at once.

What the address answers:

AnswerMeaning
204Taken.
400It isn’t JSON.
401The address or the key is wrong. It doesn’t say which.
402The feed is paused: your plan’s feeds are in use.
413Over 256 KB.
429Sent within 5 seconds of the last one.

Example: a computer’s CPU on a gauge

This script sends a Linux computer’s CPU use and load every 10 seconds. Save it as cpu-to-tiledash.sh, fill in your feed’s address and key, and start it with bash cpu-to-tiledash.sh. To keep it running after a restart, run it as a systemd service.

#!/usr/bin/env bash# Sends this computer's CPU use to Tiledash every 10 seconds.FEED='https://my.tiledash.app/api/feeds/in/your-feed-address'KEY='tdk_your-api-key'read -r _ user nice system idle iowait irq softirq steal _ < /proc/statlast_idle=$((idle + iowait)); last_total=$((user + nice + system + idle + iowait + irq + softirq + steal))while sleep 10; do  read -r _ user nice system idle iowait irq softirq steal _ < /proc/stat  all_idle=$((idle + iowait)); total=$((user + nice + system + idle + iowait + irq + softirq + steal))  cpu=$(( 100 * ((total - last_total) - (all_idle - last_idle)) / (total - last_total) ))  last_idle=$all_idle; last_total=$total  load=$(cut -d ' ' -f 1 /proc/loadavg)  curl -fsS -X POST "$FEED" \    -H "Authorization: Bearer $KEY" \    -H 'Content-Type: application/json' \    -d "{\"cpu\": $cpu, \"load\": $load}" > /dev/nulldone

Then put it on a dashboard:

  1. Edit the dashboard and add a Gauge.
  2. In its Data setting, choose Data feed and pick the feed.
  3. Find the numbers finds $.cpu, the first number in the JSON. To show the load instead, change the path to $.load.
  4. Set the gauge’s range to 0–100 and its unit to %.

From a Homey flow

With the Tiledash app for Homey connected, a flow sends JSON with the card Send JSON to a data feed under Tiledash: pick the feed and type the JSON, with tags in it where you like, such as {"soil": [Soil moisture]}. The app sends it for you, so the feed’s address and key stay out of your flows. It needs Pro, like the app’s other cards.

Without the app, a HomeyScript in a flow can send what Homey knows, or what it fetched itself:

// Sends the living room's temperature and the time.const device = await Homey.devices.getDevice({ id: 'your-device-id' });await fetch('https://my.tiledash.app/api/feeds/in/your-feed-address', {  method: 'POST',  headers: {    Authorization: 'Bearer tdk_your-api-key',    'Content-Type': 'application/json',  },  body: JSON.stringify({    temperature: device.capabilitiesObj.measure_temperature.value,    at: new Date().toISOString(),  }),});

Let Tiledash fetch it

When a service already has the JSON at a web address (a public API, a status page, your NAS behind its own https name), Tiledash can fetch it for you:

  1. Choose New data feed, give it a name, and under How it comes in choose Fetched by Tiledash.
  2. Type the Web address. It must start with https:// and be on the internet: addresses in your own network can’t be reached from Tiledash.
  3. Choose how often under Fetch every: every 5 minutes at most on Pro, every hour on Free.
  4. If the service asks for a key, fill in Header (optional), such as X-Api-Key and the key itself. Tiledash sends it only to that site, never after a redirect to another.
  5. Choose Make the feed. Tiledash fetches it at once.

It is fetched only while someone is looking: a dashboard, a share link or a paired screen showing it. When the last fetch is older than its interval, the next look fetches it again, once, however many screens show it. A feed nobody looks at is never fetched.

Each fetch counts toward your fetches of the day: 24 on Free, 500 on Pro, counted per UTC day. Once they are used, fetched feeds rest until the next day, and tiles keep their last JSON. Settings › Data feeds shows how many are used today.

A fetch waits at most 10 seconds and takes at most 256 KB. The address and the header are stored encrypted; the list shows only the site’s name.

For JSON that only a flow uses, a Homey text variable may be simpler: a tile’s Data setting reads JSON from a variable too, without a feed.

How a feed is doing

Settings › Data feeds lists every feed of the Homey: when the last JSON came and how big it was, or why the last send or fetch brought nothing (not JSON, too big, not found, refused, no answer). Tiles keep drawing the last JSON that came.

Back on Free with more feeds than it has, the newest are paused: kept, but not read and not taking sends, until you delete some or go Pro again.

A feed’s name and its JSON are stored encrypted, like the rest of your Homey’s data in Tiledash. Your data export has both, and a fetched feed’s site and interval; never an address, key or header. Removing the Homey or your account removes its feeds.