Skip to content

fix: return 0 instead of None from target_temperature when oven is off#478

Open
cdccentral-sourcecontrol wants to merge 1 commit intosimbaja:masterfrom
cdccentral-sourcecontrol:fix/oven-target-temperature-none
Open

fix: return 0 instead of None from target_temperature when oven is off#478
cdccentral-sourcecontrol wants to merge 1 commit intosimbaja:masterfrom
cdccentral-sourcecontrol:fix/oven-target-temperature-none

Conversation

@cdccentral-sourcecontrol
Copy link
Copy Markdown

Problem

When the oven is off, GeOven.target_temperature returns None because cook_mode.temperature is 0 (falsy).

Google Assistant's report_state.pyinitial_report iterates all entities exposed to Google and calls entity.query_serialize()trait.query_attributes()float(target_temp). When target_temp is None, this raises:

TypeError: float() argument must be a string or a real number, not 'NoneType'

at homeassistant/components/google_assistant/trait.py:1112.

The initial_report try/except only catches SmartHomeError, not TypeError, 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 0 instead of None when the oven has no active target temperature. This is semantically correct (the oven isn't targeting any temperature) and safe for all consumers since float(0) works fine.

One-line change

# Before
    if cook_mode.temperature:
        return cook_mode.temperature
    return None

# After
    if cook_mode.temperature:
        return cook_mode.temperature
    return 0

Testing

  • Verified on HAOS 2026.3.3 with GE Profile oven (dual cavity, upper + lower)
  • Both water_heater.upper_oven and water_heater.lower_oven now report temperature: 0 when off
  • Zero TypeError / report_state errors in HA logs after restart
  • Google Assistant state reporting works correctly for all entities

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.
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