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
902d76da
Unverified
Commit
902d76da
authored
7 months ago
by
J. Nick Koston
Committed by
GitHub
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Small cleanup to normalize states (#124614)
- Remove duplicate state_unit lookup - Use undefined instead of object
parent
d8161c43
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/sensor/recorder.py
+3
-2
3 additions, 2 deletions
homeassistant/components/sensor/recorder.py
with
3 additions
and
2 deletions
homeassistant/components/sensor/recorder.py
+
3
−
2
View file @
902d76da
...
@@ -33,6 +33,7 @@ from homeassistant.const import (
...
@@ -33,6 +33,7 @@ from homeassistant.const import (
from
homeassistant.core
import
HomeAssistant
,
State
,
split_entity_id
from
homeassistant.core
import
HomeAssistant
,
State
,
split_entity_id
from
homeassistant.exceptions
import
HomeAssistantError
from
homeassistant.exceptions
import
HomeAssistantError
from
homeassistant.helpers.entity
import
entity_sources
from
homeassistant.helpers.entity
import
entity_sources
from
homeassistant.helpers.typing
import
UNDEFINED
,
UndefinedType
from
homeassistant.loader
import
async_suggest_report_issue
from
homeassistant.loader
import
async_suggest_report_issue
from
homeassistant.util
import
dt
as
dt_util
from
homeassistant.util
import
dt
as
dt_util
from
homeassistant.util.enum
import
try_parse_enum
from
homeassistant.util.enum
import
try_parse_enum
...
@@ -220,13 +221,13 @@ def _normalize_states(
...
@@ -220,13 +221,13 @@ def _normalize_states(
LINK_DEV_STATISTICS
,
LINK_DEV_STATISTICS
,
)
)
return
None
,
[]
return
None
,
[]
state_unit
=
fstates
[
0
][
1
].
attributes
.
get
(
ATTR_UNIT_OF_MEASUREMENT
)
return
state_unit
,
fstates
return
state_unit
,
fstates
converter
=
statistics
.
STATISTIC_UNIT_TO_UNIT_CONVERTER
[
statistics_unit
]
converter
=
statistics
.
STATISTIC_UNIT_TO_UNIT_CONVERTER
[
statistics_unit
]
valid_fstates
:
list
[
tuple
[
float
,
State
]]
=
[]
valid_fstates
:
list
[
tuple
[
float
,
State
]]
=
[]
convert
:
Callable
[[
float
],
float
]
|
None
=
None
convert
:
Callable
[[
float
],
float
]
|
None
=
None
last_unit
:
str
|
None
|
object
=
object
()
last_unit
:
str
|
None
|
UndefinedType
=
UNDEFINED
valid_units
=
converter
.
VALID_UNITS
valid_units
=
converter
.
VALID_UNITS
for
fstate
,
state
in
fstates
:
for
fstate
,
state
in
fstates
:
...
...
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