Skip to content

Commit c6a6144

Browse files
Rename attribute
1 parent 8739b59 commit c6a6144

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Label State Helpers for Home Assistant
1111
You can create state, not state and numeric state helpers which provide a binary sensor that turns on if any entity with an assigned label matches the criteria you specify.
1212

1313
An `entities` attribute is available which lists all entities that match the criteria.
14-
A `friendly_names` attribute is available which lists either the device (entity) names or just the entity name if the entity is not part of a device, for all entities that match the criteria.
14+
A `entity_names` attribute is available which lists either the device (entity) names or just the entity name if the entity is not part of a device, for all entities that match the criteria.
1515

1616
## Example use cases
1717

@@ -83,7 +83,7 @@ actions:
8383
data:
8484
message: >-
8585
Critical sensors are unavailable {{
86-
state_attr('binary_sensor.critical_sensor_unavailable', 'friendly_names') |
86+
state_attr('binary_sensor.critical_sensor_unavailable', 'entity_names') |
8787
join(', ') }}
8888
mode: single
8989
```

custom_components/label_state/binary_sensor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from .const import (
2525
ATTR_ENTITIES,
26-
ATTR_FRIENDLY_NAMES,
26+
ATTR_ENTITY_NAMES,
2727
CONF_LABEL,
2828
CONF_STATE_LOWER_LIMIT,
2929
CONF_STATE_NOT,
@@ -266,7 +266,7 @@ def _calc_state(self) -> None:
266266

267267
state_is_on: bool | None = False
268268
entities_on: list[str] = []
269-
friendly_names: list[str] = []
269+
entity_names: list[str] = []
270270

271271
entity_registry = er.async_get(self.hass)
272272

@@ -285,7 +285,7 @@ def _calc_state(self) -> None:
285285
state_is_on = True
286286
entities_on.append(entity_id)
287287
name = self._get_device_or_entity_name(entity_id)
288-
friendly_names.append(name)
288+
entity_names.append(name)
289289

290290
if self._state_type == StateTypes.NOT_STATE:
291291
for entity_id in self._state_dict.keys():
@@ -302,7 +302,7 @@ def _calc_state(self) -> None:
302302
state_is_on = True
303303
entities_on.append(entity_id)
304304
name = self._get_device_or_entity_name(entity_id)
305-
friendly_names.append(name)
305+
entity_names.append(name)
306306

307307
if self._state_type == StateTypes.NUMERIC_STATE:
308308
for entity_id in self._state_dict.keys():
@@ -328,7 +328,7 @@ def _calc_state(self) -> None:
328328
state_is_on = True
329329
entities_on.append(entity_id)
330330
name = self._get_device_or_entity_name(entity_id)
331-
friendly_names.append(name)
331+
entity_names.append(name)
332332

333333
LOGGER.debug(
334334
"State %s is below lower limit %s and above upper limit %s for %s",
@@ -345,7 +345,7 @@ def _calc_state(self) -> None:
345345
state_is_on = True
346346
entities_on.append(entity_id)
347347
name = self._get_device_or_entity_name(entity_id)
348-
friendly_names.append(name)
348+
entity_names.append(name)
349349

350350
LOGGER.debug(
351351
"State %s is below lower limit %s for %s",
@@ -361,7 +361,7 @@ def _calc_state(self) -> None:
361361
state_is_on = True
362362
entities_on.append(entity_id)
363363
name = self._get_device_or_entity_name(entity_id)
364-
friendly_names.append(name)
364+
entity_names.append(name)
365365

366366
LOGGER.debug(
367367
"State %s is above upper limit %s for %s",
@@ -384,7 +384,7 @@ def _calc_state(self) -> None:
384384

385385
self._attr_is_on = state_is_on
386386
self._attr_extra_state_attributes[ATTR_ENTITIES] = entities_on
387-
self._attr_extra_state_attributes[ATTR_FRIENDLY_NAMES] = friendly_names
387+
self._attr_extra_state_attributes[ATTR_ENTITY_NAMES] = entity_names
388388

389389
def _get_device_or_entity_name(
390390
self,

custom_components/label_state/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
CONF_STATE_UPPER_LIMIT = "state_upper_limit"
3232

3333
ATTR_ENTITIES = "entities"
34-
ATTR_FRIENDLY_NAMES = "friendly_names"
34+
ATTR_ENTITY_NAMES = "entity_names"
3535

3636

3737
class StateTypes(StrEnum):

0 commit comments

Comments
 (0)