Add device_class to valve core config (#6765)

This commit is contained in:
acshef 2024-05-17 22:17:09 -06:00 committed by GitHub
parent df838b5788
commit 94b63d7bc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,8 @@ from esphome.const import (
CONF_STATE, CONF_STATE,
CONF_STOP, CONF_STOP,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
DEVICE_CLASS_GAS,
DEVICE_CLASS_WATER,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
@ -22,6 +24,11 @@ IS_PLATFORM_COMPONENT = True
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
DEVICE_CLASSES = [
DEVICE_CLASS_GAS,
DEVICE_CLASS_WATER,
]
valve_ns = cg.esphome_ns.namespace("valve") valve_ns = cg.esphome_ns.namespace("valve")
Valve = valve_ns.class_("Valve", cg.EntityBase) Valve = valve_ns.class_("Valve", cg.EntityBase)
@ -65,6 +72,7 @@ VALVE_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA).ex
{ {
cv.GenerateID(): cv.declare_id(Valve), cv.GenerateID(): cv.declare_id(Valve),
cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTValveComponent), cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTValveComponent),
cv.Optional(CONF_DEVICE_CLASS): cv.one_of(*DEVICE_CLASSES, lower=True),
cv.Optional(CONF_POSITION_COMMAND_TOPIC): cv.All( cv.Optional(CONF_POSITION_COMMAND_TOPIC): cv.All(
cv.requires_component("mqtt"), cv.subscribe_topic cv.requires_component("mqtt"), cv.subscribe_topic
), ),