From f2fc62138aa3714ced71bd758ccc052fa02d100d Mon Sep 17 00:00:00 2001
From: elmurato <1382097+elmurato@users.noreply.github.com>
Date: Thu, 21 Sep 2023 08:40:07 +0200
Subject: [PATCH] Clean-up Minecraft Server constants (#100666)

---
 .../minecraft_server/binary_sensor.py         |  6 +++-
 .../minecraft_server/config_flow.py           |  4 ++-
 .../components/minecraft_server/const.py      | 25 -------------
 .../minecraft_server/coordinator.py           |  5 +--
 .../components/minecraft_server/entity.py     |  4 ++-
 .../components/minecraft_server/helpers.py    |  2 +-
 .../components/minecraft_server/sensor.py     | 36 +++++++++----------
 7 files changed, 33 insertions(+), 49 deletions(-)

diff --git a/homeassistant/components/minecraft_server/binary_sensor.py b/homeassistant/components/minecraft_server/binary_sensor.py
index 0446e0a2d7c..e89fce2d7d5 100644
--- a/homeassistant/components/minecraft_server/binary_sensor.py
+++ b/homeassistant/components/minecraft_server/binary_sensor.py
@@ -10,10 +10,14 @@ from homeassistant.config_entries import ConfigEntry
 from homeassistant.core import HomeAssistant
 from homeassistant.helpers.entity_platform import AddEntitiesCallback
 
-from .const import DOMAIN, ICON_STATUS, KEY_STATUS
+from .const import DOMAIN
 from .coordinator import MinecraftServerCoordinator
 from .entity import MinecraftServerEntity
 
+ICON_STATUS = "mdi:lan"
+
+KEY_STATUS = "status"
+
 
 @dataclass
 class MinecraftServerBinarySensorEntityDescription(BinarySensorEntityDescription):
diff --git a/homeassistant/components/minecraft_server/config_flow.py b/homeassistant/components/minecraft_server/config_flow.py
index beacfde5b8e..f4b4212bc64 100644
--- a/homeassistant/components/minecraft_server/config_flow.py
+++ b/homeassistant/components/minecraft_server/config_flow.py
@@ -10,7 +10,9 @@ from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
 from homeassistant.data_entry_flow import FlowResult
 
 from . import helpers
-from .const import DEFAULT_HOST, DEFAULT_NAME, DEFAULT_PORT, DOMAIN
+from .const import DEFAULT_NAME, DEFAULT_PORT, DOMAIN
+
+DEFAULT_HOST = "localhost:25565"
 
 _LOGGER = logging.getLogger(__name__)
 
diff --git a/homeassistant/components/minecraft_server/const.py b/homeassistant/components/minecraft_server/const.py
index ea510c467a1..9f14f429a12 100644
--- a/homeassistant/components/minecraft_server/const.py
+++ b/homeassistant/components/minecraft_server/const.py
@@ -1,34 +1,9 @@
 """Constants for the Minecraft Server integration."""
 
-ATTR_PLAYERS_LIST = "players_list"
-
-DEFAULT_HOST = "localhost:25565"
 DEFAULT_NAME = "Minecraft Server"
 DEFAULT_PORT = 25565
 
 DOMAIN = "minecraft_server"
 
-ICON_LATENCY = "mdi:signal"
-ICON_PLAYERS_MAX = "mdi:account-multiple"
-ICON_PLAYERS_ONLINE = "mdi:account-multiple"
-ICON_PROTOCOL_VERSION = "mdi:numeric"
-ICON_STATUS = "mdi:lan"
-ICON_VERSION = "mdi:numeric"
-ICON_MOTD = "mdi:minecraft"
-
 KEY_LATENCY = "latency"
-KEY_PLAYERS_MAX = "players_max"
-KEY_PLAYERS_ONLINE = "players_online"
-KEY_PROTOCOL_VERSION = "protocol_version"
-KEY_STATUS = "status"
-KEY_VERSION = "version"
 KEY_MOTD = "motd"
-
-MANUFACTURER = "Mojang AB"
-
-SCAN_INTERVAL = 60
-
-SRV_RECORD_PREFIX = "_minecraft._tcp"
-
-UNIT_PLAYERS_MAX = "players"
-UNIT_PLAYERS_ONLINE = "players"
diff --git a/homeassistant/components/minecraft_server/coordinator.py b/homeassistant/components/minecraft_server/coordinator.py
index 6965759e734..178c12772c6 100644
--- a/homeassistant/components/minecraft_server/coordinator.py
+++ b/homeassistant/components/minecraft_server/coordinator.py
@@ -14,7 +14,8 @@ from homeassistant.core import HomeAssistant
 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
 
 from . import helpers
-from .const import SCAN_INTERVAL
+
+SCAN_INTERVAL = timedelta(seconds=60)
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -45,7 +46,7 @@ class MinecraftServerCoordinator(DataUpdateCoordinator[MinecraftServerData]):
             hass=hass,
             name=config_data[CONF_NAME],
             logger=_LOGGER,
-            update_interval=timedelta(seconds=SCAN_INTERVAL),
+            update_interval=SCAN_INTERVAL,
         )
 
         # Server data
