Allow extra keys in MQTT discovery messages (#58390)

* Allow extra keys in MQTT discovery messages

* Remove extra keys
This commit is contained in:
Erik Montnemery 2021-10-25 13:47:06 +02:00 committed by GitHub
parent a8a8b532d0
commit 640a7fee9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 628 additions and 480 deletions

View file

@ -58,6 +58,8 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend(
}
).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
DISCOVERY_SCHEMA = PLATFORM_SCHEMA.extend({}, extra=vol.REMOVE_EXTRA)
async def async_setup_platform(
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
@ -72,7 +74,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
setup = functools.partial(
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
)
await async_setup_entry_helper(hass, binary_sensor.DOMAIN, setup, PLATFORM_SCHEMA)
await async_setup_entry_helper(hass, binary_sensor.DOMAIN, setup, DISCOVERY_SCHEMA)
async def _async_setup_entity(
@ -101,7 +103,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity):
@staticmethod
def config_schema():
"""Return the config schema."""
return PLATFORM_SCHEMA
return DISCOVERY_SCHEMA
def _setup_from_config(self, config):
value_template = self._config.get(CONF_VALUE_TEMPLATE)