mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-09 10:26:30 +00:00
parent
5537cef36c
commit
880e00d8f1
@ -12,16 +12,16 @@ For a generic introduction of entities, see [entities architecture](../architect
|
|||||||
Below is an example switch entity that keeps track of their state in memory.
|
Below is an example switch entity that keeps track of their state in memory.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchEntity
|
||||||
|
|
||||||
|
|
||||||
class MySwitch(SwitchDevice):
|
class MySwitch(SwitchEntity):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._is_on = False
|
self._is_on = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Name of the device."""
|
"""Name of the entity."""
|
||||||
return "My Switch"
|
return "My Switch"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user