Skip to content

Commit

Permalink
Revert/forward as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
CoMPaTech committed May 21, 2023
1 parent b55a452 commit 23ed31f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions homeassistant/components/plugwise/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from typing import Any

from plugwise import DeviceData
from plugwise import SmileBinarySensors

from homeassistant.components.binary_sensor import (
BinarySensorEntity,
Expand All @@ -27,7 +27,7 @@
class PlugwiseBinarySensorMixin:
"""Mixin for required Plugwise binary sensor base description keys."""

value_fn: Callable[[DeviceData], bool]
value_fn: Callable[[SmileBinarySensors], bool]


@dataclass
Expand All @@ -46,22 +46,22 @@ class PlugwiseBinarySensorEntityDescription(
icon="mdi:hvac",
icon_off="mdi:hvac-off",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["compressor_state"],
value_fn=lambda data: data["compressor_state"],
),
PlugwiseBinarySensorEntityDescription(
key="cooling_enabled",
translation_key="cooling_enabled",
icon="mdi:snowflake-thermometer",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["cooling_enabled"],
value_fn=lambda data: data["cooling_enabled"],
),
PlugwiseBinarySensorEntityDescription(
key="dhw_state",
translation_key="dhw_state",
icon="mdi:water-pump",
icon_off="mdi:water-pump-off",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["dhw_state"],
value_fn=lambda data: data["dhw_state"],
),
PlugwiseBinarySensorEntityDescription(
key="flame_state",
Expand All @@ -70,39 +70,39 @@ class PlugwiseBinarySensorEntityDescription(
icon="mdi:fire",
icon_off="mdi:fire-off",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["flame_state"],
value_fn=lambda data: data["flame_state"],
),
PlugwiseBinarySensorEntityDescription(
key="heating_state",
translation_key="heating_state",
icon="mdi:radiator",
icon_off="mdi:radiator-off",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["heating_state"],
value_fn=lambda data: data["heating_state"],
),
PlugwiseBinarySensorEntityDescription(
key="cooling_state",
translation_key="cooling_state",
icon="mdi:snowflake",
icon_off="mdi:snowflake-off",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["cooling_state"],
value_fn=lambda data: data["cooling_state"],
),
PlugwiseBinarySensorEntityDescription(
key="slave_boiler_state",
translation_key="slave_boiler_state",
icon="mdi:fire",
icon_off="mdi:circle-off-outline",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["slave_boiler_state"],
value_fn=lambda data: data["slave_boiler_state"],
),
PlugwiseBinarySensorEntityDescription(
key="plugwise_notification",
translation_key="plugwise_notification",
icon="mdi:mailbox-up-outline",
icon_off="mdi:mailbox-outline",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data["binary_sensors"]["plugwise_notification"],
value_fn=lambda data: data["plugwise_notification"],
),
)

Expand All @@ -119,10 +119,10 @@ async def async_setup_entry(

entities: list[PlugwiseBinarySensorEntity] = []
for device_id, device in coordinator.data.devices.items():
if "binary_sensors" not in device:
if not (binary_sensors := device.get("binary_sensors")):
continue
for description in BINARY_SENSORS:
if description.key not in device["binary_sensors"]:
if description.key not in binary_sensors:
continue

entities.append(
Expand Down Expand Up @@ -154,7 +154,7 @@ def __init__(
@property
def is_on(self) -> bool | None:
"""Return true if the binary sensor is on."""
return self.entity_description.value_fn(self.device)
return self.entity_description.value_fn(self.device["binary_sensors"])

@property
def icon(self) -> str | None:
Expand Down

0 comments on commit 23ed31f

Please sign in to comment.