From 971560125503982bbfcc2605211cf2921b105800 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 1 Dec 2021 07:08:17 +0100 Subject: [PATCH] Add button device classes to NAM (#60621) --- homeassistant/components/nam/button.py | 8 ++++++-- tests/components/nam/test_button.py | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/nam/button.py b/homeassistant/components/nam/button.py index 3a205606ccc..73b5169abcd 100644 --- a/homeassistant/components/nam/button.py +++ b/homeassistant/components/nam/button.py @@ -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, ) diff --git a/tests/components/nam/test_button.py b/tests/components/nam/test_button.py index 7cd731e7584..c8ed00b3376 100644 --- a/tests/components/nam/test_button.py +++ b/tests/components/nam/test_button.py @@ -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