Add button device classes to NAM (#60621)

This commit is contained in:
Franck Nijhof 2021-12-01 07:08:17 +01:00 committed by GitHub
parent 9efec244b9
commit 9715601255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -3,7 +3,11 @@ from __future__ import annotations
import logging
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.components.button import (
ButtonDeviceClass,
ButtonEntity,
ButtonEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG
from homeassistant.core import HomeAssistant
@ -20,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
RESTART_BUTTON: ButtonEntityDescription = ButtonEntityDescription(
key="restart",
name=f"{DEFAULT_NAME} Restart",
icon="mdi:restart",
device_class=ButtonDeviceClass.RESTART,
entity_category=ENTITY_CATEGORY_CONFIG,
)

View file

@ -1,8 +1,8 @@
"""Test button of Nettigo Air Monitor integration."""
from unittest.mock import patch
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, ATTR_ICON, STATE_UNKNOWN
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, ButtonDeviceClass
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_UNKNOWN
from homeassistant.helpers import entity_registry as er
from homeassistant.util import dt as dt_util
@ -18,7 +18,7 @@ async def test_button(hass):
state = hass.states.get("button.nettigo_air_monitor_restart")
assert state
assert state.state == STATE_UNKNOWN
assert state.attributes.get(ATTR_ICON) == "mdi:restart"
assert state.attributes.get(ATTR_DEVICE_CLASS) == ButtonDeviceClass.RESTART
entry = registry.async_get("button.nettigo_air_monitor_restart")
assert entry