Use core constants for mqtt (#46389)
parent
1b61b5c10b
commit
b85ecc0bd2
|
@ -19,6 +19,7 @@ from homeassistant import config_entries
|
|||
from homeassistant.components import websocket_api
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_DISCOVERY,
|
||||
CONF_PASSWORD,
|
||||
CONF_PAYLOAD,
|
||||
CONF_PORT,
|
||||
|
@ -28,7 +29,6 @@ from homeassistant.const import (
|
|||
EVENT_HOMEASSISTANT_STARTED,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
from homeassistant.const import CONF_UNIQUE_ID # noqa: F401
|
||||
from homeassistant.core import CoreState, Event, HassJob, ServiceCall, callback
|
||||
from homeassistant.exceptions import HomeAssistantError, Unauthorized
|
||||
from homeassistant.helpers import config_validation as cv, event, template
|
||||
|
@ -48,7 +48,6 @@ from .const import (
|
|||
ATTR_TOPIC,
|
||||
CONF_BIRTH_MESSAGE,
|
||||
CONF_BROKER,
|
||||
CONF_DISCOVERY,
|
||||
CONF_QOS,
|
||||
CONF_RETAIN,
|
||||
CONF_STATE_TOPIC,
|
||||
|
@ -1053,7 +1052,6 @@ async def websocket_subscribe(hass, connection, msg):
|
|||
@callback
|
||||
def async_subscribe_connection_status(hass, connection_status_callback):
|
||||
"""Subscribe to MQTT connection changes."""
|
||||
|
||||
connection_status_callback_job = HassJob(connection_status_callback)
|
||||
|
||||
async def connected():
|
||||
|
|
|
@ -110,7 +110,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT alarm control panel dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -78,7 +78,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT binary sensor dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
@ -214,7 +213,6 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity):
|
|||
@callback
|
||||
def _value_is_expired(self, *_):
|
||||
"""Triggered when value is expired."""
|
||||
|
||||
self._expiration_trigger = None
|
||||
self._expired = True
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT camera dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -38,6 +38,8 @@ from homeassistant.const import (
|
|||
ATTR_TEMPERATURE,
|
||||
CONF_DEVICE,
|
||||
CONF_NAME,
|
||||
CONF_PAYLOAD_OFF,
|
||||
CONF_PAYLOAD_ON,
|
||||
CONF_TEMPERATURE_UNIT,
|
||||
CONF_UNIQUE_ID,
|
||||
CONF_VALUE_TEMPLATE,
|
||||
|
@ -98,8 +100,6 @@ CONF_MODE_COMMAND_TOPIC = "mode_command_topic"
|
|||
CONF_MODE_LIST = "modes"
|
||||
CONF_MODE_STATE_TEMPLATE = "mode_state_template"
|
||||
CONF_MODE_STATE_TOPIC = "mode_state_topic"
|
||||
CONF_PAYLOAD_OFF = "payload_off"
|
||||
CONF_PAYLOAD_ON = "payload_on"
|
||||
CONF_POWER_COMMAND_TOPIC = "power_command_topic"
|
||||
CONF_POWER_STATE_TEMPLATE = "power_state_template"
|
||||
CONF_POWER_STATE_TOPIC = "power_state_topic"
|
||||
|
@ -274,7 +274,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT climate device dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -7,6 +7,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import (
|
||||
CONF_DISCOVERY,
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
CONF_PAYLOAD,
|
||||
|
@ -22,7 +23,6 @@ from .const import (
|
|||
ATTR_TOPIC,
|
||||
CONF_BIRTH_MESSAGE,
|
||||
CONF_BROKER,
|
||||
CONF_DISCOVERY,
|
||||
CONF_WILL_MESSAGE,
|
||||
DATA_MQTT_CONFIG,
|
||||
DEFAULT_BIRTH,
|
||||
|
|
|
@ -11,7 +11,6 @@ ATTR_TOPIC = "topic"
|
|||
|
||||
CONF_BROKER = "broker"
|
||||
CONF_BIRTH_MESSAGE = "birth_message"
|
||||
CONF_DISCOVERY = "discovery"
|
||||
CONF_QOS = ATTR_QOS
|
||||
CONF_RETAIN = ATTR_RETAIN
|
||||
CONF_STATE_TOPIC = "state_topic"
|
||||
|
|
|
@ -207,7 +207,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT cover dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -59,7 +59,6 @@ PLATFORM_SCHEMA_DISCOVERY = (
|
|||
|
||||
async def async_setup_entry_from_discovery(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT device tracker dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -122,7 +122,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT fan dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -43,7 +43,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT light dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -28,6 +28,7 @@ from homeassistant.const import (
|
|||
CONF_COLOR_TEMP,
|
||||
CONF_DEVICE,
|
||||
CONF_EFFECT,
|
||||
CONF_HS,
|
||||
CONF_NAME,
|
||||
CONF_OPTIMISTIC,
|
||||
CONF_RGB,
|
||||
|
@ -75,7 +76,6 @@ CONF_EFFECT_LIST = "effect_list"
|
|||
|
||||
CONF_FLASH_TIME_LONG = "flash_time_long"
|
||||
CONF_FLASH_TIME_SHORT = "flash_time_short"
|
||||
CONF_HS = "hs"
|
||||
|
||||
CONF_MAX_MIREDS = "max_mireds"
|
||||
CONF_MIN_MIREDS = "min_mireds"
|
||||
|
|
|
@ -24,6 +24,7 @@ from homeassistant.const import (
|
|||
CONF_DEVICE,
|
||||
CONF_NAME,
|
||||
CONF_OPTIMISTIC,
|
||||
CONF_STATE_TEMPLATE,
|
||||
CONF_UNIQUE_ID,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
|
@ -62,7 +63,6 @@ CONF_GREEN_TEMPLATE = "green_template"
|
|||
CONF_MAX_MIREDS = "max_mireds"
|
||||
CONF_MIN_MIREDS = "min_mireds"
|
||||
CONF_RED_TEMPLATE = "red_template"
|
||||
CONF_STATE_TEMPLATE = "state_template"
|
||||
CONF_WHITE_VALUE_TEMPLATE = "white_value_template"
|
||||
|
||||
PLATFORM_SCHEMA_TEMPLATE = (
|
||||
|
|
|
@ -84,7 +84,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT lock dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -67,7 +67,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT number dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
@ -110,7 +109,6 @@ class MqttNumber(MqttEntity, NumberEntity, RestoreEntity):
|
|||
@log_messages(self.hass, self.entity_id)
|
||||
def message_received(msg):
|
||||
"""Handle new MQTT messages."""
|
||||
|
||||
try:
|
||||
if msg.payload.decode("utf-8").isnumeric():
|
||||
self._current_number = int(msg.payload)
|
||||
|
@ -149,7 +147,6 @@ class MqttNumber(MqttEntity, NumberEntity, RestoreEntity):
|
|||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
"""Update the current value."""
|
||||
|
||||
current_number = value
|
||||
|
||||
if value.is_integer():
|
||||
|
|
|
@ -47,7 +47,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT scene dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -72,7 +72,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT sensors dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -80,7 +80,6 @@ async def async_setup_platform(
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT switch dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -45,7 +45,6 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend(
|
|||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
"""Set up MQTT tag scan dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(async_setup_tag, hass, config_entry=config_entry)
|
||||
await async_setup_entry_helper(hass, "tag", setup, PLATFORM_SCHEMA)
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up MQTT vacuum dynamically through MQTT discovery."""
|
||||
|
||||
setup = functools.partial(
|
||||
_async_setup_entity, async_add_entities, config_entry=config_entry
|
||||
)
|
||||
|
|
|
@ -377,7 +377,6 @@ class MqttVacuum(MqttEntity, VacuumEntity):
|
|||
|
||||
No need to check SUPPORT_BATTERY, this won't be called if battery_level is None.
|
||||
"""
|
||||
|
||||
return icon_for_battery_level(
|
||||
battery_level=self.battery_level, charging=self._charging
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue