1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 17:22:20 +01:00

Allow entities to be disabled by default in HA (#2113)

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Jesse Hills
2021-08-10 13:45:31 +12:00
committed by GitHub
parent c038cf27a7
commit 93796491af
20 changed files with 224 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ from esphome.const import (
CONF_ACCURACY_DECIMALS,
CONF_ALPHA,
CONF_BELOW,
CONF_DISABLED_BY_DEFAULT,
CONF_EXPIRE_AFTER,
CONF_FILTERS,
CONF_FROM,
@@ -170,7 +171,7 @@ validate_accuracy_decimals = cv.int_
validate_icon = cv.icon
validate_device_class = cv.one_of(*DEVICE_CLASSES, lower=True, space="_")
SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend(
SENSOR_SCHEMA = cv.NAMEABLE_SCHEMA.extend(cv.MQTT_COMPONENT_SCHEMA).extend(
{
cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTSensorComponent),
cv.GenerateID(): cv.declare_id(Sensor),
@@ -494,6 +495,7 @@ async def build_filters(config):
async def setup_sensor_core_(var, config):
cg.add(var.set_name(config[CONF_NAME]))
cg.add(var.set_disabled_by_default(config[CONF_DISABLED_BY_DEFAULT]))
if CONF_INTERNAL in config:
cg.add(var.set_internal(config[CONF_INTERNAL]))
if CONF_DEVICE_CLASS in config: