Fix entity category for binary_sensor fails setup (#103511)
This commit is contained in:
parent
5bb3c7ca55
commit
db97e7588b
2 changed files with 23 additions and 0 deletions
|
@ -42,6 +42,7 @@ from .mixins import (
|
|||
MqttAvailability,
|
||||
MqttEntity,
|
||||
async_setup_entity_entry_helper,
|
||||
validate_sensor_entity_category,
|
||||
write_state_on_attr_change,
|
||||
)
|
||||
from .models import MqttValueTemplate, ReceiveMessage
|
||||
|
@ -68,10 +69,12 @@ _PLATFORM_SCHEMA_BASE = MQTT_RO_SCHEMA.extend(
|
|||
).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
|
||||
|
||||
DISCOVERY_SCHEMA = vol.All(
|
||||
validate_sensor_entity_category(binary_sensor.DOMAIN, discovery=True),
|
||||
_PLATFORM_SCHEMA_BASE.extend({}, extra=vol.REMOVE_EXTRA),
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA_MODERN = vol.All(
|
||||
validate_sensor_entity_category(binary_sensor.DOMAIN, discovery=False),
|
||||
_PLATFORM_SCHEMA_BASE,
|
||||
)
|
||||
|
||||
|
|
|
@ -2172,6 +2172,18 @@ async def test_setup_manual_mqtt_with_invalid_config(
|
|||
},
|
||||
"sensor.test",
|
||||
),
|
||||
(
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
"binary_sensor": {
|
||||
"name": "test",
|
||||
"state_topic": "test-topic",
|
||||
"entity_category": "config",
|
||||
}
|
||||
}
|
||||
},
|
||||
"binary_sensor.test",
|
||||
),
|
||||
],
|
||||
)
|
||||
@patch(
|
||||
|
@ -2195,6 +2207,14 @@ async def test_setup_manual_mqtt_with_invalid_entity_category(
|
|||
@pytest.mark.parametrize(
|
||||
("config", "entity_id"),
|
||||
[
|
||||
(
|
||||
{
|
||||
"name": "test",
|
||||
"state_topic": "test-topic",
|
||||
"entity_category": "config",
|
||||
},
|
||||
"binary_sensor.test",
|
||||
),
|
||||
(
|
||||
{
|
||||
"name": "test",
|
||||
|
|
Loading…
Add table
Reference in a new issue