Added properties entities and methods (#228)

* Added properties entities and methods

* Fix formatting, remove extraneous text

* Added more classes and methods

* Removed State attributes from properties

* Removed unnecessarily exposed methods from doc

* Added methods turn_off and turn_on

* Add backticks/replace LightDevice w ToggleEnity

Will added is_on soon

* Added is_on

* Fixed methods
This commit is contained in:
luismonge1192 2019-04-29 18:29:17 +00:00 committed by Paulus Schoutsen
parent fe8b3005a7
commit b30087d9e4

View File

@ -3,14 +3,59 @@ title: Light Entity
sidebar_label: Light
---
> This entry is incomplete. Contribution welcome.
A light entity is a device that controls the brightness, RGB value,color temperature and effects of a light source.
## Properties
> Properties should always only return information from memory and not do I/O (like network requests). Implement `update()` or `async_update()` to fetch data.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| ---- | ---- | ---- | ----
| brightness | int | None | Return the brightness of this light between 0..255
| color_temp | int | None | Return the CT color value in mireds.
| effect | String | None | Return the current effect.
| effect_list | list | None | Return the list of supported effects.
| hs_color | list | None | Return the hue and saturation color value [float, float].
| is_on | bool | bool | Returns if the light entity is on or not.
| max_minreds | int | int | Return the warmest color_temp that this light supports.
| min_mireds | int | int | Return the coldest color_temp that this light supports.
| supported_features | int | int | Flag supported features.
| white_value | int | None | Return the white value of this light between 0..255.
## Support Feature
| Constant | Description
|----------|-----------------------
| `SUPPORT_BRIGHTNESS` | Controls the brightness of a light source
| `SUPPORT_COLOR` | Controls the color a light source shows
| `SUPPORT_COLOR_TEMP` | Controls the representation a light source shows based on temperature
| `SUPPORT_EFFECT` | Controls the effect a light source shows
| `SUPPORT_FLASH` | Controls the duration of a flash a light source shows
| `SUPPORT_TRANSITION` | Controls the duration of transitions between color and effects
| `SUPPORT_WHITE_VALUE` | Controls the white light a light source shows.
## Methods
# Turn on Light Device
```python
class MyLightDevice(LightDevice):
def turn_on(self, **kwargs):
"""Turn the device on."""
async def async_turn_on(self, **kwargs):
"""Turn device on."""
```
# Turn Off Light Device
```python
class MyLightDevice(LightDevice):
def turn_off(self, **kwargs):
"""Turn the device off."""
async def async_turn_off(self, **kwargs):
"""Turn device off."""
```