diff --git a/homeassistant/components/wiz/const.py b/homeassistant/components/wiz/const.py index a88c445614a..e1a98482635 100644 --- a/homeassistant/components/wiz/const.py +++ b/homeassistant/components/wiz/const.py @@ -9,8 +9,6 @@ DEFAULT_NAME = "WiZ" DISCOVER_SCAN_TIMEOUT = 10 DISCOVERY_INTERVAL = timedelta(minutes=15) -SOCKET_DEVICE_STR = "_SOCKET_" - WIZ_EXCEPTIONS = ( OSError, WizLightTimeOutError, diff --git a/homeassistant/components/wiz/light.py b/homeassistant/components/wiz/light.py index bc5ac078ec7..2c4485c5b72 100644 --- a/homeassistant/components/wiz/light.py +++ b/homeassistant/components/wiz/light.py @@ -28,7 +28,7 @@ from homeassistant.util.color import ( color_temperature_mired_to_kelvin, ) -from .const import DOMAIN, SOCKET_DEVICE_STR +from .const import DOMAIN from .entity import WizToggleEntity from .models import WizData @@ -42,7 +42,7 @@ async def async_setup_entry( ) -> None: """Set up the WiZ Platform from config_flow.""" wiz_data: WizData = hass.data[DOMAIN][entry.entry_id] - if SOCKET_DEVICE_STR not in wiz_data.bulb.bulbtype.name: + if wiz_data.bulb.bulbtype.bulb_type != BulbClass.SOCKET: async_add_entities([WizBulbEntity(wiz_data, entry.title)]) diff --git a/homeassistant/components/wiz/switch.py b/homeassistant/components/wiz/switch.py index e6e34c73c3b..ffe75910b40 100644 --- a/homeassistant/components/wiz/switch.py +++ b/homeassistant/components/wiz/switch.py @@ -4,13 +4,14 @@ from __future__ import annotations from typing import Any from pywizlight import PilotBuilder +from pywizlight.bulblibrary import BulbClass from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from .const import DOMAIN, SOCKET_DEVICE_STR +from .const import DOMAIN from .entity import WizToggleEntity from .models import WizData @@ -22,7 +23,7 @@ async def async_setup_entry( ) -> None: """Set up the WiZ switch platform.""" wiz_data: WizData = hass.data[DOMAIN][entry.entry_id] - if SOCKET_DEVICE_STR in wiz_data.bulb.bulbtype.name: + if wiz_data.bulb.bulbtype.bulb_type == BulbClass.SOCKET: async_add_entities([WizSocketEntity(wiz_data, entry.title)]) diff --git a/homeassistant/components/wiz/utils.py b/homeassistant/components/wiz/utils.py index ceaab797d5e..42be5758130 100644 --- a/homeassistant/components/wiz/utils.py +++ b/homeassistant/components/wiz/utils.py @@ -3,7 +3,7 @@ from __future__ import annotations from pywizlight import BulbType -from .const import DEFAULT_NAME, SOCKET_DEVICE_STR +from .const import DEFAULT_NAME def _short_mac(mac: str) -> str: @@ -13,8 +13,4 @@ def _short_mac(mac: str) -> str: def name_from_bulb_type_and_mac(bulb_type: BulbType, mac: str) -> str: """Generate a name from bulb_type and mac.""" - if SOCKET_DEVICE_STR in bulb_type.name: - description = "Socket" - else: - description = bulb_type.bulb_type.value - return f"{DEFAULT_NAME} {description} {_short_mac(mac)}" + return f"{DEFAULT_NAME} {bulb_type.bulb_type.value} {_short_mac(mac)}"