Missing data
Say what’s going on when a sensor has no reading.
{% if cap.measure_temperature.value != nil %} <p class="reading">{{ cap.measure_temperature.value | temp: 1 }}</p>{% else %} <p>Temperature unavailable</p> <p>Check that the sensor is connected.</p>{% endif %}The preview runs on a made-up sensor.climate device, so you don’t need a Homey. Edit the template or style to try something; actions don’t reach a device here.
How it works
A value is nil when Homey has no reading yet or the device is gone. Test for nil, never for “empty”: 0 is a real reading and must show. Choose Away in the preview to see the fallback.
It doesn’t tell an offline device from a new one; device.available does that (see the first-widget tutorial, step 3).
Files
{% if cap.measure_temperature.value != nil %} <p class="reading">{{ cap.measure_temperature.value | temp: 1 }}</p>{% else %} <p>Temperature unavailable</p> <p>Check that the sensor is connected.</p>{% endif %}:host { display: flex; flex-direction: column; gap: 12px; padding: 12px;}p { margin: 0;}.reading { font: var(--hd-number-weight) 36px var(--hd-font-display);}button { color: var(--hd-text); background: var(--hd-surface); border: 1px solid var(--hd-border); padding: 10px; border-radius: var(--hd-control-radius);}{ "id": "@your-handle/missing-reading", "title": "Missing data", "summary": "Say what’s going on when a sensor has no reading.", "version": "1.0.0", "licence": "MIT", "tags": [], "kind": "widget", "widget": { "kind": "device", "match": { "requires": [ "measure_temperature" ], "optional": [ "measure_humidity", "measure_co2", "measure_battery", "alarm_battery" ] }, "size": { "default": [ 3, 4 ], "min": [ 1, 1 ], "max": [ 6, 8 ] }, "align": { "y": "end" }, "settings": [ { "name": "tileTap", "label": "The tile", "required": false, "group": "tap", "type": "tap", "gesture": "tap", "default": { "type": "none" }, "hold": { "type": "device" }, "double": { "type": "none" }, "allow": [ "toggle", "device", "dashboard", "flow", "mood", "variable", "request" ] }, { "name": "temperatureTap", "label": "Temperature", "required": false, "group": "tap", "type": "tap", "gesture": "tap", "default": { "type": "none" }, "hold": { "type": "none" }, "double": { "type": "none" }, "allow": [ "toggle", "device", "history", "dashboard", "flow", "mood", "variable", "request" ], "capability": "measure_temperature" }, { "name": "humidityTap", "label": "Humidity", "required": false, "group": "tap", "type": "tap", "gesture": "tap", "default": { "type": "none" }, "hold": { "type": "none" }, "double": { "type": "none" }, "allow": [ "toggle", "device", "history", "dashboard", "flow", "mood", "variable", "request" ], "capability": "measure_humidity" } ], "basedOn": "sensor.climate" }}Use it
In the editor, start from the widget it’s based on and paste the template and style; or unzip the package, replace your-handle with your name in the Community and publish it. Build your first widget walks through both.