From 415deac62aaf2d5710f16faeaa38fb21eab583af Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 14 May 2020 12:07:11 -0700 Subject: [PATCH] Add blog about renaming entity classes (#526) --- blog/2020-05-14-entity-class-names.md | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 blog/2020-05-14-entity-class-names.md diff --git a/blog/2020-05-14-entity-class-names.md b/blog/2020-05-14-entity-class-names.md new file mode 100644 index 00000000..a11af0bc --- /dev/null +++ b/blog/2020-05-14-entity-class-names.md @@ -0,0 +1,32 @@ +--- +author: Paulus Schoutsen +authorURL: https://github.com/balloob +authorTwitter: balloob +title: Entity class names +--- + +Ever wondered when implementing entities for our entity integrations why you had to extend `BinarySensorDevice` and not `BinarySensorEntity`? Wonder no longer, as we have addressed the situation in Home Assistant 0.110 by renaming all classes that incorrectly had Device in their name. The old classes are still around but will log a warning when used. + +All integrations in Home Assistant have been upgraded. Custom component authors need to do the migration themselves. You can do this while keeping backwards compatibility by using the following snippet: + +```python +try: + from homeassistant.components.binary_sensor import BinarySensorEntity +except ImportError: + from homeassistant.components.binary_sensor import BinarySensorDevice as BinarySensorEntity +``` + +The following classes have been renamed: + +| Old Class Name | New Class Name | +| -------------------- | -------------------- | +| `BinarySensorDevice` | `BinarySensorEntity` | +| `MediaPlayerDevice` | `MediaPlayerEntity` | +| `LockDevice` | `LockEntity` | +| `ClimateDevice` | `ClimateEntity` | +| `CoverDevice` | `CoverEntity` | +| `VacuumDevice` | `VacuumEntity` | +| `RemoteDevice` | `RemoteEntity` | +| `Light` | `LightEntity` | +| `SwitchDevice` | `SwitchEntity` | +| `WaterHeaterDevice` | `WaterHeaterEntity` |