Skip to content
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
13 changes: 6 additions & 7 deletions homeassistant/components/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Component to interface with binary sensors."""
from __future__ import annotations

from datetime import timedelta
import logging
Expand All @@ -12,6 +13,7 @@
)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import StateType

# mypy: allow-untyped-defs, no-check-untyped-defs

Expand Down Expand Up @@ -147,21 +149,18 @@ async def async_unload_entry(hass, entry):
class BinarySensorEntity(Entity):
"""Represent a binary sensor."""

_attr_is_on: bool | None = None

@property
def is_on(self):
def is_on(self) -> bool | None:
"""Return true if the binary sensor is on."""
return None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_attr_is_on is not used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well spotted, opening a fix for that 👍 (after CI has been fixed)


@property
def state(self):
def state(self) -> StateType:
"""Return the state of the binary sensor."""
return STATE_ON if self.is_on else STATE_OFF

@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return None


class BinarySensorDevice(BinarySensorEntity):
"""Represent a binary sensor (for backwards compatibility)."""
Expand Down