From 0a020cef2a8d49356e838e3a7987a1060ef9e784 Mon Sep 17 00:00:00 2001 From: t0urista Date: Mon, 28 Oct 2024 12:36:45 +0100 Subject: [PATCH] Update binary_sensor.py --- esphome/components/bthome/binary_sensor.py | 70 +++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/esphome/components/bthome/binary_sensor.py b/esphome/components/bthome/binary_sensor.py index 23eb893e3f..0aacc9549b 100644 --- a/esphome/components/bthome/binary_sensor.py +++ b/esphome/components/bthome/binary_sensor.py @@ -1,16 +1,75 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import binary_sensor +from esphome.components import sensor // added dco +from esphome.components import event // added dco + + from esphome.const import ( + # non-binary + DEVICE_CLASS_EMPTY, + DEVICE_CLASS_AQI, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_CARBON_DIOXIDE, + DEVICE_CLASS_CARBON_MONOXIDE, + DEVICE_CLASS_CURRENT, + DEVICE_CLASS_ENERGY, + DEVICE_CLASS_GAS, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_ILLUMINANCE, + DEVICE_CLASS_MONETARY, + DEVICE_CLASS_NITROGEN_DIOXIDE, + DEVICE_CLASS_NITROGEN_MONOXIDE, + DEVICE_CLASS_NITROUS_OXIDE, + DEVICE_CLASS_OZONE, + DEVICE_CLASS_PM1, + DEVICE_CLASS_PM10, + DEVICE_CLASS_PM25, + DEVICE_CLASS_POWER, + DEVICE_CLASS_POWER_FACTOR, + DEVICE_CLASS_PRESSURE, + DEVICE_CLASS_SIGNAL_STRENGTH, + DEVICE_CLASS_SULPHUR_DIOXIDE, + DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_TIMESTAMP, + DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, + DEVICE_CLASS_VOLTAGE, + # binary + DEVICE_CLASS_EMPTY, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_GAS, + DEVICE_CLASS_POWER, + DEVICE_CLASS_BATTERY_CHARGING, + DEVICE_CLASS_COLD, + DEVICE_CLASS_CONNECTIVITY, + DEVICE_CLASS_DOOR, + DEVICE_CLASS_GARAGE_DOOR, + DEVICE_CLASS_HEAT, + DEVICE_CLASS_LIGHT, + DEVICE_CLASS_LOCK, + DEVICE_CLASS_MOISTURE, + DEVICE_CLASS_MOTION, + DEVICE_CLASS_MOVING, + DEVICE_CLASS_OCCUPANCY, + DEVICE_CLASS_OPENING, + DEVICE_CLASS_PLUG, + DEVICE_CLASS_PRESENCE, + DEVICE_CLASS_PROBLEM, + DEVICE_CLASS_RUNNING, + DEVICE_CLASS_SAFETY, + DEVICE_CLASS_SMOKE, + DEVICE_CLASS_SOUND, + DEVICE_CLASS_TAMPER, + DEVICE_CLASS_VIBRATION, DEVICE_CLASS_WINDOW, + DEVICE_CLASS_UPDATE, CONF_ID, ) from . import BTHome - CONF_WINDOW = "window" - +CONF_MOTION = "motion" // added dco DEPENDENCIES = ["bthome"] @@ -21,6 +80,9 @@ CONFIG_SCHEMA = cv.Schema( cv.Optional(CONF_WINDOW): binary_sensor.binary_sensor_schema( device_class=DEVICE_CLASS_WINDOW ), + cv.Optional(CONF_MOTION): binary_sensor.binary_sensor_schema( + device_class=DEVICE_CLASS_MOTION + ), } ) @@ -31,3 +93,7 @@ async def to_code(config): if CONF_WINDOW in config: sens = await binary_sensor.new_binary_sensor(config[CONF_WINDOW]) cg.add(parent.set_window(sens)) + + if CONF_MOTION in config: // added dco + sens = await binary_sensor.new_binary_sensor(config[CONF_MOTION]) // added dco + cg.add(parent.set_window(sens)) // added dco