Update example platforms for async conventions (#1998)
This commit is contained in:
parent
38e6098ad8
commit
daa11ee550
2 changed files with 20 additions and 4 deletions
|
@ -38,6 +38,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class ExampleSensor(Entity):
|
||||
"""Representation of a Sensor."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the sensor."""
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
|
@ -46,10 +50,17 @@ class ExampleSensor(Entity):
|
|||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return 23
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_CELSIUS
|
||||
|
||||
def update(self):
|
||||
"""Fetch new state data for the sensor.
|
||||
|
||||
This is the only method that should fetch new data for Home Assistant.
|
||||
"""
|
||||
self._state = 23
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue