Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/predbat/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def update_entity(self, entity_id, new_history_data):

# Filter useless data from history data
for entry in new_history_data:
if "attributes" in entry:
if entry.get("attributes"):

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from if \"attributes\" in entry: to if entry.get(\"attributes\"): alters the behavior. The original check verified the key's existence, while .get() returns the value and evaluates its truthiness. This means an empty dictionary {\"attributes\": {}} would be skipped with the new code but processed with the old code, preventing the filtering loop from executing when it should. Use if \"attributes\" in entry: to maintain the original behavior, or use if entry.get(\"attributes\") is not None: if you want to explicitly handle None values.

Suggested change
if entry.get("attributes"):
if "attributes" in entry:

Copilot uses AI. Check for mistakes.
for attr in FILTER_ATTRIBUTES:
entry["attributes"].pop(attr, None)
for entry_attr in FILTER_ENTRIES:
Expand Down
Loading