Skip to content

Commit

Permalink
Adapt to recent development
Browse files Browse the repository at this point in the history
  • Loading branch information
Shutgun committed May 6, 2023
1 parent 318b67b commit 4e4426c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/devolo_home_network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
@callback
def platforms(device: Device) -> set[Platform]:
"""Assemble supported platforms."""
supported_platforms = {Platform.SENSOR, Platform.SWITCH}
supported_platforms = {Platform.BUTTON, Platform.SENSOR, Platform.SWITCH}
if device.plcnet:
supported_platforms.add(Platform.BINARY_SENSOR)
if device.device and "wifi1" in device.device.features:
Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/devolo_home_network/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,22 @@ class DevoloButtonEntityDescription(
key=IDENTIFY,
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:led-on",
name="Identify device with a blinking LED",
press_func=lambda device: device.plcnet.async_identify_device_start(), # type: ignore[union-attr]
),
PAIRING: DevoloButtonEntityDescription(
key=PAIRING,
icon="mdi:plus-network-outline",
name="Start PLC pairing",
press_func=lambda device: device.plcnet.async_pair_device(), # type: ignore[union-attr]
),
RESTART: DevoloButtonEntityDescription(
key=RESTART,
device_class=ButtonDeviceClass.RESTART,
entity_category=EntityCategory.CONFIG,
name="Restart device",
press_func=lambda device: device.device.async_restart(), # type: ignore[union-attr]
),
START_WPS: DevoloButtonEntityDescription(
key=START_WPS,
icon="mdi:wifi-plus",
name="Start WPS",
press_func=lambda device: device.device.async_start_wps(), # type: ignore[union-attr]
),
}
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/devolo_home_network/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
name=entry.title,
sw_version=device.firmware_version,
)
self._attr_translation_key = self.entity_description.key
self._attr_unique_id = f"{device.serial_number}_{self.entity_description.key}"


Expand Down
14 changes: 14 additions & 0 deletions homeassistant/components/devolo_home_network/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
"name": "Connected to router"
}
},
"button": {
"identify": {
"name": "Identify device with a blinking LED"
},
"pairing": {
"name": "Start PLC pairing"
},
"restart": {
"name": "Restart device"
},
"start_wps": {
"name": "Start WPS"
}
},
"sensor": {
"connected_plc_devices": {
"name": "Connected PLC devices"
Expand Down
9 changes: 5 additions & 4 deletions tests/components/devolo_home_network/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR
from homeassistant.components.button import DOMAIN as BUTTON
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER
from homeassistant.components.devolo_home_network.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR
Expand Down Expand Up @@ -83,17 +84,17 @@ async def test_hass_stop(hass: HomeAssistant, mock_device: MockDevice) -> None:
@pytest.mark.parametrize(
("device", "expected_platforms"),
[
["mock_device", (BINARY_SENSOR, DEVICE_TRACKER, SENSOR, SWITCH)],
["mock_repeater_device", (DEVICE_TRACKER, SENSOR, SWITCH)],
["mock_nonwifi_device", (BINARY_SENSOR, SENSOR, SWITCH)],
["mock_device", (BINARY_SENSOR, BUTTON, DEVICE_TRACKER, SENSOR, SWITCH)],
["mock_repeater_device", (BUTTON, DEVICE_TRACKER, SENSOR, SWITCH)],
["mock_nonwifi_device", (BINARY_SENSOR, BUTTON, SENSOR, SWITCH)],
],
)
async def test_platforms(
hass: HomeAssistant,
device: str,
expected_platforms: set[str],
request: pytest.FixtureRequest,
):
) -> None:
"""Test platform assembly."""
request.getfixturevalue(device)
entry = configure_integration(hass)
Expand Down

0 comments on commit 4e4426c

Please sign in to comment.