Skip to content

Commit 4915c8e

Browse files
authored
Use named kwarg for add_entities' update_before_add parameter (#1695)
1 parent cdebb4d commit 4915c8e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/creating_platform_code_review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
6969
```
7070

7171
2. Avoid passing in `hass` as a parameter to the entity. `hass` will be set on the entity when the entity is added to Home Assistant. This means you can access `hass` as `self.hass` inside the entity.
72-
3. Do not call `update()` in constructor, use `add_entities(devices, True)` instead.
72+
3. Do not call `update()` in constructor, use `add_entities(devices, update_before_add=True)` instead.
7373
4. Do not do any I/O inside properties. Cache values inside `update()` instead.
7474
5. When dealing with time, state and/or attributes should not contain relative time since something happened. Instead, it should store UTC timestamps.
7575
6. Leverage the [entity lifecycle callbacks](core/entity.md#lifecycle-hooks) to attach event listeners or clean up connections.

docs/integration_fetching_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Some APIs will offer an endpoint per device. It sometimes won't be possible to m
148148

149149
If you can map exactly one device endpoint to a single entity, you can fetch the data for this entity inside the `update()`/`async_update()` methods. Make sure polling is set to `True` and Home Assistant will call this method regularly.
150150

151-
If your entities need to fetch data before being written to Home Assistant for the first time, pass `True` to the `add_entities` method: `add_entities([MyEntity()], True)`.
151+
If your entities need to fetch data before being written to Home Assistant for the first time, pass `update_before_add=True` to the `add_entities` method: `add_entities([MyEntity()], update_before_add=True)`.
152152

153153
You can control the polling interval for your integration by defining a `SCAN_INTERVAL` constant in your platform. Careful with setting this too low. It will take up resources in Home Assistant, can overwhelm the device hosting the API or can get you blocked from cloud APIs. The minimum allowed value is 5 seconds.
154154

0 commit comments

Comments
 (0)