mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix class and variable naming errors in pyLoad integration (#120547)
This commit is contained in:
parent
13a9efb6a6
commit
972b85a75b
@ -181,7 +181,7 @@ class PyLoadSensor(CoordinatorEntity[PyLoadCoordinator], SensorEntity):
|
|||||||
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
||||||
)
|
)
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self.device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
entry_type=DeviceEntryType.SERVICE,
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=SERVICE_NAME,
|
model=SERVICE_NAME,
|
||||||
|
@ -24,7 +24,7 @@ from .const import DOMAIN, MANUFACTURER, SERVICE_NAME
|
|||||||
from .coordinator import PyLoadCoordinator
|
from .coordinator import PyLoadCoordinator
|
||||||
|
|
||||||
|
|
||||||
class PyLoadSwitchEntity(StrEnum):
|
class PyLoadSwitch(StrEnum):
|
||||||
"""PyLoad Switch Entities."""
|
"""PyLoad Switch Entities."""
|
||||||
|
|
||||||
PAUSE_RESUME_QUEUE = "download"
|
PAUSE_RESUME_QUEUE = "download"
|
||||||
@ -42,16 +42,16 @@ class PyLoadSwitchEntityDescription(SwitchEntityDescription):
|
|||||||
|
|
||||||
SENSOR_DESCRIPTIONS: tuple[PyLoadSwitchEntityDescription, ...] = (
|
SENSOR_DESCRIPTIONS: tuple[PyLoadSwitchEntityDescription, ...] = (
|
||||||
PyLoadSwitchEntityDescription(
|
PyLoadSwitchEntityDescription(
|
||||||
key=PyLoadSwitchEntity.PAUSE_RESUME_QUEUE,
|
key=PyLoadSwitch.PAUSE_RESUME_QUEUE,
|
||||||
translation_key=PyLoadSwitchEntity.PAUSE_RESUME_QUEUE,
|
translation_key=PyLoadSwitch.PAUSE_RESUME_QUEUE,
|
||||||
device_class=SwitchDeviceClass.SWITCH,
|
device_class=SwitchDeviceClass.SWITCH,
|
||||||
turn_on_fn=lambda api: api.unpause(),
|
turn_on_fn=lambda api: api.unpause(),
|
||||||
turn_off_fn=lambda api: api.pause(),
|
turn_off_fn=lambda api: api.pause(),
|
||||||
toggle_fn=lambda api: api.toggle_pause(),
|
toggle_fn=lambda api: api.toggle_pause(),
|
||||||
),
|
),
|
||||||
PyLoadSwitchEntityDescription(
|
PyLoadSwitchEntityDescription(
|
||||||
key=PyLoadSwitchEntity.RECONNECT,
|
key=PyLoadSwitch.RECONNECT,
|
||||||
translation_key=PyLoadSwitchEntity.RECONNECT,
|
translation_key=PyLoadSwitch.RECONNECT,
|
||||||
device_class=SwitchDeviceClass.SWITCH,
|
device_class=SwitchDeviceClass.SWITCH,
|
||||||
turn_on_fn=lambda api: api.toggle_reconnect(),
|
turn_on_fn=lambda api: api.toggle_reconnect(),
|
||||||
turn_off_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
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
PyLoadBinarySensor(coordinator, description)
|
PyLoadSwitchEntity(coordinator, description)
|
||||||
for description in SENSOR_DESCRIPTIONS
|
for description in SENSOR_DESCRIPTIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PyLoadBinarySensor(CoordinatorEntity[PyLoadCoordinator], SwitchEntity):
|
class PyLoadSwitchEntity(CoordinatorEntity[PyLoadCoordinator], SwitchEntity):
|
||||||
"""Representation of a pyLoad sensor."""
|
"""Representation of a pyLoad sensor."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': <PyLoadSwitchEntity.RECONNECT: 'reconnect'>,
|
'translation_key': <PyLoadSwitch.RECONNECT: 'reconnect'>,
|
||||||
'unique_id': 'XXXXXXXXXXXXXX_reconnect',
|
'unique_id': 'XXXXXXXXXXXXXX_reconnect',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -74,7 +74,7 @@
|
|||||||
'platform': 'pyload',
|
'platform': 'pyload',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': <PyLoadSwitchEntity.PAUSE_RESUME_QUEUE: 'download'>,
|
'translation_key': <PyLoadSwitch.PAUSE_RESUME_QUEUE: 'download'>,
|
||||||
'unique_id': 'XXXXXXXXXXXXXX_download',
|
'unique_id': 'XXXXXXXXXXXXXX_download',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, call, patch
|
|||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.pyload.switch import PyLoadSwitchEntity
|
from homeassistant.components.pyload.switch import PyLoadSwitch
|
||||||
from homeassistant.components.switch import (
|
from homeassistant.components.switch import (
|
||||||
DOMAIN as SWITCH_DOMAIN,
|
DOMAIN as SWITCH_DOMAIN,
|
||||||
SERVICE_TOGGLE,
|
SERVICE_TOGGLE,
|
||||||
@ -22,12 +22,12 @@ from tests.common import MockConfigEntry, snapshot_platform
|
|||||||
|
|
||||||
# Maps entity to the mock calls to assert
|
# Maps entity to the mock calls to assert
|
||||||
API_CALL = {
|
API_CALL = {
|
||||||
PyLoadSwitchEntity.PAUSE_RESUME_QUEUE: {
|
PyLoadSwitch.PAUSE_RESUME_QUEUE: {
|
||||||
SERVICE_TURN_ON: call.unpause,
|
SERVICE_TURN_ON: call.unpause,
|
||||||
SERVICE_TURN_OFF: call.pause,
|
SERVICE_TURN_OFF: call.pause,
|
||||||
SERVICE_TOGGLE: call.toggle_pause,
|
SERVICE_TOGGLE: call.toggle_pause,
|
||||||
},
|
},
|
||||||
PyLoadSwitchEntity.RECONNECT: {
|
PyLoadSwitch.RECONNECT: {
|
||||||
SERVICE_TURN_ON: call.toggle_reconnect,
|
SERVICE_TURN_ON: call.toggle_reconnect,
|
||||||
SERVICE_TURN_OFF: call.toggle_reconnect,
|
SERVICE_TURN_OFF: call.toggle_reconnect,
|
||||||
SERVICE_TOGGLE: 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},
|
{ATTR_ENTITY_ID: entity_entry.entity_id},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
|
||||||
assert (
|
assert (
|
||||||
API_CALL[entity_entry.translation_key][service_call]
|
API_CALL[entity_entry.translation_key][service_call]
|
||||||
in mock_pyloadapi.method_calls
|
in mock_pyloadapi.method_calls
|
||||||
|
Loading…
x
Reference in New Issue
Block a user