From 672fb44041476dd99868f196e46a32785c3bd9f6 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Thu, 20 Apr 2023 13:27:44 -0400 Subject: [PATCH] Add pjlink const (#91749) * Add pjlink const This is a precursor * Use DOMAIN const in pjlink media player * fixup! Add pjlink const --- homeassistant/components/pjlink/const.py | 8 ++++++++ homeassistant/components/pjlink/media_player.py | 12 ++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 homeassistant/components/pjlink/const.py diff --git a/homeassistant/components/pjlink/const.py b/homeassistant/components/pjlink/const.py new file mode 100644 index 00000000000..95e29e5bf23 --- /dev/null +++ b/homeassistant/components/pjlink/const.py @@ -0,0 +1,8 @@ +"""Constants for the PJLink integration.""" + +CONF_ENCODING = "encoding" + +DEFAULT_PORT = 4352 +DEFAULT_ENCODING = "utf-8" + +DOMAIN = "pjlink" diff --git a/homeassistant/components/pjlink/media_player.py b/homeassistant/components/pjlink/media_player.py index 3fb5facac5e..4bbf1225a92 100644 --- a/homeassistant/components/pjlink/media_player.py +++ b/homeassistant/components/pjlink/media_player.py @@ -19,11 +19,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -CONF_ENCODING = "encoding" - -DEFAULT_PORT = 4352 -DEFAULT_ENCODING = "utf-8" -DEFAULT_TIMEOUT = 10 +from .const import CONF_ENCODING, DEFAULT_ENCODING, DEFAULT_PORT, DOMAIN ERR_PROJECTOR_UNAVAILABLE = "projector unavailable" @@ -51,9 +47,9 @@ def setup_platform( encoding = config.get(CONF_ENCODING) password = config.get(CONF_PASSWORD) - if "pjlink" not in hass.data: - hass.data["pjlink"] = {} - hass_data = hass.data["pjlink"] + if DOMAIN not in hass.data: + hass.data[DOMAIN] = {} + hass_data = hass.data[DOMAIN] device_label = f"{host}:{port}" if device_label in hass_data: