Recommended Free Tools
Use two safeguards together: block the action unless the sensor has a valid, usable state, then reject readings older than the device’s expected reporting interval. This prevents both obvious failures such as unavailable and quiet failures where an old but plausible number still passes a threshold.
The two checks every safety-critical automation needs
A Home Assistant condition is evaluated after a trigger fires. Put the sensor guard in the same automation, immediately before the action it protects. The guard should answer two separate questions:
As an Amazon Associate I earn from qualifying purchases.
- Is the current value valid? Reject
unknown,unavailable, empty values, and non-numeric text when the automation makes a numeric decision. - Is the value fresh enough for this decision? Compare an appropriate last-seen or report timestamp with a timeout based on the device’s normal reporting cadence.
These checks are complementary. A sensor can be available but stale, or it can be fresh but currently unavailable. Treat either failure according to the consequence of the action: skip the action, notify someone, or move the system to a safe state.
What unknown, unavailable, and stale mean
unavailable
Home Assistant defines unavailable as “The entity cannot provide its state right now.” It commonly indicates a disconnected device, failed communication, incomplete setup, or an integration problem. It is not a sensor reading and must never be interpreted as zero, false, or a safe default.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
unknown
unknown means Home Assistant does not currently know the value. This often occurs during startup, while an integration is fetching data, or when an integration can reach a device but is temporarily missing part of its data. Home Assistant developer guidance distinguishes that situation from a communication failure: missing data may be represented as unknown, while a failed update should make the entity unavailable.
A stale value
A stale value is syntactically valid and may look plausible, but it is older than the decision allows. For example, a temperature of 22 °C might be perfectly valid when reported, yet unsafe to use for ventilation control if the sensor has stopped reporting for an hour. “The value did not change” is not the same as “the sensor did not report.” A device may repeatedly report the same value without changing the state value.
Why an automation can still run during recovery
Conditions do not wait for a state to become valid
When a trigger fires, Home Assistant evaluates each condition against the current state once. If a condition is false, the action is blocked; Home Assistant does not pause and retry automatically when the condition later becomes true. If you need a later event to cause a run, create a trigger for that event.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteRecovery is a state change
A State changed trigger can fire when an entity moves from unavailable or unknown back to a value. That recovery transition proves only that Home Assistant observed a state change. It does not prove that the returned value is fresh, in range, or suitable for the action. Keep the validity and freshness conditions on the automation even when the trigger is a recovery event.
Use deliberate from and to values
If a trigger should run only for a specific transition, define both ends of the transition. A trigger with a from value matches that source state; an entity-specific trigger may not react to every recovery transition. When an automation must respond to both a physical event and a recovery event, add separate triggers and retain the same protective conditions.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
Step 1: inventory the sensor before writing YAML
- Open the entity in Home Assistant and record its exact entity ID, unit, normal update interval, and behavior when the device disconnects.
- Determine whether it reports on a fixed schedule, only when its value changes, or through an integration-specific heartbeat.
- Look for a device-provided last-seen, last-report, or connectivity entity. Prefer that timestamp over a generic Home Assistant state-machine timestamp.
- Define the consequence of a bad reading. A light can usually be left unchanged; a heater, lock, pump, or alarm may require a notification or an explicit safe state.
- Choose an acceptable value range as well as a freshness limit. A fresh but impossible reading should be rejected too.
Step 2: block invalid states explicitly
Guard for a non-numeric sensor
For an action that only needs the entity to be present, use a template condition that excludes the invalid states:
condition:
- condition: template
value_template: >-
{{ states('sensor.room_temperature') not in ['unknown', 'unavailable', 'none', ''] }}
Using states('entity_id') is safer than directly reading .state in templates because startup can leave an entity unknown. Replace the example entity with the sensor used by the automation.
Guard before converting a numeric value
Do not convert an unavailable value and hope a default will make the comparison safe. Check the raw state first, then verify that conversion succeeded:
condition:
- condition: template
value_template: >-
{% set raw = states('sensor.room_temperature') %}
{{ raw not in ['unknown', 'unavailable', 'none', '']
and (raw | float(none)) is not none
and (raw | float) > 28 }}
This example permits the action only when the value is numeric and above 28. Set the threshold, unit, and accepted range for the actual device. If a sensor can return text such as a fault code, reject that text rather than silently coercing it.
Check both sides of a numeric comparison
A numeric-state condition does not pass when either the sensor value or the threshold entity is unknown or unavailable. If a numeric condition unexpectedly fails, inspect both entities. A helper used as the threshold can be the unavailable side of the comparison even when the sensor itself is healthy.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Step 3: add a freshness rule that matches the device
Choose the timeout from reporting behavior
There is no universal stale timeout. A mains-powered environmental sensor that reports every 30 seconds might justify a minutes-scale limit. A battery contact sensor that reports only on changes may legitimately remain quiet for days. For the latter, a short “no state change” timeout would create false failures; use device availability or a last-seen signal if the integration provides one.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Set the limit from the expected interval and the risk of acting on old data. A useful policy is to allow several normal reporting intervals, then fail closed or notify. Document the assumption beside the automation so a later change to the device’s reporting schedule does not invalidate the guard.
Prefer a device or integration report timestamp
A last-seen or last-report entity supplied by the device or integration is the clearest freshness signal because it represents an actual communication event. MQTT sensors can expose availability through an availability topic and can expire when updates stop. Use those integration features when available, and make sure the timestamp is updated even when the measured value remains unchanged.
Understand Home Assistant timestamps
last_changed records when the state value changed. Repeated reports of the same value may leave it unchanged, so it is not a reliable universal last-report time. last_updated describes a Home Assistant state-machine update, but its exact usefulness depends on how the integration publishes data. Neither timestamp necessarily proves when the physical sensor took its measurement.
Use a state-machine timeout only with verified semantics
If no device-level timestamp exists, a template can impose a timeout using last_updated, but first verify that the integration updates that timestamp for every successful report. The following is an illustrative pattern, not a universal recipe:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
condition:
- condition: template
value_template: >-
{% set raw = states('sensor.room_temperature') %}
{% set updated = as_timestamp(states.sensor.room_temperature.last_updated, 0) %}
{{ raw not in ['unknown', 'unavailable', 'none', '']
and (raw | float(none)) is not none
and (as_timestamp(now()) - updated) < 900 }}
Here, 900 seconds is only an example. Replace it with a limit justified by the sensor’s reporting interval, and treat the test as invalid if the integration updates Home Assistant for reasons unrelated to a new device report. A dedicated last-seen entity is preferable whenever one exists.
Step 4: account for restarts and automation reloads
Template triggers support a for duration when a condition must remain true for a period. That wait is cleared when Home Assistant restarts or the automation is reloaded. If an unsafe action depends on the timer surviving a restart, do not rely on an in-memory for countdown.
The official template guidance recommends storing the target time in an input_datetime helper. On restart, compare the current time with the stored target and reconstruct the remaining schedule. This makes the deadline persistent instead of silently starting a new countdown after a reload.
Step 5: represent availability upstream
MQTT sensors
The MQTT sensor integration supports an availability topic and expiry behavior. Configure the source to publish an explicit online/offline indication when possible, and set an expiry interval that reflects the expected message cadence. Expiry should be longer than a normal reporting gap but short enough to expose a failed connection before an automation makes a dangerous decision.
Free tools Windows power users keep installed
One-click scans. No signup required.
Other integrations
Availability options differ by integration. Check whether the integration publishes a connectivity entity, a last-seen attribute, or a heartbeat. If an update fails or device data is missing, the integration should mark the entity unavailable; when a fetch succeeds but only some fields are temporarily absent, it may mark the affected entity unknown. The automation should honor those distinctions rather than assigning its own meaning to the strings.
Best Value
Choose what happens when the guard fails
| Situation | Safer default | When to choose another response |
|---|---|---|
| Optional convenience action, such as adjusting a scene | Skip the action silently | Notify if failures persist or affect many entities |
| Important environmental control | Skip and send a notification with the entity and age | Enter a defined fallback mode when regulations or equipment require it |
| Safety-critical actuator | Move to a known safe state and notify | Use a redundant sensor or independent interlock when one sensor cannot provide adequate assurance |
| Repeated connectivity failure | Rate-limit alerts and create a maintenance signal | Escalate after a longer outage rather than sending one alert per trigger |
Do not use a guessed default value to force an action through an invalid-state check. A default can hide a failed sensor and make the automation appear healthy.
Build triggers and conditions as separate responsibilities
The trigger answers “what event should start evaluation?” The conditions answer “is it safe to act now?” Keeping those roles separate makes recovery behavior predictable. For example, a motion trigger can start an automation, while conditions verify that illuminance is numeric, fresh, and within its expected range before turning on a light.
If a stale sensor becomes fresh later and that transition itself should cause an action, add a trigger for the freshness event or for the sensor’s valid-state transition. A condition alone will not launch the automation when it changes from false to true.
Testing procedure before enabling the automation
- Run the automation with a known-good value and confirm that the action occurs.
- Temporarily make the sensor
unknownand confirm that the action is blocked. - Repeat with
unavailable. - Return the entity to a valid value and verify whether the configured trigger intentionally runs on recovery.
- Test a non-numeric response, an empty response, and a value outside the accepted range.
- Simulate a report gap longer than the freshness limit. Confirm that the automation skips or enters the selected fallback and that the notification contains useful context.
- Restart Home Assistant during a template
forwait. Verify the documented reset behavior, or verify that aninput_datetime-based deadline survives as intended. - Check that a threshold helper remains available; an unavailable threshold can block a numeric condition even when the sensor is healthy.
Comparison of freshness and validity approaches
| Approach | Invalid-state coverage | Freshness meaning | Main limitation |
|---|---|---|---|
| Explicit template state guard | Can reject unknown, unavailable, empty, and non-numeric values | None by itself | A valid value may still be old |
| Numeric-state condition alone | Rejects unavailable or unknown operands | None by itself | Does not establish that a valid number is recent |
last_changed timeout |
Depends on the separate state guard | Time since the value changed | Unchanged but successfully reported values look old |
last_updated timeout |
Depends on the separate state guard | Time since Home Assistant updated the state object | Meaning varies with integration behavior and is not necessarily a physical measurement time |
| Device or integration last-seen timestamp | Depends on the separate state guard | Usually closest to an actual report or communication event | Not every integration exposes one |
| Availability topic or expiry | Communicates connectivity state upstream | Based on message presence and expiry | Timeout must match the source’s normal cadence |
Template for duration |
Applies to the condition being held | Measures persistence during the current runtime | Wait resets on restart or automation reload |
Troubleshooting failures
The action runs when the sensor is unavailable
- Confirm that the condition is attached to the automation that performs the action, not only to a different automation.
- Check the exact entity ID; a similarly named entity may be the one used in the action.
- Inspect traces to see whether the condition was evaluated and which value Home Assistant saw at that moment.
- Look for a trigger that starts a different automation without the guard.
The numeric condition never passes
- Inspect the sensor state and the threshold entity for
unknownorunavailable. - Check units and conversion. A string with a unit suffix or a fault message is not a usable number.
- Verify that the comparison direction and threshold match the sensor’s unit.
The stale check reports false failures
- Compare the timeout with the device’s real reporting cadence, including sleep periods for battery devices.
- Determine whether the integration updates
last_updatedon unchanged reports. - Replace a state-machine timestamp with a device last-seen or heartbeat entity when possible.
- Check whether an automation reload or restart reset a
fortimer.
The entity remains unavailable
Treat this as an integration or device problem rather than weakening the automation guard. Check power, network reachability, credentials, broker connectivity, and the integration’s logs. Once the source is healthy, verify that the entity returns to a valid state and that the recovery transition is handled deliberately.
Quick Recap
Deployment checklist
- The automation rejects
unknownandunavailable. - Numeric inputs are validated before conversion and comparison.
- Threshold entities are checked as well as measured entities.
- The freshness signal represents a device report or has verified state-machine semantics.
- The timeout matches the reporting cadence and the risk of stale data.
- Unchanged reports are not mistaken for missing reports.
- Recovery transitions cannot bypass the guard.
- The response to invalid or stale data is explicit: skip, notify, or enter a safe state.
- Restart behavior for template
forwaits is understood and, where necessary, persisted withinput_datetime. - The failure and recovery paths have been tested in traces.
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.

