Home Assistant Automation Triggers: Polling vs Events FAQ
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
Home Assistant automations can be triggered either by polling (checking a state at intervals) or by events (instant notifications of changes). This article answers the most common questions about choosing, configuring, and troubleshooting these two trigger types, with practical examples and clear explanations.
What Are Polling and Event Triggers?
In Home Assistant, a polling trigger checks a sensor or entity at a fixed interval (e.g., every 30 seconds) and fires the automation if the condition is true at that moment. An event trigger listens for a state change or an event bus message and fires immediately when that change occurs, without waiting for a poll cycle.
For example, a motion sensor typically uses an event trigger: the sensor reports “on� the instant motion is detected, and the automation turns on lights immediately. A temperature sensor that updates every 5 minutes might use a polling trigger if you only need to check the temperature every hour for a climate control routine.
How Polling Triggers Work
Polling triggers in Home Assistant are defined in YAML using the platform: state or platform: time_pattern with a for: duration. The most common pattern is:
trigger:
platform: state
entity_id: sensor.outdoor_temp
to: "25"
for: "00:05:00"
This fires when the sensor’s state changes to exactly 25°C and stays there for 5 minutes. However, if the sensor updates only every 10 minutes, the automation might miss the exact “25� state. To avoid this, you can use a numeric state trigger with a threshold:
trigger:
platform: numeric_state
entity_id: sensor.outdoor_temp
above: 24
below: 26
for: "00:05:00"
This fires when the temperature is between 24 and 26°C for 5 minutes, which is more robust for sensors that update infrequently.
How Event Triggers Work
Event triggers listen to the Home Assistant event bus. The most common is platform: event with event_type: state_changed, but you can also listen to custom events like mqtt_message_received or homeassistant_start. A simple event trigger:
trigger:
platform: event
event_type: state_changed
event_data:
entity_id: binary_sensor.front_door
new_state: "on"
This fires the instant the door sensor changes to “on�. No polling interval is involved, so the response is immediate. Event triggers are ideal for:
- Motion, door/window, and presence sensors
- Button presses and remote controls
- Notifications from integrations that push updates (e.g., MQTT, REST, WebSocket)
Choosing Between Polling and Events
The choice depends on how often the sensor updates and how quickly you need a response. Consider these factors:
- Update frequency: If a sensor updates every 5 minutes, a polling trigger every 30 seconds is wasteful; use a longer interval or an event trigger if the sensor pushes updates.
- Response time: Events are immediate; polling introduces a delay up to the poll interval. For security or safety automations, use events.
- Resource usage: Polling wakes up the system repeatedly, even if nothing changes. Events only fire when something happens, saving CPU and battery on IoT devices.
- Reliability: If a sensor fails to report a change, an event trigger will miss it, but a polling trigger might catch it on the next check. For critical conditions, combine both.
A common hybrid approach is to use an event trigger for immediate response and a time-based polling trigger as a fallback. For example, a water leak sensor triggers an alert instantly via event, and a daily poll at 8 AM checks if the sensor is still wet to send a reminder.
Common Problems and Misconceptions
One frequent mistake is assuming that state triggers are event-based. In Home Assistant, state triggers are actually event-driven—they listen to state_changed events. However, the sensor itself may be polled by its integration. So the trigger is instant when the sensor updates, but the sensor’s update might be delayed by its own polling interval.
Another issue is the for: duration. If a sensor updates every 10 minutes and you set for: "00:05:00", the automation will only fire if the state remains unchanged for 5 consecutive minutes. If the sensor updates every 10 minutes, the state might change at minute 5, resetting the timer. Use a for: that is shorter than the sensor’s update interval, or use a numeric threshold with a tolerance.
Also, beware of trigger IDs. If you have multiple triggers in one automation, you need to use id: to distinguish them in the action, otherwise the automation may run multiple times. For example:
trigger:
- platform: state
entity_id: binary_sensor.motion
to: "on"
id: motion_on
- platform: numeric_state
entity_id: sensor.temp
above: 30
id: high_temp
Then in the action, use choose based on trigger.id.
Performance and Best Practices
Polling too frequently can overload the system, especially with many sensors. A poll every 10 seconds for a sensor that updates every minute is unnecessary. As a rule of thumb:
- Use the sensor’s native update interval as a guide; poll at most every 30 seconds for fast-changing sensors, and every 5 minutes for slow ones.
- For integrations that support it, use
eventtriggers instead of polling to reduce load. - Group multiple automations that poll the same sensor into one automation with multiple triggers to avoid duplicate polls.
- Use
for:to debounce noisy sensors, but set it appropriately to avoid missing events.
When testing, use the “Run� button in the developer tools to fire a trigger manually. This helps verify that the automation logic works without waiting for the actual event.
Frequently Asked Questions
Can I use both polling and event triggers in one automation?
Yes, you can define multiple triggers in a single automation. They are evaluated in parallel—whichever fires first will start the automation. Use id: to know which trigger fired, and use choose in the action to handle each case differently.
Why does my automation not fire when the sensor changes?
Check if the sensor actually updates. Some integrations only poll every few minutes. Also verify that the trigger condition matches exactly—for state triggers, the to: value must match the sensor’s new state, including units (e.g., “25� vs “25.0�). Use the developer tools to see the current state and test the trigger manually.
What is the difference between a state trigger and an event trigger?
A state trigger is a convenience wrapper around the state_changed event. It fires when an entity’s state changes, and you can specify from, to, and for. An event trigger listens to any event type, including custom events, and gives you more flexibility but requires you to filter by event data.
How often should I poll a sensor?
Poll at a rate that is at least twice the sensor’s update frequency to catch changes reliably, but not more than once every 10 seconds for most sensors. For example, if a temperature sensor updates every 60 seconds, poll every 30 seconds. If you need immediate response, use an event trigger instead.
Does polling drain battery on battery-powered sensors?
Yes, frequent polling can drain batteries on devices that are normally asleep. Prefer event-driven integrations like Zigbee or Z-Wave, which push updates, and avoid polling those devices. For battery-powered sensors, set the integration’s polling interval to the maximum acceptable value.
Can I make a polling trigger that checks every hour but only fires if the value is above a threshold?
Yes, use a time_pattern trigger with a numeric_state condition. For example, trigger on time_pattern: hours: "/1" and then in the condition check sensor.temp > 30. This is a hybrid approach: the trigger is time-based, but the condition filters the value.
Conclusion
Understanding the difference between polling and event triggers is key to building efficient and responsive Home Assistant automations. Use events for instant reactions and polling for periodic checks, and combine them when needed. Always test your automations and monitor system performance to avoid unnecessary load.
Related
Formula used
in t | Poll interval (seconds) | s | 30 | 1 in d | Event delay (seconds) | s | 0 | 0 out p | Polls per hour | polls/h | 3600 / t | 0 out e | Events per hour (est.) | events/h | 3600 / (d + 10) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.