Skip to content

Commit

Permalink
suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4nt0r committed Nov 30, 2024
1 parent 5ecec68 commit 43a39a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
15 changes: 5 additions & 10 deletions homeassistant/components/iron_os/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import IronOSConfigEntry
from .coordinator import IronOSLiveDataCoordinator
from .entity import IronOSBaseEntity


Expand All @@ -31,21 +30,17 @@ async def async_setup_entry(
"""Set up binary sensors from a config entry."""
coordinator = entry.runtime_data

async_add_entities([IronOSBinarySensorEntity(coordinator)])


class IronOSBinarySensorEntity(IronOSBaseEntity, BinarySensorEntity):
"""Representation of a IronOS binary sensor entity."""

entity_description = BinarySensorEntityDescription(
key=PinecilBinarySensor.TIP_CONNECTED,
translation_key=PinecilBinarySensor.TIP_CONNECTED,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
)

def __init__(self, coordinator: IronOSLiveDataCoordinator) -> None:
"""Initialize the entity."""
super().__init__(coordinator, self.entity_description)
async_add_entities([IronOSBinarySensorEntity(coordinator, entity_description)])


class IronOSBinarySensorEntity(IronOSBaseEntity, BinarySensorEntity):
"""Representation of a IronOS binary sensor entity."""

@property
def is_on(self) -> bool | None:
Expand Down
4 changes: 2 additions & 2 deletions tests/components/iron_os/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# serializer version: 1
# name: test_sensors[binary_sensor.pinecil_soldering_tip-entry]
# name: test_binary_sensors[binary_sensor.pinecil_soldering_tip-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
Expand Down Expand Up @@ -32,7 +32,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_sensors[binary_sensor.pinecil_soldering_tip-state]
# name: test_binary_sensors[binary_sensor.pinecil_soldering_tip-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'connectivity',
Expand Down
2 changes: 1 addition & 1 deletion tests/components/iron_os/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def binary_sensor_only() -> AsyncGenerator[None]:
@pytest.mark.usefixtures(
"entity_registry_enabled_by_default", "mock_pynecil", "ble_device"
)
async def test_sensors(
async def test_binary_sensors(
hass: HomeAssistant,
config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
Expand Down

0 comments on commit 43a39a0

Please sign in to comment.