Skip to content

Hotfix/Safeguards for device number properties - #184

Merged
jjjonesjr33 merged 1 commit into
jjjonesjr33:devfrom
FeliGoblin:hotfix/device-number-properties-safeguards
Nov 30, 2025
Merged

Hotfix/Safeguards for device number properties#184
jjjonesjr33 merged 1 commit into
jjjonesjr33:devfrom
FeliGoblin:hotfix/device-number-properties-safeguards

Conversation

@FeliGoblin

Copy link
Copy Markdown
Contributor

Proposed change:

User was getting a TypeError when VolumeConverter was trying to convert value None

  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 131, in <lambda>
    return lambda val: (val / from_ratio) * to_ratio
                        ~~~~^~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

The change adds a safeguard to a bunch of device properties that should return numbers. Before, they only checked if the value exists, now it checks that it's a number.

For example:

    @property
    def today_feeding_quantity(self) -> int:
        return self._data.get("grainStatus", {}).get("todayFeedingQuantity", 0)

becomes:

    @property
    def today_feeding_quantity(self) -> float:
        quantity = self._data.get("grainStatus", {}).get("todayFeedingQuantity")
        return quantity if isinstance(quantity, (int, float)) else 0

Closes #183 (issue)

Type of change:

  • New device.
  • Bug fix (non-breaking change which fixes an issue).
  • New feature or enhancement (non-breaking change which adds functionality).
  • Documentation only.
  • Other (please explain).

Checklist:

  • If applicable, I have added corresponding documentation changes.
  • If applicable, I have reviewed the feature / enhancement guidlines before submitting my request.
  • If applicable, I have tested my code for new features & regressions on the latest version of Home Assistant.

Additional notes:

@jjjonesjr33 jjjonesjr33 added the Hot Fix An update that fixes a issue in an application without causing system downtime label Nov 30, 2025
@github-project-automation github-project-automation Bot moved this to To triage in Petlibro Nov 30, 2025
@jjjonesjr33 jjjonesjr33 added this to the [Bugs]: General Issues milestone Nov 30, 2025

@jjjonesjr33 jjjonesjr33 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good, nice hot fix @FeliGoblin

@github-project-automation github-project-automation Bot moved this from To triage to In review in Petlibro Nov 30, 2025
@jjjonesjr33
jjjonesjr33 merged commit b9130ff into jjjonesjr33:dev Nov 30, 2025
2 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Petlibro Nov 30, 2025
@jjjonesjr33 jjjonesjr33 added the Completed Completed tasks label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Completed Completed tasks Hot Fix An update that fixes a issue in an application without causing system downtime

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Error doing job: Task exception was never retrieved (None)

2 participants