Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
1cdfb06d
Unverified
Commit
1cdfb06d
authored
1 year ago
by
J. Nick Koston
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add cached_property to State.name (#108011)
parent
7c848d78
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/template/template_entity.py
+7
-2
7 additions, 2 deletions
homeassistant/components/template/template_entity.py
homeassistant/core.py
+5
-3
5 additions, 3 deletions
homeassistant/core.py
with
12 additions
and
5 deletions
homeassistant/components/template/template_entity.py
+
7
−
2
View file @
1cdfb06d
...
...
@@ -5,7 +5,7 @@ from collections.abc import Callable, Mapping
import
contextlib
import
itertools
import
logging
from
typing
import
Any
from
typing
import
TYPE_CHECKING
,
Any
import
voluptuous
as
vol
...
...
@@ -56,6 +56,11 @@ from .const import (
CONF_PICTURE
,
)
if
TYPE_CHECKING
:
from
functools
import
cached_property
else
:
from
homeassistant.backports.functools
import
cached_property
_LOGGER
=
logging
.
getLogger
(
__name__
)
TEMPLATE_ENTITY_AVAILABILITY_SCHEMA
=
vol
.
Schema
(
...
...
@@ -294,7 +299,7 @@ class TemplateEntity(Entity):
super
().
__init__
(
"
unknown.unknown
"
,
STATE_UNKNOWN
)
self
.
entity_id
=
None
# type: ignore[assignment]
@property
@
cached_
property
def
name
(
self
)
->
str
:
"""
Name of this state.
"""
return
"
<None>
"
...
...
This diff is collapsed.
Click to expand it.
homeassistant/core.py
+
5
−
3
View file @
1cdfb06d
...
...
@@ -46,7 +46,6 @@ import voluptuous as vol
import
yarl
from
.
import
block_async_io
,
util
from
.backports.functools
import
cached_property
from
.const
import
(
ATTR_DOMAIN
,
ATTR_FRIENDLY_NAME
,
...
...
@@ -108,11 +107,14 @@ from .util.unit_system import (
# Typing imports that create a circular dependency
if
TYPE_CHECKING
:
from
functools
import
cached_property
from
.auth
import
AuthManager
from
.components.http
import
ApiConfig
,
HomeAssistantHTTP
from
.config_entries
import
ConfigEntries
from
.helpers.entity
import
StateInfo
else
:
from
.backports.functools
import
cached_property
STOPPING_STAGE_SHUTDOWN_TIMEOUT
=
20
STOP_STAGE_SHUTDOWN_TIMEOUT
=
100
...
...
@@ -1436,7 +1438,7 @@ class State:
self
.
state_info
=
state_info
self
.
domain
,
self
.
object_id
=
split_entity_id
(
self
.
entity_id
)
@property
@
cached_
property
def
name
(
self
)
->
str
:
"""
Name of this state.
"""
return
self
.
attributes
.
get
(
ATTR_FRIENDLY_NAME
)
or
self
.
object_id
.
replace
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment