mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use _attr_** in slide (#62206)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
6a489bb45a
commit
1d1c91a4eb
@ -4,10 +4,10 @@ import logging
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
DEVICE_CLASS_CURTAIN,
|
||||
STATE_CLOSED,
|
||||
STATE_CLOSING,
|
||||
STATE_OPENING,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
)
|
||||
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):
|
||||
"""Representation of a Slide cover."""
|
||||
|
||||
_attr_assumed_state = True
|
||||
_attr_device_class = CoverDeviceClass.CURTAIN
|
||||
|
||||
def __init__(self, api, slide):
|
||||
"""Initialize the cover."""
|
||||
self._api = api
|
||||
self._slide = slide
|
||||
self._id = slide["id"]
|
||||
self._unique_id = slide["mac"]
|
||||
self._name = slide["name"]
|
||||
self._attr_extra_state_attributes = {ATTR_ID: self._id}
|
||||
self._attr_unique_id = slide["mac"]
|
||||
self._attr_name = slide["name"]
|
||||
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
|
||||
def is_opening(self):
|
||||
"""Return if the cover is opening or not."""
|
||||
@ -81,16 +70,6 @@ class SlideCover(CoverEntity):
|
||||
"""Return False if state is not available."""
|
||||
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
|
||||
def current_cover_position(self):
|
||||
"""Return the current position of cover shutter."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user