iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Create a template binary sensor that turns on when a source entity is unknown, unavailable, or has not updated within a limit you choose. The sensor can appear on a dashboard and trigger an automation, giving you an explicit “this reading may be stale” signal instead of silently displaying an old value.
What “stale” means in Home Assistant
A sensor reading is stale when Home Assistant still has a value, but that value is older than your system can safely treat as current. A temperature sensor that normally reports every minute may be stale after several minutes without an update. A battery-powered device that reports every 30 minutes needs a much longer limit. There is no universal timeout that fits every integration.
The most useful implementation is a template binary sensor. It evaluates the source entity’s state and its last_updated timestamp, then exposes a simple binary result:
- On: the reading is considered stale or unusable.
- Off: the reading is within the accepted age and has a usable state.
Because the template uses now(), Home Assistant reevaluates it once per minute. That means the state can change from fresh to stale up to about one minute after the exact threshold is crossed; this pattern is not a second-precision watchdog.
#1 Best Overall
- EASIEST WAY TO GET STARTED WITH HOME ASSISTANT: With Home Assistant already installed, it only requires plugging the included power supply and Ethernet cable to get started
- DESIGNED FOR THE HOME: The small, fanless, and silent design packs a quad-core processor, 32GB of storage, and 4GB of RAM
- ONE HUB TO CONTROL YOUR WHOLE HOME: Simplify your smart home with HA70. Built with official Home Assistant OS and a professional Zigbee coordinator, it brings local control, powerful automation, and seamless device management into one compact hub
- AUTOMATE EVERYTHING: Make all the devices in your home work in harmony - have your lights dim when you start watching a movie, or turn off your heat when you're away from home
- YOUR HOME, YOUR DATA: Your home's data will be kept in the home on your HomeAssistant. You can easily view, share, and export that data anywhere you want
How the timestamp check works
Every Home Assistant state object includes timestamps such as last_changed and last_updated. For this purpose, last_updated is the relevant field because it records when the state object was last updated, including updates to attributes. Home Assistant documents these timestamps as UTC-aware datetime values. The now() function returns the current time in the configured Home Assistant timezone, and Home Assistant handles comparisons between aware datetimes in different zones.
The age calculation is:
(now() - source.last_updated).total_seconds()
If that number is greater than your limit, the template returns true. A source can also be unusable without having an old timestamp. Integrations commonly represent those conditions as unknown or unavailable, so the template should handle them explicitly before doing the datetime calculation.
An important limitation is that last_updated describes Home Assistant’s state object, not a guaranteed physical transmission from the device. An integration might refresh the state object when attributes change, or it might not update the entity for every unchanged measurement. Confirm how the source integration reports data before treating this binary sensor as proof that hardware is offline.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesChoose a timeout that matches the device
Start with the device’s normal reporting cadence, then add enough margin for ordinary delays. A timeout should be longer than a healthy interval but short enough to matter for the action you intend to take.
| Source behavior | How to choose the limit | Typical consequence of a false stale alarm |
|---|---|---|
| Frequent mains-powered sensor | Use several expected reporting intervals, not merely the nominal interval. | Unnecessary notifications or automation runs. |
| Battery-powered sensor with sleep cycles | Allow for its sleep and check-in schedule, plus network delay. | You may label a healthy sleeping device as stale. |
| Event-driven sensor | Base the limit on the longest acceptable period without an event. | A quiet environment can look like a communications failure. |
| Safety- or control-related value | Choose a limit based on the risk of acting on old data, then test failure behavior. | A stale value could cause an unsafe or incorrect action. |
The 900-second value in the example below is an illustrative 15-minute threshold, not a recommended interval for all sensors. Replace it with a value justified by the source integration and your use case.
Rank #2
- 🌍 𝗔𝘀𝘀𝗲𝗺𝗯𝗹𝗲𝗱 𝗶𝗻 𝘁𝗵𝗲 𝗨𝗦𝗔 – Built and quality-checked in Texas with a 2-Year US-Based Limited Warranty for dependable long-term support.
- 🏠 𝗛𝗼𝗺𝗲 𝗔𝘀𝘀𝗶𝘀𝘁𝗮𝗻𝘁 𝗢𝗦 𝗣𝗿𝗲𝗶𝗻𝘀𝘁𝗮𝗹𝗹𝗲𝗱 – Ready to power your smart home locally with fast, reliable automation and no mandatory cloud dependence. A truly powerful smart home hub.
- ⚙️ 𝗗𝗲𝘀𝗶𝗴𝗻𝗲𝗱 𝗳𝗼𝗿 𝗖𝗼𝗻𝘁𝗶𝗻𝘂𝗼𝘂𝘀 𝗢𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻 – Built for reliable 24/7 performance powering virtualization, automation, containers, storage, and professional workloads.
- 🧠 𝗖𝗵𝗼𝗼𝘀𝗲 𝗬𝗼𝘂𝗿 𝗣𝗿𝗼𝗰𝗲𝘀𝘀𝗼𝗿 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 – Available with AMD R2314 (efficient 4-core), AMD R2514 (8-thread multitasking), or Intel Core i3-1215U (hybrid 6-core performance) to match your workload.
- 💾 𝗘𝘅𝗽𝗮𝗻𝗱𝗮𝗯𝗹𝗲 𝗥𝗔𝗠 & 𝗨𝗽 𝘁𝗼 𝟰𝗧𝗕 𝗡𝗩𝗠𝗲 𝗦𝘁𝗼𝗿𝗮𝗴𝗲 – Dual SO-DIMM slots support up to 64GB RAM. Dual NVMe SSD slots support up to 4TB total storage. Select installed memory and storage based on your needs.
Build the template binary sensor in YAML
Complete example
Add a template binary sensor to your Home Assistant configuration, replacing the entity ID, name, unique ID, and timeout:
template:
- binary_sensor:
- name: "Outdoor temperature stale"
unique_id: outdoor_temperature_stale
device_class: problem
state: >-
{% set entity_id = 'sensor.outdoor_temperature' %}
{% set source = states[entity_id] %}
{% if source is none or source.state in ['unknown', 'unavailable'] %}
true
{% else %}
{{ (now() - source.last_updated).total_seconds() > 900 }}
{% endif %}
In this example, the binary sensor turns on when sensor.outdoor_temperature is missing, is unknown, is unavailable, or has not updated for more than 900 seconds. A missing entity is treated as stale rather than silently accepted.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →What each line does
template:starts Home Assistant’s modern template integration configuration.binary_sensor:declares a derived entity with an on/off state.name:is the label shown in the UI.unique_id:lets Home Assistant manage the entity in the UI and prevents collisions with other template entities.device_class: problemtells the frontend thatonrepresents a problem. The UI wording and icon follow the device class, so remove or change it if “problem” is not the meaning you want.states[entity_id]retrieves the source state object dynamically.source is nonecatches a misspelled entity ID or an entity that is not currently present.- The first conditional handles non-usable source states before attempting datetime arithmetic.
now()makes the template refresh on Home Assistant’s once-per-minute schedule in addition to updates from the source entity.
Use a different reporting limit
Change 900 to the number of seconds that fits your source. For example, 3,600 means one hour:
{{ (now() - source.last_updated).total_seconds() > 3600 }}
Keep the comparison as > if you want the sensor to turn on after the limit has been exceeded. Using >= changes the boundary so the sensor can turn on exactly at the limit when the template is evaluated.
Decide how unknown and unavailable should behave
The example uses a conservative policy: either state means the reading is stale. That is appropriate when downstream automations must never assume an unusable source is safe.
Rank #3
- 7.3″ Color E Ink Spectra6 Display - Enjoy vibrant colors and sharp text with the 7.3-inch 800×480 E Ink Spectra 6 display. It stays clear in bright light and uses almost no power while holding an image—perfect for home dashboards, smart displays, reminders and daily information boards.
- Ultra-Low Power with Up to 3-Month Battery Life - The built-in 2000mAh battery and ultra-efficient design allow the reTerminal E1002 to run for up to 3 months in deep-sleep mode (6-hour refresh interval). Place it anywhere—on your desk, bedside table or wall—without worrying about wires or frequent charging.
- No-Code Dashboard Design with SenseCraft HMI - Create beautiful custom dashboards using SenseCraft HMI, an AI-powered no-code platform. Simply drag and drop UI elements, choose from ready-made templates or let AI generate layouts for you. Connect live data from sensors, APIs or smart home systems and deploy your design to the E1002 with just a few clicks.
- Works with Home Assistant, ESPHome & Maker Tools - Enjoy smooth integration with popular smart home and developer ecosystems. Build TRMNL dashboards with 300+ plugins, connect instantly to Home Assistant via ESPHome, or create your own applications using Arduino, PlatformIO or ESP-IDF—ideal for makers and DIY smart home enthusiasts.
- Customizable Hardware & Flexible Expansion - Designed with makers in mind, the reTerminal E1002 supports GPIO/I²C/SPI expansion and Grove modules, allowing you to easily add buttons, sensors or other accessories. Perfect for smart home displays, creative DIY builds, educational projects and personal productivity boards.
| Policy | Template result for unknown/unavailable |
When it fits |
|---|---|---|
| Conservative stale policy | Return true and turn the binary sensor on. |
You want one alarm entity for old, missing, or unusable data. |
| Separate outage policy | Do not classify those states as stale here; handle availability with another entity or automation. | Your installation already has a dedicated connectivity indicator and you need to distinguish “no state” from “old state.” |
| Preserve-last-value policy | Keep a previous value during temporary dropouts. | Downstream consumers need continuity. This is a different goal from exposing staleness and should not replace the stale indicator. |
If you choose the second policy, make the distinction visible to anyone using the entity. A binary sensor that remains off while its source is unavailable can otherwise be mistaken for a fresh reading.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Configure it through the Home Assistant UI
Home Assistant also supports template binary sensors created as helpers. In current installations, open Settings → Devices & services → Helpers, choose Create helper, select the template binary sensor option, and enter the name and template fields. Labels can vary slightly by Home Assistant version.
- Open the Helpers page and start a new template binary sensor.
- Give it a name such as
Outdoor temperature stale. - Set the state template to the expression that returns
trueorfalse. Use the full conditional example if you need explicit handling for missing, unknown, and unavailable states. - Select a device class only when its terminology matches your intended meaning.
problemis suitable when on means a detected problem. - Save the helper, then locate the resulting entity in Settings or Developer Tools and confirm its entity ID.
For installations managed as code, YAML is easier to review, back up, and reproduce. For a one-off helper, the UI avoids editing configuration files. Do not create both versions with the same intended entity unless you deliberately want two separate indicators.
Validate the template before using it in an automation
Check the source entity
- Open Developer Tools → States.
- Search for the exact source entity ID, such as
sensor.outdoor_temperature. - Confirm the current state, attributes, and the entity’s update information. Copy the entity ID exactly; display names are not interchangeable with entity IDs.
Render the expression
- Open Developer Tools → Template.
- Paste the template body or a diagnostic version that prints the source state and timestamp.
- Confirm that a healthy source renders
False, an old source rendersTrue, andunknown,unavailable, and a missing entity follow your chosen policy.
{% set entity_id = 'sensor.outdoor_temperature' %}
{% set source = states[entity_id] %}
Source exists: {{ source is not none }}
{% if source is not none %}
State: {{ source.state }}
Last updated: {{ source.last_updated }}
Age (seconds): {{ (now() - source.last_updated).total_seconds() }}
{% endif %}
After saving the helper or reloading the template integration, inspect the actual binary sensor rather than relying only on the editor. The editor verifies rendering in that context; the created entity must still be checked in the configuration where it will run.
Understand detection timing and precision
The template responds immediately to a source state update that causes reevaluation, but the age threshold itself is crossed by the scheduled refresh from now(). Home Assistant reevaluates templates containing now() or utcnow() once per minute. If the limit is 900 seconds, the sensor may turn on at roughly 900 to 960 seconds after the last relevant update, depending on where the update falls in that minute cycle.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- 【All in One Control Panel With】 Enjoy a larger view with the 4.7-inch display that Control your home with just a tap—whether it’s monitoring energy use, viewing live cameras, adjusting the thermostat, managing your lighting or even browsing the web
- 【Home Security】Customize 3 modes by setting different arming devices. When a sensor is triggered, the panel will sound an alarm and send a notification to your phone
- 【Power Consumption】 You can select devices with energy statistics functions to track their daily energy consumption over a week
- 【Camera Viewer】 NSPanel Pro can be used as a display and supports adding the following four types of cameras for live monitoring, allowing real-time views of your living room, garage, bedroom, and more
- 【Explore Webpages】Listening to music, watching videos, or checking out the latest advice? Save the address in NSPanel Pro’s Webpages, start it quickly with one click, and relax anytime
Do not use this pattern when you require sub-minute or second-level guarantees. For those cases, design a trigger-based or external monitoring mechanism around the timing precision your application actually needs. The template binary sensor remains useful as a clear, visible state even when it is not a hard real-time watchdog.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Use the stale state in an automation
Once the binary sensor exists, it can be used like any other binary sensor. A basic notification automation can trigger when it changes to on:
automation:
- alias: "Notify when outdoor temperature is stale"
triggers:
- trigger: state
entity_id: binary_sensor.outdoor_temperature_stale
to: "on"
actions:
- action: notify.notify
data:
message: "Outdoor temperature has not updated within the configured limit."
The exact notification service depends on your installation. Keep the stale binary sensor separate from the action so you can display it on a dashboard, suppress alerts during maintenance, or reuse it in more than one automation.
Avoid repeated notifications
A state trigger with to: "on" fires when the sensor enters the stale state, not on every minute-by-minute reevaluation while it remains on. If the source recovers and then becomes stale again, the next transition to on can notify you again. Add a condition, a notification throttle, or an explicit recovery notification when your operation needs those behaviors.
Free tools Windows power users keep installed
One-click scans. No signup required.
Show recovery as well as failure
A second automation can trigger when the stale sensor changes to off and report that updates have resumed. Recovery messaging is useful when the original alert was sent while nobody was watching the dashboard.
Best Value
- Only mount plastic mount is included. Home assistant device is not included.
- Made In USA from High Quality Materials.
- Secure Mounting — Uses #6 flat head screws (Not Included) for a stable, reliable installation.
- Easy Access Ports: Design ensures all bottom ports are fully accessible for power, network, and peripheral connections.
- Cooling-Friendly Design: Open structure allows airflow around cooling fins to help maintain optimal operating temperature.
Choose the right device class and dashboard meaning
A template binary sensor can be on, off, unknown, or unavailable. Its device class controls presentation, labels, and icons; it does not change the underlying Boolean calculation. Use problem when on should communicate “a problem is present.” If your interface needs neutral wording such as “stale” and “fresh,” choose a presentation that does not imply a different condition, or leave the device class generic.
Name the entity so the state is unambiguous. “Outdoor temperature stale” is clearer than “Outdoor temperature status,” because users can immediately infer what on means. If you monitor several entities, use a consistent suffix such as _stale and keep the source entity name in the friendly name.
Troubleshooting common failures
The binary sensor is always off
- Check that the entity ID is exact and belongs to the expected domain.
- Inspect
last_updatedin Developer Tools. The source may be updating more often than you assumed. - Confirm that the timeout is expressed in seconds. A value of
900means 15 minutes, not 900 minutes. - Remember that the
now()refresh is once per minute; a test performed immediately before the next refresh can appear late.
The binary sensor is always on
- Verify that the source is not permanently
unknownorunavailable. - Check for a typo that makes
states[entity_id]return no entity; the example intentionally treats a missing source as stale. - Compare the source’s update cadence with the selected threshold. A battery device may report less often than the limit.
- Render the age diagnostic in the Template editor to see whether the timestamp is advancing.
The timestamp changes but the physical value did not
This can be normal. last_updated belongs to Home Assistant’s state object, and an integration may update attributes or state metadata without a meaningful change in the physical measurement. Conversely, an integration may not refresh the entity for every unchanged report. Treat the result as evidence about the entity’s update behavior, then verify the integration’s reporting model before using it as an offline detector.
Recommended Free Tools
The template reports a datetime error
- Do not subtract a text-formatted timestamp from
now(); use the state object’slast_updateddirectly. - Keep the unknown and unavailable checks before the subtraction.
- Ensure you are not accessing
last_updatedon a missing source. Thesource is nonebranch prevents that.
The helper exists but the UI wording is confusing
Review the device class and the name. Device class affects labels and representation, while the state template determines only whether the entity is on or off. Change the class or use a generic presentation when “problem” does not describe your dashboard’s intended meaning.
When a stale detector is not enough
A stale binary sensor tells you that a value is old or unusable; it does not repair the source, prove that a device has lost power, or distinguish a radio outage from a quiet environment. Pair it with the evidence that matters for your installation, such as integration diagnostics, a device availability entity, or a heartbeat reported by the device.
If downstream logic needs to keep using the last known measurement during a short dropout, a trigger-based template sensor can preserve that value. That design serves continuity, whereas the stale binary sensor deliberately exposes that the value should no longer be trusted. You can use both, but do not mistake a preserved value for fresh data.
Practical checklist
- Identify the exact source entity ID.
- Measure or document its normal reporting cadence.
- Choose a timeout longer than normal cadence and appropriate to the consequence of stale data.
- Decide whether
unknownandunavailableshould count as stale. - Handle a missing entity explicitly.
- Use
now()only with the understanding that refresh precision is about one minute. - Validate healthy, old, unknown, unavailable, and missing-source cases in Developer Tools → Template.
- Inspect the created entity after saving and confirm its on/off meaning.
- Test the automation on both stale and recovery transitions.
- Document that the result describes Home Assistant entity updates, not necessarily every physical transmission.
What this setup requires
You do not need an additional sensor, special hardware, or a paid service. The template uses an existing Home Assistant entity and the state metadata already available to the system. Home Assistant can run on hardware such as Home Assistant Green, but that hardware is optional; the stale-reading logic is independent of the host device.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

