Skip to content
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions docs/entity_switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: Switch Entity
sidebar_label: Switch
---

A switch entity turns on or off something, for example a relay. Derive a platform entity from [`homeassistant.components.switch.SwitchEntity`](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/switch/__init__.py).
To represent something which can be turned on or off but can't be controlled, for example a wall switch which transmits its state but can't be turned on or off from Home Assistant, a Binary Sensor is a better choice.
To represent something which doesn't have a state, for example a door bell push button, a custom event or a Device Trigger is a better choice.

## Properties

:::tip
Expand All @@ -23,7 +27,7 @@ Properties should always only return information from memory and not do I/O (lik
Turn the switch on.

```python
class MySwitch(SwitchDevice):
class MySwitch(SwitchEntity):
# Implement one of these methods.

def turn_on(self, **kwargs) -> None:
Expand All @@ -38,7 +42,7 @@ class MySwitch(SwitchDevice):
Turn the switch off.

```python
class MySwitch(SwitchDevice):
class MySwitch(SwitchEntity):
# Implement one of these methods.

def turn_off(self, **kwargs):
Expand All @@ -53,7 +57,7 @@ class MySwitch(SwitchDevice):
Optional. If not implemented will default to checking what method to call using the `is_on` property.

```python
class MySwitch(SwitchDevice):
class MySwitch(SwitchEntity):
# Implement one of these methods.

def toggle(self, **kwargs):
Expand Down