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
df8c9498
Unverified
Commit
df8c9498
authored
8 months ago
by
J. Nick Koston
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Migrate esphome to use shorthand available attr (#121827)
parent
adb88f01
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/esphome/entity.py
+9
-13
9 additions, 13 deletions
homeassistant/components/esphome/entity.py
with
9 additions
and
13 deletions
homeassistant/components/esphome/entity.py
+
9
−
13
View file @
df8c9498
...
...
@@ -190,13 +190,13 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]):
)
->
None
:
"""
Initialize.
"""
self
.
_entry_data
=
entry_data
assert
entry_data
.
device_info
is
not
None
device_info
=
entry_data
.
device_info
self
.
_device_info
=
device_info
self
.
_on_entry_data_changed
()
self
.
_key
=
entity_info
.
key
self
.
_state_type
=
state_type
self
.
_on_static_info_update
(
entity_info
)
assert
entry_data
.
device_info
is
not
None
device_info
=
entry_data
.
device_info
self
.
_device_info
=
device_info
self
.
_attr_device_info
=
DeviceInfo
(
connections
=
{(
dr
.
CONNECTION_NETWORK_MAC
,
device_info
.
mac_address
)}
)
...
...
@@ -288,6 +288,12 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]):
entry_data
=
self
.
_entry_data
self
.
_api_version
=
entry_data
.
api_version
self
.
_client
=
entry_data
.
client
if
self
.
_device_info
.
has_deep_sleep
:
# During deep sleep the ESP will not be connectable (by design)
# For these cases, show it as available
self
.
_attr_available
=
entry_data
.
expected_disconnect
else
:
self
.
_attr_available
=
entry_data
.
available
@callback
def
_on_device_update
(
self
)
->
None
:
...
...
@@ -300,16 +306,6 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]):
# through the next entity state packet.
self
.
async_write_ha_state
()
@property
def
available
(
self
)
->
bool
:
"""
Return if the entity is available.
"""
if
self
.
_device_info
.
has_deep_sleep
:
# During deep sleep the ESP will not be connectable (by design)
# For these cases, show it as available
return
self
.
_entry_data
.
expected_disconnect
return
self
.
_entry_data
.
available
class
EsphomeAssistEntity
(
Entity
):
"""
Define a base entity for Assist Pipeline entities.
"""
...
...
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