Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/core/entity/light.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class MyLightEntity(LightEntity):
...

value_in_range = math.ceil(brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS]))
```

:::

Expand All @@ -170,3 +171,17 @@ class MyLightEntity(LightEntity):
async def async_turn_off(self, **kwargs):
"""Turn device off."""
```

### Toggle Light Device

```python
class MyLightEntity(LightEntity):
async def async_toggle(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that integrations only need to implement this if the API that is integrated directly supports toggling the state of the device? If the API only supports turning on and off, integrations should not implement the async_toggle method. The base class has a default implementation that falls back on turn_on and turn_off.

"""Toggle the entity."""
```

:::tip No sync `toggle`

Unlike `turn_on`/`turn_off`, there is no support for synchronously toggling a light.

:::