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 TypeError if power value is None from moonraker #349

Merged
merged 2 commits into from
May 31, 2024
Merged
Changes from all commits
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
10 changes: 8 additions & 2 deletions custom_components/moonraker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ async def async_setup_optional_sensors(coordinator, entry, async_add_entities):
status_key=obj,
name=f"{split_obj[1].replace('_', ' ')} Power".title(),
value_fn=lambda sensor: int(
sensor.coordinator.data["status"][sensor.status_key]["power"] * 100
(
sensor.coordinator.data["status"][sensor.status_key]["power"]
or 0.0
) * 100
),
subscriptions=[(obj, "power")],
icon="mdi:flash",
Expand Down Expand Up @@ -502,7 +505,10 @@ async def async_setup_optional_sensors(coordinator, entry, async_add_entities):
status_key=obj,
name=f"{base_name} Power".title(),
value_fn=lambda sensor: int(
sensor.coordinator.data["status"][sensor.status_key]["power"] * 100
(
sensor.coordinator.data["status"][sensor.status_key]["power"]
or 0.0
) * 100
),
subscriptions=[(obj, "power")],
icon="mdi:flash",
Expand Down
Loading