mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Use device class for DLink (#96567)
This commit is contained in:
parent
cb1f365482
commit
0ca4da5592
@ -17,7 +17,6 @@ SCAN_INTERVAL = timedelta(minutes=2)
|
|||||||
|
|
||||||
SWITCH_TYPE = SwitchEntityDescription(
|
SWITCH_TYPE = SwitchEntityDescription(
|
||||||
key="switch",
|
key="switch",
|
||||||
name="Switch",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +33,8 @@ async def async_setup_entry(
|
|||||||
class SmartPlugSwitch(DLinkEntity, SwitchEntity):
|
class SmartPlugSwitch(DLinkEntity, SwitchEntity):
|
||||||
"""Representation of a D-Link Smart Plug switch."""
|
"""Representation of a D-Link Smart Plug switch."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
|
@ -28,7 +28,7 @@ async def test_switch_state(hass: HomeAssistant, mocked_plug: AsyncMock) -> None
|
|||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
entity_id = "switch.mock_title_switch"
|
entity_id = "switch.mock_title"
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert state.attributes["total_consumption"] == 1040.0
|
assert state.attributes["total_consumption"] == 1040.0
|
||||||
@ -62,7 +62,7 @@ async def test_switch_no_value(
|
|||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get("switch.mock_title_switch")
|
state = hass.states.get("switch.mock_title")
|
||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert state.attributes["total_consumption"] is None
|
assert state.attributes["total_consumption"] is None
|
||||||
assert state.attributes["temperature"] is None
|
assert state.attributes["temperature"] is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user