diff --git a/homeassistant/components/minecraft_server/entity.py b/homeassistant/components/minecraft_server/entity.py
index e7e91c7be86..9bac71e0000 100644
--- a/homeassistant/components/minecraft_server/entity.py
+++ b/homeassistant/components/minecraft_server/entity.py
@@ -3,9 +3,11 @@
 from homeassistant.helpers.device_registry import DeviceInfo
 from homeassistant.helpers.update_coordinator import CoordinatorEntity
 
-from .const import DOMAIN, MANUFACTURER
+from .const import DOMAIN
 from .coordinator import MinecraftServerCoordinator
 
+MANUFACTURER = "Mojang Studios"
+
 
 class MinecraftServerEntity(CoordinatorEntity[MinecraftServerCoordinator]):
     """Representation of a Minecraft Server base entity."""
diff --git a/homeassistant/components/minecraft_server/helpers.py b/homeassistant/components/minecraft_server/helpers.py
index ac9ec52f679..f5991620c68 100644
--- a/homeassistant/components/minecraft_server/helpers.py
+++ b/homeassistant/components/minecraft_server/helpers.py
@@ -6,7 +6,7 @@ import aiodns
 
 from homeassistant.const import CONF_HOST, CONF_PORT
 
-from .const import SRV_RECORD_PREFIX
+SRV_RECORD_PREFIX = "_minecraft._tcp"
 
 _LOGGER = logging.getLogger(__name__)
 
diff --git a/homeassistant/components/minecraft_server/sensor.py b/homeassistant/components/minecraft_server/sensor.py
index 27749e5b60f..efe534e0f92 100644
--- a/homeassistant/components/minecraft_server/sensor.py
+++ b/homeassistant/components/minecraft_server/sensor.py
@@ -12,27 +12,27 @@ from homeassistant.core import HomeAssistant, callback
 from homeassistant.helpers.entity_platform import AddEntitiesCallback
 from homeassistant.helpers.typing import StateType
 
-from .const import (
-    ATTR_PLAYERS_LIST,
-    DOMAIN,
-    ICON_LATENCY,
-    ICON_MOTD,
-    ICON_PLAYERS_MAX,
-    ICON_PLAYERS_ONLINE,
-    ICON_PROTOCOL_VERSION,
-    ICON_VERSION,
-    KEY_LATENCY,
-    KEY_MOTD,
-    KEY_PLAYERS_MAX,
-    KEY_PLAYERS_ONLINE,
-    KEY_PROTOCOL_VERSION,
-    KEY_VERSION,
-    UNIT_PLAYERS_MAX,
-    UNIT_PLAYERS_ONLINE,
-)
+from .const import DOMAIN, KEY_LATENCY, KEY_MOTD
 from .coordinator import MinecraftServerCoordinator, MinecraftServerData
 from .entity import MinecraftServerEntity
 
+ATTR_PLAYERS_LIST = "players_list"
+
+ICON_LATENCY = "mdi:signal"
+ICON_PLAYERS_MAX = "mdi:account-multiple"
+ICON_PLAYERS_ONLINE = "mdi:account-multiple"
+ICON_PROTOCOL_VERSION = "mdi:numeric"
+ICON_VERSION = "mdi:numeric"
+ICON_MOTD = "mdi:minecraft"
+
+KEY_PLAYERS_MAX = "players_max"
+KEY_PLAYERS_ONLINE = "players_online"
+KEY_PROTOCOL_VERSION = "protocol_version"
+KEY_VERSION = "version"
+
+UNIT_PLAYERS_MAX = "players"
+UNIT_PLAYERS_ONLINE = "players"
+
 
 @dataclass
 class MinecraftServerEntityDescriptionMixin:
-- 
GitLab