mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Remove usage of ATTR_FRIENDLY_NAME within components/platforms
This commit is contained in:
parent
39bbfd14d9
commit
b29f2f6d6f
@ -16,8 +16,7 @@ from homeassistant.helpers import validate_config
|
|||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_USERNAME, CONF_PASSWORD, EVENT_PLATFORM_DISCOVERED,
|
CONF_HOST, CONF_USERNAME, CONF_PASSWORD, EVENT_PLATFORM_DISCOVERED,
|
||||||
EVENT_HOMEASSISTANT_STOP, ATTR_SERVICE, ATTR_DISCOVERED,
|
EVENT_HOMEASSISTANT_STOP, ATTR_SERVICE, ATTR_DISCOVERED)
|
||||||
ATTR_FRIENDLY_NAME)
|
|
||||||
|
|
||||||
DOMAIN = "isy994"
|
DOMAIN = "isy994"
|
||||||
REQUIREMENTS = ['PyISY==1.0.5']
|
REQUIREMENTS = ['PyISY==1.0.5']
|
||||||
@ -147,7 +146,7 @@ class ISYDeviceABC(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
""" Returns the state attributes for the node. """
|
""" Returns the state attributes for the node. """
|
||||||
attr = {ATTR_FRIENDLY_NAME: self.name}
|
attr = {}
|
||||||
for name, prop in self._attrs.items():
|
for name, prop in self._attrs.items():
|
||||||
attr[name] = getattr(self, prop)
|
attr[name] = getattr(self, prop)
|
||||||
attr = self._attr_filter(attr)
|
attr = self._attr_filter(attr)
|
||||||
|
@ -7,8 +7,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/light.tellstick/
|
https://home-assistant.io/components/light.tellstick/
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.light import Light, ATTR_BRIGHTNESS
|
from homeassistant.components.light import Light, ATTR_BRIGHTNESS
|
||||||
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
ATTR_FRIENDLY_NAME)
|
|
||||||
REQUIREMENTS = ['tellcore-py==1.1.2']
|
REQUIREMENTS = ['tellcore-py==1.1.2']
|
||||||
SIGNAL_REPETITIONS = 1
|
SIGNAL_REPETITIONS = 1
|
||||||
|
|
||||||
@ -58,7 +57,6 @@ class TellstickLight(Light):
|
|||||||
import tellcore.constants as tellcore_constants
|
import tellcore.constants as tellcore_constants
|
||||||
|
|
||||||
self.tellstick_device = tellstick_device
|
self.tellstick_device = tellstick_device
|
||||||
self.state_attr = {ATTR_FRIENDLY_NAME: tellstick_device.name}
|
|
||||||
self.signal_repetitions = signal_repetitions
|
self.signal_repetitions = signal_repetitions
|
||||||
self._brightness = 0
|
self._brightness = 0
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ DEFAULT_PROXIMITY_ZONE = 'home'
|
|||||||
ATTR_DIST_FROM = 'dist_to_zone'
|
ATTR_DIST_FROM = 'dist_to_zone'
|
||||||
ATTR_DIR_OF_TRAVEL = 'dir_of_travel'
|
ATTR_DIR_OF_TRAVEL = 'dir_of_travel'
|
||||||
ATTR_NEAREST = 'nearest'
|
ATTR_NEAREST = 'nearest'
|
||||||
ATTR_FRIENDLY_NAME = 'friendly_name'
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -94,6 +93,11 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
|
|||||||
self.tolerance = tolerance
|
self.tolerance = tolerance
|
||||||
self.proximity_zone = proximity_zone
|
self.proximity_zone = proximity_zone
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the entity."""
|
||||||
|
return self.friendly_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state. """
|
""" Returns the state. """
|
||||||
@ -110,7 +114,6 @@ class Proximity(Entity): # pylint: disable=too-many-instance-attributes
|
|||||||
return {
|
return {
|
||||||
ATTR_DIR_OF_TRAVEL: self.dir_of_travel,
|
ATTR_DIR_OF_TRAVEL: self.dir_of_travel,
|
||||||
ATTR_NEAREST: self.nearest,
|
ATTR_NEAREST: self.nearest,
|
||||||
ATTR_FRIENDLY_NAME: self.friendly_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_proximity_state_change(self, entity, old_state, new_state):
|
def check_proximity_state_change(self, entity, old_state, new_state):
|
||||||
|
@ -24,7 +24,7 @@ ENTITY_ID_PATTERN = re.compile(r"^(\w+)\.(\w+)$")
|
|||||||
|
|
||||||
def generate_entity_id(entity_id_format, name, current_ids=None, hass=None):
|
def generate_entity_id(entity_id_format, name, current_ids=None, hass=None):
|
||||||
"""Generate a unique entity ID based on given entity IDs or used ids."""
|
"""Generate a unique entity ID based on given entity IDs or used ids."""
|
||||||
name = name.lower() or DEVICE_DEFAULT_NAME.lower()
|
name = (name or DEVICE_DEFAULT_NAME).lower()
|
||||||
if current_ids is None:
|
if current_ids is None:
|
||||||
if hass is None:
|
if hass is None:
|
||||||
raise RuntimeError("Missing required parameter currentids or hass")
|
raise RuntimeError("Missing required parameter currentids or hass")
|
||||||
@ -71,7 +71,7 @@ class Entity(object):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the entity."""
|
"""Return the name of the entity."""
|
||||||
return DEVICE_DEFAULT_NAME
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -161,7 +161,7 @@ class Entity(object):
|
|||||||
state = STATE_UNAVAILABLE
|
state = STATE_UNAVAILABLE
|
||||||
attr = {}
|
attr = {}
|
||||||
|
|
||||||
if ATTR_FRIENDLY_NAME not in attr and self.name is not None:
|
if self.name is not None:
|
||||||
attr[ATTR_FRIENDLY_NAME] = str(self.name)
|
attr[ATTR_FRIENDLY_NAME] = str(self.name)
|
||||||
|
|
||||||
if ATTR_ICON not in attr and self.icon is not None:
|
if ATTR_ICON not in attr and self.icon is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user