From 96a02ccefa7fe5a8d88b5e1222641bb68eef3fc2 Mon Sep 17 00:00:00 2001 From: Trip5 Date: Mon, 26 Feb 2024 04:48:51 +0900 Subject: [PATCH] Update weather-display.md I had some real trouble today when some sensors went offline... here's how to error-check in Home Assistant! --- wiki/weather-display.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wiki/weather-display.md b/wiki/weather-display.md index 90dc0e07..ee43d50b 100644 --- a/wiki/weather-display.md +++ b/wiki/weather-display.md @@ -111,3 +111,15 @@ action: g: 192 b: 192 ``` + +### How to add error-checking to sensors which may go offline (and cause the script to abort) + +``` + text: > + {% set state = states('sensor.openweathermap_temperature') %} {% if + is_number(state) %} + {{ state|round(1) }}° + {% else %} + {{ "error" }} + {% endif %} +```