mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Clean-up Minecraft Server constants (#100666)
This commit is contained in:
parent
9f56aec267
commit
f2fc62138a
@ -10,10 +10,14 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, ICON_STATUS, KEY_STATUS
|
from .const import DOMAIN
|
||||||
from .coordinator import MinecraftServerCoordinator
|
from .coordinator import MinecraftServerCoordinator
|
||||||
from .entity import MinecraftServerEntity
|
from .entity import MinecraftServerEntity
|
||||||
|
|
||||||
|
ICON_STATUS = "mdi:lan"
|
||||||
|
|
||||||
|
KEY_STATUS = "status"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MinecraftServerBinarySensorEntityDescription(BinarySensorEntityDescription):
|
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 homeassistant.data_entry_flow import FlowResult
|
||||||
|
|
||||||
from . import helpers
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -1,34 +1,9 @@
|
|||||||
"""Constants for the Minecraft Server integration."""
|
"""Constants for the Minecraft Server integration."""
|
||||||
|
|
||||||
ATTR_PLAYERS_LIST = "players_list"
|
|
||||||
|
|
||||||
DEFAULT_HOST = "localhost:25565"
|
|
||||||
DEFAULT_NAME = "Minecraft Server"
|
DEFAULT_NAME = "Minecraft Server"
|
||||||
DEFAULT_PORT = 25565
|
DEFAULT_PORT = 25565
|
||||||
|
|
||||||
DOMAIN = "minecraft_server"
|
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_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"
|
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 homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from . import helpers
|
from . import helpers
|
||||||
from .const import SCAN_INTERVAL
|
|
||||||
|
SCAN_INTERVAL = timedelta(seconds=60)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ class MinecraftServerCoordinator(DataUpdateCoordinator[MinecraftServerData]):
|
|||||||
hass=hass,
|
hass=hass,
|
||||||
name=config_data[CONF_NAME],
|
name=config_data[CONF_NAME],
|
||||||
logger=_LOGGER,
|
logger=_LOGGER,
|
||||||
update_interval=timedelta(seconds=SCAN_INTERVAL),
|
update_interval=SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Server data
|
# Server data
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DOMAIN, MANUFACTURER
|
from .const import DOMAIN
|
||||||
from .coordinator import MinecraftServerCoordinator
|
from .coordinator import MinecraftServerCoordinator
|
||||||
|
|
||||||
|
MANUFACTURER = "Mojang Studios"
|
||||||
|
|
||||||
|
|
||||||
class MinecraftServerEntity(CoordinatorEntity[MinecraftServerCoordinator]):
|
class MinecraftServerEntity(CoordinatorEntity[MinecraftServerCoordinator]):
|
||||||
"""Representation of a Minecraft Server base entity."""
|
"""Representation of a Minecraft Server base entity."""
|
||||||
|
@ -6,7 +6,7 @@ import aiodns
|
|||||||
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
|
|
||||||
from .const import SRV_RECORD_PREFIX
|
SRV_RECORD_PREFIX = "_minecraft._tcp"
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -12,27 +12,27 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from .const import (
|
from .const import DOMAIN, KEY_LATENCY, KEY_MOTD
|
||||||
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 .coordinator import MinecraftServerCoordinator, MinecraftServerData
|
from .coordinator import MinecraftServerCoordinator, MinecraftServerData
|
||||||
from .entity import MinecraftServerEntity
|
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
|
@dataclass
|
||||||
class MinecraftServerEntityDescriptionMixin:
|
class MinecraftServerEntityDescriptionMixin:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user