You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conditions are checks that must be met in order for an automation to trigger. Implement them in the `condition` platform (`condition.py`) of your integration by creating and registering condition classes.
102
+
103
+
### Condition class
104
+
105
+
Conditions inherit from `homeassistant.helpers.condition.Condition` and must implement `async_validate_config` and `async_get_checker`.
106
+
Just as with the [trigger class](#trigger-class), `async_validate_config` is used to validate the condition configuration.
107
+
`async_get_checker` should return a function that will be called whenever the condition needs to be checked.
108
+
109
+
In the following snippet we create a condition that can be configured to only pass when `binary_sensor.front_door` has a desired configured state.
110
+
111
+
```python
112
+
from typing importTYPE_CHECKING, override
113
+
114
+
import voluptuous as vol
115
+
116
+
from homeassistant.const importSTATE_OFF, STATE_ON, CONF_STATE
117
+
from homeassistant.core import HomeAssistant
118
+
from homeassistant.helpers import config_validation as cv
119
+
from homeassistant.helpers.condition import (
120
+
Condition,
121
+
ConditionCheckerType,
122
+
ConditionConfig,
123
+
trace_condition_function,
124
+
)
125
+
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
0 commit comments