fix: return 0 instead of None from target_temperature when oven is off#478
Open
cdccentral-sourcecontrol wants to merge 1 commit intosimbaja:masterfrom
Open
Conversation
When the oven is off, cook_mode.temperature is 0/falsy, causing target_temperature to return None. Google Assistant's report_state calls float(target_temp) on this value, which raises: TypeError: float() argument must be a string or a real number, not 'NoneType' This crashes the initial_report task on every HA startup, blocking Google Assistant state reporting for all entities. Returning 0 instead of None is safe — it accurately represents "no target temperature" and prevents the TypeError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the oven is off,
GeOven.target_temperaturereturnsNonebecausecook_mode.temperatureis0(falsy).Google Assistant's
report_state.py→initial_reportiterates all entities exposed to Google and callsentity.query_serialize()→trait.query_attributes()→float(target_temp). Whentarget_tempisNone, this raises:at
homeassistant/components/google_assistant/trait.py:1112.The
initial_reporttry/except only catchesSmartHomeError, notTypeError, so this unhandled exception crashes the entire initial report task on every HA startup, blocking Google Assistant state reporting for all entities — not just the oven.Fix
Return
0instead ofNonewhen the oven has no active target temperature. This is semantically correct (the oven isn't targeting any temperature) and safe for all consumers sincefloat(0)works fine.One-line change
Testing
water_heater.upper_ovenandwater_heater.lower_ovennow reporttemperature: 0when offTypeError/report_stateerrors in HA logs after restart