[fix] report about required component

This commit is contained in:
Ramil Valitov 2024-11-08 13:16:38 +03:00
parent 1829e68730
commit 31d3d16a68
No known key found for this signature in database
GPG key ID: 2AB186DABDFE1914
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,2 @@
DEPENDENCIES = ["network"]
CONF_STATUS_ID = "status_id"

View file

@ -5,6 +5,7 @@ from esphome.const import (
DEVICE_CLASS_CONNECTIVITY,
ENTITY_CATEGORY_DIAGNOSTIC,
)
from . import CONF_STATUS_ID
status_ns = cg.esphome_ns.namespace("status")
StatusBinarySensor = status_ns.class_(
@ -15,7 +16,15 @@ CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(
StatusBinarySensor,
device_class=DEVICE_CLASS_CONNECTIVITY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
).extend(cv.COMPONENT_SCHEMA)
).extend(cv.COMPONENT_SCHEMA).extend(
cv.Schema(
{
cv.GenerateID(CONF_STATUS_ID): cv.All(
cv.requires_component("network")
),
}
)
)
async def to_code(config):