From 4f3d8a5e1f43698ec3abfbd618dd55c3825b96a6 Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Sat, 30 Nov 2024 20:24:50 +0000 Subject: [PATCH] suggested changes --- homeassistant/components/iron_os/binary_sensor.py | 15 +++++---------- .../iron_os/snapshots/test_binary_sensor.ambr | 4 ++-- tests/components/iron_os/test_binary_sensor.py | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/iron_os/binary_sensor.py b/homeassistant/components/iron_os/binary_sensor.py index 4ef6ed7c02fd9..19e21895881f5 100644 --- a/homeassistant/components/iron_os/binary_sensor.py +++ b/homeassistant/components/iron_os/binary_sensor.py @@ -13,7 +13,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import IronOSConfigEntry -from .coordinator import IronOSLiveDataCoordinator from .entity import IronOSBaseEntity @@ -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: diff --git a/tests/components/iron_os/snapshots/test_binary_sensor.ambr b/tests/components/iron_os/snapshots/test_binary_sensor.ambr index bcad4ec8c3092..17b49c1d687ee 100644 --- a/tests/components/iron_os/snapshots/test_binary_sensor.ambr +++ b/tests/components/iron_os/snapshots/test_binary_sensor.ambr @@ -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({ }), @@ -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', diff --git a/tests/components/iron_os/test_binary_sensor.py b/tests/components/iron_os/test_binary_sensor.py index f2e1451ee761b..37776f1cbd765 100644 --- a/tests/components/iron_os/test_binary_sensor.py +++ b/tests/components/iron_os/test_binary_sensor.py @@ -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,