mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Fix entity category for binary_sensor fails setup (#103511)
This commit is contained in:
parent
5bb3c7ca55
commit
db97e7588b
@ -42,6 +42,7 @@ from .mixins import (
|
|||||||
MqttAvailability,
|
MqttAvailability,
|
||||||
MqttEntity,
|
MqttEntity,
|
||||||
async_setup_entity_entry_helper,
|
async_setup_entity_entry_helper,
|
||||||
|
validate_sensor_entity_category,
|
||||||
write_state_on_attr_change,
|
write_state_on_attr_change,
|
||||||
)
|
)
|
||||||
from .models import MqttValueTemplate, ReceiveMessage
|
from .models import MqttValueTemplate, ReceiveMessage
|
||||||
@ -68,10 +69,12 @@ _PLATFORM_SCHEMA_BASE = MQTT_RO_SCHEMA.extend(
|
|||||||
).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
|
).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
|
||||||
|
|
||||||
DISCOVERY_SCHEMA = vol.All(
|
DISCOVERY_SCHEMA = vol.All(
|
||||||
|
validate_sensor_entity_category(binary_sensor.DOMAIN, discovery=True),
|
||||||
_PLATFORM_SCHEMA_BASE.extend({}, extra=vol.REMOVE_EXTRA),
|
_PLATFORM_SCHEMA_BASE.extend({}, extra=vol.REMOVE_EXTRA),
|
||||||
)
|
)
|
||||||
|
|
||||||
PLATFORM_SCHEMA_MODERN = vol.All(
|
PLATFORM_SCHEMA_MODERN = vol.All(
|
||||||
|
validate_sensor_entity_category(binary_sensor.DOMAIN, discovery=False),
|
||||||
_PLATFORM_SCHEMA_BASE,
|
_PLATFORM_SCHEMA_BASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2172,6 +2172,18 @@ async def test_setup_manual_mqtt_with_invalid_config(
|
|||||||
},
|
},
|
||||||
"sensor.test",
|
"sensor.test",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
mqtt.DOMAIN: {
|
||||||
|
"binary_sensor": {
|
||||||
|
"name": "test",
|
||||||
|
"state_topic": "test-topic",
|
||||||
|
"entity_category": "config",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"binary_sensor.test",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@patch(
|
@patch(
|
||||||
@ -2195,6 +2207,14 @@ async def test_setup_manual_mqtt_with_invalid_entity_category(
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("config", "entity_id"),
|
("config", "entity_id"),
|
||||||
[
|
[
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"name": "test",
|
||||||
|
"state_topic": "test-topic",
|
||||||
|
"entity_category": "config",
|
||||||
|
},
|
||||||
|
"binary_sensor.test",
|
||||||
|
),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"name": "test",
|
"name": "test",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user