Skip to content

Commit af29799

Browse files
mw-whiteballoob
authored andcommitted
Add include/exclude filter to mqtt_statestream docs (home-assistant#3893)
* Add include/exclude filter to mqtt_statestream docs * ✏️ Small changes
1 parent 33d0643 commit af29799

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

source/_components/mqtt_statestream.markdown

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ Configuration variables:
3232
Default is false.
3333
- **publish_timestamps** (*Optional*): Publish the last_changed and last_updated timestamps for the entity.
3434
Default is false.
35+
- **exclude** (*Optional*): Configure which components should be excluded from recordings. See *Include/Exclude* section below for details.
36+
- **entities** (*Optional*): The list of entity ids to be excluded from recordings.
37+
- **domains** (*Optional*): The list of domains to be excluded from recordings.
38+
- **include** (*Optional*): Configure which components should be included in recordings. If set, all other entities will not be recorded.
39+
- **entities** (*Optional*): The list of entity ids to be included from recordings.
40+
- **domains** (*Optional*): The list of domains to be included from recordings.
3541
3642
## Operation
3743
@@ -44,6 +50,56 @@ For example, with the example configuration above, if an entity called 'light.ma
4450

4551
If that entity also has an attribute called `brightness`, the component will also publish the value of that attribute to `homeassistant/light/master_bedroom_dimmer/brightness`.
4652

47-
All states and attributes are passed through JSON serialization before publishing. **Please note** that this causes strings to be quoted (e.g., the string 'on' will be published as '"on"'). You can access the JSON deserialized values (as well as unquoted strings) at many places by using `value_json` instead of `value`.
53+
All states and attributes are passed through JSON serialization before publishing. **Please note** that this causes strings to be quoted (e.g., the string 'on' will be published as '"on"'). You can access the JSON deserialized values (as well as unquoted strings) at many places by using `value_json` instead of `value`.
4854

4955
The last_updated and last_changed values for the entity will be published to `homeassistant/light/master_bedroom_dimmer/last_updated` and `homeassistant/light/master_bedroom_dimmer/last_changed`, respectively. The timestamps are in ISO 8601 format - for example, `2017-10-01T23:20:30.920969+00:00`.
56+
57+
## Include/exclude
58+
59+
The **exclude** and **include** configuration variables can be used to filter the items that are published to MQTT.
60+
61+
1\. If neither **exclude** or **include** are specified, all entities are published.
62+
63+
2\. If only **exclude** is specified, then all entities except the ones listed are published.
64+
65+
```yaml
66+
# Example of excluding entities
67+
mqtt_statestream:
68+
base_topic: homeassistant
69+
exclude:
70+
domains:
71+
- switch
72+
entities:
73+
- sensor.nopublish
74+
```
75+
In the above example, all entities except for *switch.x* and *sensor.nopublish* will be published to MQTT.
76+
77+
3\. If only **include** is specified, then only the specified entries are published.
78+
79+
```yaml
80+
# Example of excluding entities
81+
mqtt_statestream:
82+
base_topic: homeassistant
83+
include:
84+
domains:
85+
- sensor
86+
entities:
87+
- lock.important
88+
```
89+
In this example, only *sensor.x* and *lock.important* will be published.
90+
91+
4\. If both **include** and **exclude** are specified then all entities specified by **include** are published except for the ones
92+
specified by **exclude**.
93+
94+
```yaml
95+
# Example of excluding entities
96+
mqtt_statestream:
97+
base_topic: homeassistant
98+
include:
99+
domains:
100+
- sensor
101+
exclude:
102+
entities:
103+
- sensor.noshow
104+
```
105+
In this example, all sensors except for *sensor.noshow* will be published.

0 commit comments

Comments
 (0)