Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accelerator sensor in fibaro integration #81237

Merged
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions homeassistant/components/fibaro/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,20 @@ def __init__(

def update(self) -> None:
"""Update the state."""
with suppress(KeyError, ValueError):
self._attr_native_value = float(self.fibaro_device.properties.value)
with suppress(KeyError):
raw_value = self.fibaro_device.properties.value

if raw_value is None:
return raw_value

try:
# most sensors provide a number (HC2 as string, HC3 as float or int value)
self._attr_native_value = float(raw_value)
except (TypeError, ValueError):
# some sensors like accelerator provides a complex value,
# e.g. a accelerator provides {"x": 0.0, "y": 0.0, "z": 0.0}
# (HC2 as string HC3 as structure which is converted to RecursiveDict by the fiblary)
self._attr_native_value = str(raw_value)
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved


class FibaroAdditionalSensor(FibaroDevice, SensorEntity):
Expand Down