mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Use a listcomp for history results (#119188)
This commit is contained in:
parent
38ab121db5
commit
909df675e0
@ -782,24 +782,30 @@ def _sorted_states_to_dict(
|
|||||||
if compressed_state_format:
|
if compressed_state_format:
|
||||||
# Compressed state format uses the timestamp directly
|
# Compressed state format uses the timestamp directly
|
||||||
ent_results.extend(
|
ent_results.extend(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
attr_state: (prev_state := state),
|
attr_state: (prev_state := state),
|
||||||
attr_time: row[last_updated_ts_idx],
|
attr_time: row[last_updated_ts_idx],
|
||||||
}
|
}
|
||||||
for row in group
|
for row in group
|
||||||
if (state := row[state_idx]) != prev_state
|
if (state := row[state_idx]) != prev_state
|
||||||
|
]
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Non-compressed state format returns an ISO formatted string
|
# Non-compressed state format returns an ISO formatted string
|
||||||
_utc_from_timestamp = dt_util.utc_from_timestamp
|
_utc_from_timestamp = dt_util.utc_from_timestamp
|
||||||
ent_results.extend(
|
ent_results.extend(
|
||||||
|
[
|
||||||
{
|
{
|
||||||
attr_state: (prev_state := state),
|
attr_state: (prev_state := state),
|
||||||
attr_time: _utc_from_timestamp(row[last_updated_ts_idx]).isoformat(),
|
attr_time: _utc_from_timestamp(
|
||||||
|
row[last_updated_ts_idx]
|
||||||
|
).isoformat(),
|
||||||
}
|
}
|
||||||
for row in group
|
for row in group
|
||||||
if (state := row[state_idx]) != prev_state
|
if (state := row[state_idx]) != prev_state
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if descending:
|
if descending:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user