@@ -204,7 +204,7 @@ You can set an attribute directly by assigning ``DOMAIN.name.attr = value``.
204
204
205
205
In cases where you need to compute the name of the state variable dynamically, or you need to set or
206
206
get all the state attributes, you can use the built-in functions ``state.get() ``, ``state.getattr() ``,
207
- ``state.set() ``and ``state.setattr() ``; see `State Functions <#state-variable-functions >`__.
207
+ ``state.set() ``, `` state.exist() `` and ``state.setattr() ``; see `State Variables <#state-variables >`__.
208
208
209
209
The function ``state.names(domain=None) `` returns a list of all state variable names (i.e.,
210
210
``entity_id ``\ s) of a domain. If ``domain `` is not specified, it returns all HASS state
@@ -1118,12 +1118,14 @@ State variables
1118
1118
State variables can be used and set just by using them as normal Python variables. However, there
1119
1119
could be cases where you want to dynamically generate the variable name (e.g., in a function or loop
1120
1120
where the state variable name is computed dynamically). These functions allow you to get and set a
1121
- variable using its string name. The set function also allows you to optionally set the attributes,
1122
- which you can't do if you are directly assigning to the variable:
1121
+ variable or attribute using its string name. The set function also allows you to optionally set the
1122
+ attributes, which you can't do if you are directly assigning to the variable:
1123
1123
1124
1124
``state.delete(name) ``
1125
1125
Deletes the given state variable or attribute. The Python ``del `` statement can also be used
1126
1126
to delete a state variable or attribute.
1127
+ ``state.exist(name) ``
1128
+ Returns ``True `` if the given state variable or attribute exists, otherwise ``False ``.
1127
1129
``state.get(name) ``
1128
1130
Returns the value of the state variable given its string ``name ``. A ``NameError `` exception
1129
1131
is thrown if the name doesn't exist. If ``name `` is a string of the form ``DOMAIN.entity.attr ``
0 commit comments