Add device class support for button entity (#1145)

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Franck Nijhof 2021-11-30 08:28:14 +01:00 committed by GitHub
parent dae81bc86f
commit c34b75731a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,12 +16,10 @@ and can be helpful for controlling device features like (but not limited to):
If you want to represent something that can be turned on and off (and thus have an actual state), you should use a `switch` entity instead. If you want to integrate a real, physical, stateless button device in Home Assistant, you can do so by firing custom events. The entity button entity isn't suitable for these cases. If you want to represent something that can be turned on and off (and thus have an actual state), you should use a `switch` entity instead. If you want to integrate a real, physical, stateless button device in Home Assistant, you can do so by firing custom events. The entity button entity isn't suitable for these cases.
## Properties ## Properties
As this integration is stateless, it doesn't provide any specific properties for itself. As this integration is stateless, it doesn't provide any specific properties for itself.
Other properties that are common to all entities such as `icon`, `name` etc are still applicable. Other properties that are common to all entities such as `device_class`, `icon`, `name` etc are still applicable.
## Methods ## Methods
@ -41,3 +39,12 @@ class MyButton(ButtonEntity):
async def async_press(self) -> None: async def async_press(self) -> None:
"""Handle the button press.""" """Handle the button press."""
``` ```
### Available device classes
Optionally specifies what type of entity it is. It will possibly map to Google device types.
| Value | Description
| ----- | -----------
| restart | The button entity restarts the device.
| update | The button entity updates the software of the device.