diff --git a/homeassistant/components/pyload/sensor.py b/homeassistant/components/pyload/sensor.py index 6cb432e12fd..83585a60c6d 100644 --- a/homeassistant/components/pyload/sensor.py +++ b/homeassistant/components/pyload/sensor.py @@ -181,7 +181,7 @@ class PyLoadSensor(CoordinatorEntity[PyLoadCoordinator], SensorEntity): f"{coordinator.config_entry.entry_id}_{entity_description.key}" ) self.entity_description = entity_description - self.device_info = DeviceInfo( + self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, manufacturer=MANUFACTURER, model=SERVICE_NAME, diff --git a/homeassistant/components/pyload/switch.py b/homeassistant/components/pyload/switch.py index b9391ef818f..b0628005008 100644 --- a/homeassistant/components/pyload/switch.py +++ b/homeassistant/components/pyload/switch.py @@ -24,7 +24,7 @@ from .const import DOMAIN, MANUFACTURER, SERVICE_NAME from .coordinator import PyLoadCoordinator -class PyLoadSwitchEntity(StrEnum): +class PyLoadSwitch(StrEnum): """PyLoad Switch Entities.""" PAUSE_RESUME_QUEUE = "download" @@ -42,16 +42,16 @@ class PyLoadSwitchEntityDescription(SwitchEntityDescription): SENSOR_DESCRIPTIONS: tuple[PyLoadSwitchEntityDescription, ...] = ( PyLoadSwitchEntityDescription( - key=PyLoadSwitchEntity.PAUSE_RESUME_QUEUE, - translation_key=PyLoadSwitchEntity.PAUSE_RESUME_QUEUE, + key=PyLoadSwitch.PAUSE_RESUME_QUEUE, + translation_key=PyLoadSwitch.PAUSE_RESUME_QUEUE, device_class=SwitchDeviceClass.SWITCH, turn_on_fn=lambda api: api.unpause(), turn_off_fn=lambda api: api.pause(), toggle_fn=lambda api: api.toggle_pause(), ), PyLoadSwitchEntityDescription( - key=PyLoadSwitchEntity.RECONNECT, - translation_key=PyLoadSwitchEntity.RECONNECT, + key=PyLoadSwitch.RECONNECT, + translation_key=PyLoadSwitch.RECONNECT, device_class=SwitchDeviceClass.SWITCH, turn_on_fn=lambda api: api.toggle_reconnect(), turn_off_fn=lambda api: api.toggle_reconnect(), @@ -70,12 +70,12 @@ async def async_setup_entry( coordinator = entry.runtime_data async_add_entities( - PyLoadBinarySensor(coordinator, description) + PyLoadSwitchEntity(coordinator, description) for description in SENSOR_DESCRIPTIONS ) -class PyLoadBinarySensor(CoordinatorEntity[PyLoadCoordinator], SwitchEntity): +class PyLoadSwitchEntity(CoordinatorEntity[PyLoadCoordinator], SwitchEntity): """Representation of a pyLoad sensor.""" _attr_has_entity_name = True diff --git a/tests/components/pyload/snapshots/test_switch.ambr b/tests/components/pyload/snapshots/test_switch.ambr index 94f2910cad8..b6465341b0a 100644 --- a/tests/components/pyload/snapshots/test_switch.ambr +++ b/tests/components/pyload/snapshots/test_switch.ambr @@ -27,7 +27,7 @@ 'platform': 'pyload', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': , + 'translation_key': , 'unique_id': 'XXXXXXXXXXXXXX_reconnect', 'unit_of_measurement': None, }) @@ -74,7 +74,7 @@ 'platform': 'pyload', 'previous_unique_id': None, 'supported_features': 0, - 'translation_key': , + 'translation_key': , 'unique_id': 'XXXXXXXXXXXXXX_download', 'unit_of_measurement': None, }) diff --git a/tests/components/pyload/test_switch.py b/tests/components/pyload/test_switch.py index e7bd5a24a87..42a6bfa6f14 100644 --- a/tests/components/pyload/test_switch.py +++ b/tests/components/pyload/test_switch.py @@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, call, patch import pytest from syrupy.assertion import SnapshotAssertion -from homeassistant.components.pyload.switch import PyLoadSwitchEntity +from homeassistant.components.pyload.switch import PyLoadSwitch from homeassistant.components.switch import ( DOMAIN as SWITCH_DOMAIN, SERVICE_TOGGLE, @@ -22,12 +22,12 @@ from tests.common import MockConfigEntry, snapshot_platform # Maps entity to the mock calls to assert API_CALL = { - PyLoadSwitchEntity.PAUSE_RESUME_QUEUE: { + PyLoadSwitch.PAUSE_RESUME_QUEUE: { SERVICE_TURN_ON: call.unpause, SERVICE_TURN_OFF: call.pause, SERVICE_TOGGLE: call.toggle_pause, }, - PyLoadSwitchEntity.RECONNECT: { + PyLoadSwitch.RECONNECT: { SERVICE_TURN_ON: call.toggle_reconnect, SERVICE_TURN_OFF: call.toggle_reconnect, SERVICE_TOGGLE: call.toggle_reconnect, @@ -97,7 +97,6 @@ async def test_turn_on_off( {ATTR_ENTITY_ID: entity_entry.entity_id}, blocking=True, ) - await hass.async_block_till_done() assert ( API_CALL[entity_entry.translation_key][service_call] in mock_pyloadapi.method_calls