diff --git a/homeassistant/components/minecraft_server/binary_sensor.py b/homeassistant/components/minecraft_server/binary_sensor.py index 0446e0a2d7cf6b3a63e8c7ba667bb135730af9d3..e89fce2d7d5a8fddf6437e788d75b4dfb300e108 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 beacfde5b8e193efa83b7ad5c0c5409a917c3f28..f4b4212bc64befecb3b1e9c8039b42421f1278c1 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 ea510c467a14438eecb64fc6f2159a154a1da74a..9f14f429a12c1b5742702e71f4b2c4d6c087c18c 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 6965759e734dcdfebc65f2f4e792924c810b113d..178c12772c6686b3341524f73791a4c0d697a7d4 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 e7e91c7be86c9496b52e72d4e9e0530b357d1ba0..9bac71e00005bac1a4c6786dd05c5c207c897b1c 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 ac9ec52f679014d0f19e9762af278473c475efca..f5991620c685152f5b5b7ad5e02160c087077ad8 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 27749e5b60f78ccd9dac5372cb3287ef298b0962..efe534e0f9200252ba84b19c19e4f450ce2c86d7 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: