Skip to content

fix: add None guards for device_stats access in sensor lambdas - #284

Open
ahaghshenas wants to merge 2 commits into
Jezza34000:mainfrom
ahaghshenas:fix/device-stats-none-check
Open

fix: add None guards for device_stats access in sensor lambdas#284
ahaghshenas wants to merge 2 commits into
Jezza34000:mainfrom
ahaghshenas:fix/device-stats-none-check

Conversation

@ahaghshenas

Copy link
Copy Markdown

Problem

Sensors crash with AttributeError: 'NoneType' object has no attribute 'statistic_info' when device.device_stats is None.

This affects T3/T4 devices where device_stats may not be populated, causing errors in the log and broken sensor entities.

Fix

Added None guards to all lambdas that access device.device_stats:

  • device.device_stats.times
  • device.device_stats.total_time
  • device.device_stats.avg_time
  • device.device_stats.statistic_info

All now return None when device_stats is not available, instead of crashing.

device_stats can be None for some devices, causing AttributeError
when accessing .statistic_info, .times, .total_time, and .avg_time.

Added None checks to all lambdas that access device.device_stats
to prevent crashes when device_stats is not populated.
@ahaghshenas
ahaghshenas requested a review from Jezza34000 as a code owner July 27, 2026 13:50
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant