Skip to content

Commit

Permalink
Remove platform key and rename schema for mqtt tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh committed Oct 7, 2023
1 parent 031a922 commit f0be778
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions homeassistant/components/mqtt/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from homeassistant.components import tag
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_DEVICE, CONF_PLATFORM, CONF_VALUE_TEMPLATE
from homeassistant.const import CONF_DEVICE, CONF_VALUE_TEMPLATE
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
Expand All @@ -33,10 +33,9 @@

TAG = "tag"

PLATFORM_SCHEMA = MQTT_BASE_SCHEMA.extend(
DISCOVERY_SCHEMA = MQTT_BASE_SCHEMA.extend(
{
vol.Optional(CONF_DEVICE): MQTT_ENTITY_DEVICE_INFO_SCHEMA,
vol.Optional(CONF_PLATFORM): "mqtt",
vol.Required(CONF_TOPIC): valid_subscribe_topic,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
},
Expand All @@ -48,7 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> N
"""Set up MQTT tag scanner 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)
await async_setup_entry_helper(hass, TAG, setup, DISCOVERY_SCHEMA)


async def _async_setup_tag(
Expand Down Expand Up @@ -121,7 +120,7 @@ async def async_update(self, discovery_data: MQTTDiscoveryPayload) -> None:
"""Handle MQTT tag discovery updates."""
# Update tag scanner
try:
config: DiscoveryInfoType = PLATFORM_SCHEMA(discovery_data)
config: DiscoveryInfoType = DISCOVERY_SCHEMA(discovery_data)
except vol.Invalid as err:
async_handle_schema_error(discovery_data, err)
return
Expand Down

0 comments on commit f0be778

Please sign in to comment.