Use _attr_** in slide (#62206)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-19 13:08:59 +01:00 committed by GitHub
parent 6a489bb45a
commit 1d1c91a4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,10 @@ import logging
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
DEVICE_CLASS_CURTAIN,
STATE_CLOSED, STATE_CLOSED,
STATE_CLOSING, STATE_CLOSING,
STATE_OPENING, STATE_OPENING,
CoverDeviceClass,
CoverEntity, CoverEntity,
) )
from homeassistant.const import ATTR_ID from homeassistant.const import ATTR_ID
@ -35,30 +35,19 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
class SlideCover(CoverEntity): class SlideCover(CoverEntity):
"""Representation of a Slide cover.""" """Representation of a Slide cover."""
_attr_assumed_state = True
_attr_device_class = CoverDeviceClass.CURTAIN
def __init__(self, api, slide): def __init__(self, api, slide):
"""Initialize the cover.""" """Initialize the cover."""
self._api = api self._api = api
self._slide = slide self._slide = slide
self._id = slide["id"] self._id = slide["id"]
self._unique_id = slide["mac"] self._attr_extra_state_attributes = {ATTR_ID: self._id}
self._name = slide["name"] self._attr_unique_id = slide["mac"]
self._attr_name = slide["name"]
self._invert = slide["invert"] self._invert = slide["invert"]
@property
def unique_id(self):
"""Return the device unique id."""
return self._unique_id
@property
def name(self):
"""Return the device name."""
return self._name
@property
def extra_state_attributes(self):
"""Return device specific state attributes."""
return {ATTR_ID: self._id}
@property @property
def is_opening(self): def is_opening(self):
"""Return if the cover is opening or not.""" """Return if the cover is opening or not."""
@ -81,16 +70,6 @@ class SlideCover(CoverEntity):
"""Return False if state is not available.""" """Return False if state is not available."""
return self._slide["online"] return self._slide["online"]
@property
def assumed_state(self):
"""Let HA know the integration is assumed state."""
return True
@property
def device_class(self):
"""Return the device class of the cover."""
return DEVICE_CLASS_CURTAIN
@property @property
def current_cover_position(self): def current_cover_position(self):
"""Return the current position of cover shutter.""" """Return the current position of cover shutter."""