mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
[mics_4514] Move consts to consts.py (#7528)
Some checks are pending
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
Some checks are pending
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
This commit is contained in:
parent
0d80286bb3
commit
361b6ab961
2 changed files with 17 additions and 26 deletions
|
@ -1,10 +1,14 @@
|
|||
import esphome.codegen as cg
|
||||
from esphome.components import i2c, sensor
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from esphome.components import sensor, i2c
|
||||
|
||||
from esphome.const import (
|
||||
CONF_AMMONIA,
|
||||
CONF_CARBON_MONOXIDE,
|
||||
CONF_ETHANOL,
|
||||
CONF_HYDROGEN,
|
||||
CONF_ID,
|
||||
CONF_METHANE,
|
||||
CONF_NITROGEN_DIOXIDE,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_PARTS_PER_MILLION,
|
||||
)
|
||||
|
@ -12,13 +16,6 @@ from esphome.const import (
|
|||
CODEOWNERS = ["@jesserockz"]
|
||||
DEPENDENCIES = ["i2c"]
|
||||
|
||||
CONF_CARBON_MONOXIDE = "carbon_monoxide"
|
||||
CONF_NITROGEN_DIOXIDE = "nitrogen_dioxide"
|
||||
CONF_METHANE = "methane"
|
||||
CONF_ETHANOL = "ethanol"
|
||||
CONF_HYDROGEN = "hydrogen"
|
||||
CONF_AMMONIA = "ammonia"
|
||||
|
||||
|
||||
mics_4514_ns = cg.esphome_ns.namespace("mics_4514")
|
||||
MICS4514Component = mics_4514_ns.class_(
|
||||
|
@ -31,6 +28,7 @@ SENSORS = [
|
|||
CONF_ETHANOL,
|
||||
CONF_HYDROGEN,
|
||||
CONF_AMMONIA,
|
||||
CONF_NITROGEN_DIOXIDE,
|
||||
]
|
||||
|
||||
common_sensor_schema = sensor.sensor_schema(
|
||||
|
@ -40,16 +38,7 @@ common_sensor_schema = sensor.sensor_schema(
|
|||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(MICS4514Component),
|
||||
cv.Optional(CONF_NITROGEN_DIOXIDE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PARTS_PER_MILLION,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
accuracy_decimals=2,
|
||||
),
|
||||
}
|
||||
)
|
||||
cv.Schema({cv.GenerateID(): cv.declare_id(MICS4514Component)})
|
||||
.extend({cv.Optional(sensor_type): common_sensor_schema for sensor_type in SENSORS})
|
||||
.extend(i2c.i2c_device_schema(0x75))
|
||||
.extend(cv.polling_component_schema("60s"))
|
||||
|
@ -62,10 +51,6 @@ async def to_code(config):
|
|||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
for sensor_type in SENSORS:
|
||||
if sensor_type in config:
|
||||
sens = await sensor.new_sensor(config[sensor_type])
|
||||
if sensor_config := config.get(sensor_type):
|
||||
sens = await sensor.new_sensor(sensor_config)
|
||||
cg.add(getattr(var, f"set_{sensor_type}_sensor")(sens))
|
||||
|
||||
if CONF_NITROGEN_DIOXIDE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_NITROGEN_DIOXIDE])
|
||||
cg.add(var.set_nitrogen_dioxide_sensor(sens))
|
||||
|
|
|
@ -53,6 +53,7 @@ CONF_ALLOW_OTHER_USES = "allow_other_uses"
|
|||
CONF_ALPHA = "alpha"
|
||||
CONF_ALTITUDE = "altitude"
|
||||
CONF_AMBIENT_LIGHT = "ambient_light"
|
||||
CONF_AMMONIA = "ammonia"
|
||||
CONF_ANALOG = "analog"
|
||||
CONF_AND = "and"
|
||||
CONF_ANGLE = "angle"
|
||||
|
@ -110,6 +111,7 @@ CONF_CALIBRATE_LINEAR = "calibrate_linear"
|
|||
CONF_CALIBRATION = "calibration"
|
||||
CONF_CAPACITANCE = "capacitance"
|
||||
CONF_CAPACITY = "capacity"
|
||||
CONF_CARBON_MONOXIDE = "carbon_monoxide"
|
||||
CONF_CARRIER_DUTY_PERCENT = "carrier_duty_percent"
|
||||
CONF_CARRIER_FREQUENCY = "carrier_frequency"
|
||||
CONF_CERTIFICATE = "certificate"
|
||||
|
@ -263,6 +265,7 @@ CONF_ENUM_DATAPOINT = "enum_datapoint"
|
|||
CONF_EQUATION = "equation"
|
||||
CONF_ESP8266_DISABLE_SSL_SUPPORT = "esp8266_disable_ssl_support"
|
||||
CONF_ESPHOME = "esphome"
|
||||
CONF_ETHANOL = "ethanol"
|
||||
CONF_ETHERNET = "ethernet"
|
||||
CONF_EVENT = "event"
|
||||
CONF_EVENT_TYPE = "event_type"
|
||||
|
@ -361,6 +364,7 @@ CONF_HOURS = "hours"
|
|||
CONF_HSYNC_PIN = "hsync_pin"
|
||||
CONF_HUMIDITY = "humidity"
|
||||
CONF_HUMIDITY_SENSOR = "humidity_sensor"
|
||||
CONF_HYDROGEN = "hydrogen"
|
||||
CONF_HYSTERESIS = "hysteresis"
|
||||
CONF_I2C = "i2c"
|
||||
CONF_I2C_ID = "i2c_id"
|
||||
|
@ -477,6 +481,7 @@ CONF_MEDIA_PLAYER = "media_player"
|
|||
CONF_MEDIUM = "medium"
|
||||
CONF_MEMORY_BLOCKS = "memory_blocks"
|
||||
CONF_MESSAGE = "message"
|
||||
CONF_METHANE = "methane"
|
||||
CONF_METHOD = "method"
|
||||
CONF_MICROPHONE = "microphone"
|
||||
CONF_MIN_BRIGHTNESS = "min_brightness"
|
||||
|
@ -523,6 +528,7 @@ CONF_NBITS = "nbits"
|
|||
CONF_NEC = "nec"
|
||||
CONF_NETWORKS = "networks"
|
||||
CONF_NEW_PASSWORD = "new_password"
|
||||
CONF_NITROGEN_DIOXIDE = "nitrogen_dioxide"
|
||||
CONF_NOISE_LEVEL = "noise_level"
|
||||
CONF_NUM_ATTEMPTS = "num_attempts"
|
||||
CONF_NUM_CHANNELS = "num_channels"
|
||||
|
|
Loading…
Reference in a new issue