Skip to content
Snippets Groups Projects
Unverified Commit f2fc6213 authored by elmurato's avatar elmurato Committed by GitHub
Browse files

Clean-up Minecraft Server constants (#100666)

parent 9f56aec2
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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__)
......
"""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"
......@@ -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
......
......@@ -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."""
......
......@@ -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__)
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment