mirror of
https://github.com/esphome/esphome.git
synced 2026-10-27 16:32:11 +00:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49b1a67509 | ||
|
|
a5a883fd19 | ||
|
|
7671d4410c | ||
|
|
298bd5ec72 | ||
|
|
b8afcdfb3c | ||
|
|
9031df757b | ||
|
|
107bebebad | ||
|
|
1147b024d6 | ||
|
|
36ba2f6106 | ||
|
|
bb0eabf241 | ||
|
|
d9969dd533 | ||
|
|
51ae3bb642 | ||
|
|
b3ef5cf2f3 | ||
|
|
b3f5789dc6 | ||
|
|
1ddacb4931 |
No files matched your search
@@ -27,7 +27,7 @@ jobs:
|
||||
days-before-close: 7
|
||||
stale-label: stale
|
||||
exempt-label: not-stale
|
||||
conflict-label: needs-rebase
|
||||
conflict-label: has-conflicts
|
||||
ignored-users: esphbot,codecov-commenter
|
||||
stale-pr-message: >
|
||||
There hasn't been any activity on this pull request recently. This
|
||||
|
||||
+3
-11
@@ -426,20 +426,12 @@ def _apply_function(
|
||||
) -> MockObj:
|
||||
"""Emit the generated function and declare ``id_`` as the ``ApplyAction`` or
|
||||
``ApplyCondition`` templated on it, so ``play()`` calls it directly."""
|
||||
fn = apply_static_function(id_, return_type, lambda_args, statements)
|
||||
fn = cg.static_function(
|
||||
f"esphome__{id_.id}__fn", return_type, lambda_args, statements
|
||||
)
|
||||
return cg.new_Pvariable(id_, cg.TemplateArguments(fn, *template_arg))
|
||||
|
||||
|
||||
def apply_static_function(
|
||||
id_: ID,
|
||||
return_type: SafeExpType,
|
||||
params: TemplateArgsType,
|
||||
statements: list[str],
|
||||
) -> MockObj:
|
||||
"""Emit the static function generated for ``id_`` and return an expression naming it."""
|
||||
return cg.static_function(f"esphome__{id_.id}__fn", return_type, params, statements)
|
||||
|
||||
|
||||
async def _render_values(
|
||||
name: str,
|
||||
target: str,
|
||||
|
||||
@@ -19,11 +19,7 @@ AbsoluteHumidityComponent = absolute_humidity_ns.class_(
|
||||
SaturationVaporPressureEquation = absolute_humidity_ns.enum(
|
||||
"SaturationVaporPressureEquation"
|
||||
)
|
||||
EQUATION = {
|
||||
"BUCK": SaturationVaporPressureEquation.BUCK,
|
||||
"TETENS": SaturationVaporPressureEquation.TETENS,
|
||||
"WOBUS": SaturationVaporPressureEquation.WOBUS,
|
||||
}
|
||||
EQUATION = SaturationVaporPressureEquation.options("BUCK", "TETENS", "WOBUS")
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
sensor.sensor_schema(
|
||||
|
||||
@@ -14,11 +14,9 @@ ac_dimmer_ns = cg.esphome_ns.namespace("ac_dimmer")
|
||||
AcDimmer = ac_dimmer_ns.class_("AcDimmer", output.FloatOutput, cg.Component)
|
||||
|
||||
DimMethod = ac_dimmer_ns.enum("DimMethod")
|
||||
DIM_METHODS = {
|
||||
"LEADING_PULSE": DimMethod.DIM_METHOD_LEADING_PULSE,
|
||||
"LEADING": DimMethod.DIM_METHOD_LEADING,
|
||||
"TRAILING": DimMethod.DIM_METHOD_TRAILING,
|
||||
}
|
||||
DIM_METHODS = DimMethod.options(
|
||||
"LEADING_PULSE", "LEADING", "TRAILING", prefix="DIM_METHOD_"
|
||||
)
|
||||
|
||||
ZC_INTERRUPT_TYPES = {
|
||||
"RISING": gpio_ns.INTERRUPT_RISING_EDGE,
|
||||
|
||||
@@ -46,11 +46,7 @@ ATTENUATION_MODES = {
|
||||
|
||||
sampling_mode = adc_ns.enum("SamplingMode", is_class=True)
|
||||
|
||||
SAMPLING_MODES = {
|
||||
"avg": sampling_mode.AVG,
|
||||
"min": sampling_mode.MIN,
|
||||
"max": sampling_mode.MAX,
|
||||
}
|
||||
SAMPLING_MODES = sampling_mode.options("avg", "min", "max")
|
||||
|
||||
adc_unit_t = cg.global_ns.enum("adc_unit_t", is_class=True)
|
||||
|
||||
|
||||
@@ -11,12 +11,6 @@
|
||||
|
||||
namespace esphome::ade7880 {
|
||||
|
||||
// adapted from https://stackoverflow.com/a/55912127/1886371
|
||||
template<size_t Bits, typename T> inline T sign_extend(const T &v) noexcept {
|
||||
using S = struct { signed Val : Bits; };
|
||||
return reinterpret_cast<const S *>(&v)->Val;
|
||||
}
|
||||
|
||||
// Register types
|
||||
// unsigned 8-bit (uint8_t)
|
||||
// signed 10-bit - 16-bit ZP on wire (int16_t, needs sign extension)
|
||||
@@ -49,7 +43,7 @@ uint16_t ADE7880::read_u16_register16_(uint16_t a_register) {
|
||||
|
||||
int32_t ADE7880::read_s24zp_register16_(uint16_t a_register) {
|
||||
// s24zp means 24 bit signed value in the lower 24 bits of a 32-bit register
|
||||
int32_t in;
|
||||
uint32_t in;
|
||||
this->read_register16(a_register, reinterpret_cast<uint8_t *>(&in), sizeof(in));
|
||||
return sign_extend<24>(convert_big_endian(in));
|
||||
}
|
||||
|
||||
@@ -84,11 +84,9 @@ automation.register_apply_action(
|
||||
)
|
||||
|
||||
AGS10SetZeroPointActionMode = ags10_ns.enum("AGS10SetZeroPointActionMode")
|
||||
AGS10_SET_ZERO_POINT_ACTION_MODE = {
|
||||
"FACTORY_DEFAULT": AGS10SetZeroPointActionMode.FACTORY_DEFAULT,
|
||||
"CURRENT_VALUE": AGS10SetZeroPointActionMode.CURRENT_VALUE,
|
||||
"CUSTOM_VALUE": AGS10SetZeroPointActionMode.CUSTOM_VALUE,
|
||||
}
|
||||
AGS10_SET_ZERO_POINT_ACTION_MODE = AGS10SetZeroPointActionMode.options(
|
||||
"FACTORY_DEFAULT", "CURRENT_VALUE", "CUSTOM_VALUE"
|
||||
)
|
||||
|
||||
AGS10_SET_ZERO_POINT_SCHEMA = cv.Schema(
|
||||
{
|
||||
|
||||
@@ -20,10 +20,7 @@ aht10_ns = cg.esphome_ns.namespace("aht10")
|
||||
AHT10Component = aht10_ns.class_("AHT10Component", cg.PollingComponent, i2c.I2CDevice)
|
||||
|
||||
AHT10Variant = aht10_ns.enum("AHT10Variant")
|
||||
AHT10_VARIANTS = {
|
||||
"AHT10": AHT10Variant.AHT10,
|
||||
"AHT20": AHT10Variant.AHT20,
|
||||
}
|
||||
AHT10_VARIANTS = AHT10Variant.options("AHT10", "AHT20")
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -29,10 +29,7 @@ AirthingsWavePlus = airthings_wave_plus_ns.class_(
|
||||
|
||||
CONF_DEVICE_TYPE = "device_type"
|
||||
WaveDeviceType = airthings_wave_plus_ns.enum("WaveDeviceType")
|
||||
DEVICE_TYPES = {
|
||||
"WAVE_PLUS": WaveDeviceType.WAVE_PLUS,
|
||||
"WAVE_GEN2": WaveDeviceType.WAVE_GEN2,
|
||||
}
|
||||
DEVICE_TYPES = WaveDeviceType.options("WAVE_PLUS", "WAVE_GEN2")
|
||||
|
||||
|
||||
def validate_wave_gen2_config(config: ConfigType) -> ConfigType:
|
||||
|
||||
@@ -30,10 +30,7 @@ CONF_END_POSITION = "end_position"
|
||||
CONF_OUT_OF_RANGE_MODE = "out_of_range_mode"
|
||||
|
||||
OutOfRangeMode = as5600_ns.enum("OutRangeMode")
|
||||
OUT_OF_RANGE_MODES = {
|
||||
"MIN_MAX": OutOfRangeMode.OUT_RANGE_MODE_MIN_MAX,
|
||||
"NAN": OutOfRangeMode.OUT_RANGE_MODE_NAN,
|
||||
}
|
||||
OUT_OF_RANGE_MODES = OutOfRangeMode.options("MIN_MAX", "NAN", prefix="OUT_RANGE_MODE_")
|
||||
|
||||
|
||||
CONF_AS5600_ID = "as5600_id"
|
||||
|
||||
@@ -55,12 +55,9 @@ GAINS_41 = {
|
||||
GAINS_43 = {**GAINS_41, "X1024": Gain.GAIN_1024X, "X2048": Gain.GAIN_2048X}
|
||||
|
||||
Normalization = as734x_ns.enum("Normalization", True)
|
||||
NORMALIZATIONS = {
|
||||
"NONE": Normalization.NORMALIZATION_NONE,
|
||||
"ALL": Normalization.NORMALIZATION_ALL,
|
||||
"BANDS": Normalization.NORMALIZATION_BANDS,
|
||||
"CLEAR": Normalization.NORMALIZATION_CLEAR,
|
||||
}
|
||||
NORMALIZATIONS = Normalization.options(
|
||||
"NONE", "ALL", "BANDS", "CLEAR", prefix="NORMALIZATION_"
|
||||
)
|
||||
|
||||
# Per-channel correction for the golden device, measured by the manufacturer.
|
||||
DEFAULT_CHANNEL_CORRECTION_43 = [
|
||||
|
||||
@@ -4,13 +4,14 @@ import esphome.config_validation as cv
|
||||
from esphome.const import DEVICE_CLASS_SWITCH, ICON_WIFI
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import CONF_AT581X_ID, AT581XComponent
|
||||
from .. import CONF_AT581X_ID, AT581XComponent, at581x_ns
|
||||
|
||||
DEPENDENCIES = ["at581x"]
|
||||
|
||||
RFSwitch = at581x_ns.class_("RFSwitch", switch.Switch)
|
||||
|
||||
CONFIG_SCHEMA = switch.switch_schema(
|
||||
switch.ApplySwitch,
|
||||
RFSwitch,
|
||||
device_class=DEVICE_CLASS_SWITCH,
|
||||
icon=ICON_WIFI,
|
||||
).extend(
|
||||
@@ -23,7 +24,7 @@ CONFIG_SCHEMA = switch.switch_schema(
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
hub = await cg.get_variable(config[CONF_AT581X_ID])
|
||||
await switch.sub_switches(config, parent=hub).create(
|
||||
config, hub.set_rf_power_switch, apply="set_rf_mode(state)", publish="before"
|
||||
)
|
||||
at581x_component = await cg.get_variable(config[CONF_AT581X_ID])
|
||||
s = await switch.new_switch(config)
|
||||
await cg.register_parented(s, config[CONF_AT581X_ID])
|
||||
cg.add(at581x_component.set_rf_power_switch(s))
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "rf_switch.h"
|
||||
|
||||
namespace esphome::at581x {
|
||||
|
||||
void RFSwitch::write_state(bool state) {
|
||||
this->publish_state(state);
|
||||
this->parent_->set_rf_mode(state);
|
||||
}
|
||||
|
||||
} // namespace esphome::at581x
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/switch/switch.h"
|
||||
#include "../at581x.h"
|
||||
|
||||
namespace esphome::at581x {
|
||||
|
||||
class RFSwitch final : public switch_::Switch, public Parented<AT581XComponent> {
|
||||
protected:
|
||||
void write_state(bool state) override;
|
||||
};
|
||||
|
||||
} // namespace esphome::at581x
|
||||
@@ -27,13 +27,7 @@ audio_ns = cg.esphome_ns.namespace("audio")
|
||||
|
||||
AudioFile = audio_ns.struct("AudioFile")
|
||||
AudioFileType = audio_ns.enum("AudioFileType", is_class=True)
|
||||
AUDIO_FILE_TYPE_ENUM = {
|
||||
"NONE": AudioFileType.NONE,
|
||||
"WAV": AudioFileType.WAV,
|
||||
"MP3": AudioFileType.MP3,
|
||||
"FLAC": AudioFileType.FLAC,
|
||||
"OPUS": AudioFileType.OPUS,
|
||||
}
|
||||
AUDIO_FILE_TYPE_ENUM = AudioFileType.options("NONE", "WAV", "MP3", "FLAC", "OPUS")
|
||||
|
||||
MEMORY_PSRAM = "psram"
|
||||
MEMORY_INTERNAL = "internal"
|
||||
|
||||
@@ -12,14 +12,10 @@ DEPENDENCIES = ["bedjet"]
|
||||
BedJetClimate = bedjet_ns.class_("BedJetClimate", climate.Climate, cg.PollingComponent)
|
||||
BedjetHeatMode = bedjet_ns.enum("BedjetHeatMode")
|
||||
BedjetTemperatureSource = bedjet_ns.enum("BedjetTemperatureSource")
|
||||
BEDJET_HEAT_MODES = {
|
||||
"heat": BedjetHeatMode.HEAT_MODE_HEAT,
|
||||
"extended": BedjetHeatMode.HEAT_MODE_EXTENDED,
|
||||
}
|
||||
BEDJET_TEMPERATURE_SOURCES = {
|
||||
"outlet": BedjetTemperatureSource.TEMPERATURE_SOURCE_OUTLET,
|
||||
"ambient": BedjetTemperatureSource.TEMPERATURE_SOURCE_AMBIENT,
|
||||
}
|
||||
BEDJET_HEAT_MODES = BedjetHeatMode.options("heat", "extended", prefix="HEAT_MODE_")
|
||||
BEDJET_TEMPERATURE_SOURCES = BedjetTemperatureSource.options(
|
||||
"outlet", "ambient", prefix="TEMPERATURE_SOURCE_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
climate.climate_schema(BedJetClimate)
|
||||
|
||||
@@ -25,11 +25,7 @@ BH1745Component = bh1745_ns.class_(
|
||||
)
|
||||
|
||||
AdcGain = bh1745_ns.enum("AdcGain", is_class=True)
|
||||
ADC_GAINS = {
|
||||
"1X": AdcGain.ADC_GAIN_1X,
|
||||
"2X": AdcGain.ADC_GAIN_2X,
|
||||
"16X": AdcGain.ADC_GAIN_16X,
|
||||
}
|
||||
ADC_GAINS = AdcGain.options("1X", "2X", "16X", prefix="ADC_GAIN_")
|
||||
|
||||
MeasurementTime = bh1745_ns.enum("MeasurementTime", is_class=True)
|
||||
MEASUREMENT_TIMES = {
|
||||
|
||||
@@ -35,10 +35,9 @@ CONF_ENERGY_TOTAL = "energy_total"
|
||||
bl0939_ns = cg.esphome_ns.namespace("bl0939")
|
||||
BL0939 = bl0939_ns.class_("BL0939", cg.PollingComponent, uart.UARTDevice)
|
||||
BL0939Mode = bl0939_ns.enum("BL0939Mode", is_class=True)
|
||||
MODE_OPTIONS = {
|
||||
"direct": BL0939Mode.BL0939_MODE_DIRECT,
|
||||
"current_transformer": BL0939Mode.BL0939_MODE_CURRENT_TRANSFORMER,
|
||||
}
|
||||
MODE_OPTIONS = BL0939Mode.options(
|
||||
"direct", "current_transformer", prefix="BL0939_MODE_"
|
||||
)
|
||||
# Must match the mode_ member initializer in bl0939.h; set_mode() is skipped
|
||||
# when the config already equals it.
|
||||
DEFAULT_MODE = "direct"
|
||||
|
||||
@@ -24,23 +24,14 @@ DOMAIN = "bme280_base"
|
||||
|
||||
bme280_ns = cg.esphome_ns.namespace("bme280_base")
|
||||
BME280Oversampling = bme280_ns.enum("BME280Oversampling")
|
||||
OVERSAMPLING_OPTIONS = {
|
||||
"NONE": BME280Oversampling.BME280_OVERSAMPLING_NONE,
|
||||
"1X": BME280Oversampling.BME280_OVERSAMPLING_1X,
|
||||
"2X": BME280Oversampling.BME280_OVERSAMPLING_2X,
|
||||
"4X": BME280Oversampling.BME280_OVERSAMPLING_4X,
|
||||
"8X": BME280Oversampling.BME280_OVERSAMPLING_8X,
|
||||
"16X": BME280Oversampling.BME280_OVERSAMPLING_16X,
|
||||
}
|
||||
OVERSAMPLING_OPTIONS = BME280Oversampling.options(
|
||||
"NONE", "1X", "2X", "4X", "8X", "16X", prefix="BME280_OVERSAMPLING_"
|
||||
)
|
||||
|
||||
BME280IIRFilter = bme280_ns.enum("BME280IIRFilter")
|
||||
IIR_FILTER_OPTIONS = {
|
||||
"OFF": BME280IIRFilter.BME280_IIR_FILTER_OFF,
|
||||
"2X": BME280IIRFilter.BME280_IIR_FILTER_2X,
|
||||
"4X": BME280IIRFilter.BME280_IIR_FILTER_4X,
|
||||
"8X": BME280IIRFilter.BME280_IIR_FILTER_8X,
|
||||
"16X": BME280IIRFilter.BME280_IIR_FILTER_16X,
|
||||
}
|
||||
IIR_FILTER_OPTIONS = BME280IIRFilter.options(
|
||||
"OFF", "2X", "4X", "8X", "16X", prefix="BME280_IIR_FILTER_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA_BASE = cv.Schema(
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "bme280_base.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <esphome/components/sensor/sensor.h>
|
||||
#include <esphome/core/component.h>
|
||||
@@ -144,11 +145,10 @@ void BME280Component::setup() {
|
||||
this->calibration_.h1 = read_u8_(BME280_REGISTER_DIG_H1);
|
||||
this->calibration_.h2 = read_s16_le_(BME280_REGISTER_DIG_H2);
|
||||
this->calibration_.h3 = read_u8_(BME280_REGISTER_DIG_H3);
|
||||
// h4 and h5 are signed 12-bit values; shift left then arithmetic right shift to sign-extend
|
||||
int16_t h4_raw = read_u8_(BME280_REGISTER_DIG_H4) << 4 | (read_u8_(BME280_REGISTER_DIG_H4 + 1) & 0x0F);
|
||||
this->calibration_.h4 = static_cast<int16_t>(h4_raw << 4) >> 4;
|
||||
int16_t h5_raw = read_u8_(BME280_REGISTER_DIG_H5 + 1) << 4 | (read_u8_(BME280_REGISTER_DIG_H5) >> 4);
|
||||
this->calibration_.h5 = static_cast<int16_t>(h5_raw << 4) >> 4;
|
||||
this->calibration_.h4 =
|
||||
sign_extend<12>(read_u8_(BME280_REGISTER_DIG_H4) << 4 | (read_u8_(BME280_REGISTER_DIG_H4 + 1) & 0x0F));
|
||||
this->calibration_.h5 =
|
||||
sign_extend<12>(read_u8_(BME280_REGISTER_DIG_H5 + 1) << 4 | (read_u8_(BME280_REGISTER_DIG_H5) >> 4));
|
||||
this->calibration_.h6 = read_u8_(BME280_REGISTER_DIG_H6);
|
||||
|
||||
uint8_t humid_control_val = 0;
|
||||
|
||||
@@ -28,26 +28,14 @@ DEPENDENCIES = ["i2c"]
|
||||
|
||||
bme680_ns = cg.esphome_ns.namespace("bme680")
|
||||
BME680Oversampling = bme680_ns.enum("BME680Oversampling")
|
||||
OVERSAMPLING_OPTIONS = {
|
||||
"NONE": BME680Oversampling.BME680_OVERSAMPLING_NONE,
|
||||
"1X": BME680Oversampling.BME680_OVERSAMPLING_1X,
|
||||
"2X": BME680Oversampling.BME680_OVERSAMPLING_2X,
|
||||
"4X": BME680Oversampling.BME680_OVERSAMPLING_4X,
|
||||
"8X": BME680Oversampling.BME680_OVERSAMPLING_8X,
|
||||
"16X": BME680Oversampling.BME680_OVERSAMPLING_16X,
|
||||
}
|
||||
OVERSAMPLING_OPTIONS = BME680Oversampling.options(
|
||||
"NONE", "1X", "2X", "4X", "8X", "16X", prefix="BME680_OVERSAMPLING_"
|
||||
)
|
||||
|
||||
BME680IIRFilter = bme680_ns.enum("BME680IIRFilter")
|
||||
IIR_FILTER_OPTIONS = {
|
||||
"OFF": BME680IIRFilter.BME680_IIR_FILTER_OFF,
|
||||
"1X": BME680IIRFilter.BME680_IIR_FILTER_1X,
|
||||
"3X": BME680IIRFilter.BME680_IIR_FILTER_3X,
|
||||
"7X": BME680IIRFilter.BME680_IIR_FILTER_7X,
|
||||
"15X": BME680IIRFilter.BME680_IIR_FILTER_15X,
|
||||
"31X": BME680IIRFilter.BME680_IIR_FILTER_31X,
|
||||
"63X": BME680IIRFilter.BME680_IIR_FILTER_63X,
|
||||
"127X": BME680IIRFilter.BME680_IIR_FILTER_127X,
|
||||
}
|
||||
IIR_FILTER_OPTIONS = BME680IIRFilter.options(
|
||||
"OFF", "1X", "3X", "7X", "15X", "31X", "63X", "127X", prefix="BME680_IIR_FILTER_"
|
||||
)
|
||||
|
||||
BME680Component = bme680_ns.class_(
|
||||
"BME680Component", cg.PollingComponent, i2c.I2CDevice
|
||||
|
||||
@@ -19,10 +19,7 @@ CONF_SUPPLY_VOLTAGE = "supply_voltage"
|
||||
bme680_bsec_ns = cg.esphome_ns.namespace("bme680_bsec")
|
||||
|
||||
IAQMode = bme680_bsec_ns.enum("IAQMode")
|
||||
IAQ_MODE_OPTIONS = {
|
||||
"STATIC": IAQMode.IAQ_MODE_STATIC,
|
||||
"MOBILE": IAQMode.IAQ_MODE_MOBILE,
|
||||
}
|
||||
IAQ_MODE_OPTIONS = IAQMode.options("STATIC", "MOBILE", prefix="IAQ_MODE_")
|
||||
|
||||
SupplyVoltage = bme680_bsec_ns.enum("SupplyVoltage")
|
||||
SUPPLY_VOLTAGE_OPTIONS = {
|
||||
@@ -31,10 +28,7 @@ SUPPLY_VOLTAGE_OPTIONS = {
|
||||
}
|
||||
|
||||
SampleRate = bme680_bsec_ns.enum("SampleRate")
|
||||
SAMPLE_RATE_OPTIONS = {
|
||||
"LP": SampleRate.SAMPLE_RATE_LP,
|
||||
"ULP": SampleRate.SAMPLE_RATE_ULP,
|
||||
}
|
||||
SAMPLE_RATE_OPTIONS = SampleRate.options("LP", "ULP", prefix="SAMPLE_RATE_")
|
||||
|
||||
BME680BSECComponent = bme680_bsec_ns.class_(
|
||||
"BME680BSECComponent", cg.Component, i2c.I2CDevice
|
||||
|
||||
@@ -36,28 +36,18 @@ BME68xBSEC2Component = bme68x_bsec2_ns.class_("BME68xBSEC2Component", cg.Compone
|
||||
MODEL_OPTIONS = ["bme680", "bme688"]
|
||||
|
||||
AlgorithmOutput = bme68x_bsec2_ns.enum("AlgorithmOutput")
|
||||
ALGORITHM_OUTPUT_OPTIONS = {
|
||||
"classification": AlgorithmOutput.ALGORITHM_OUTPUT_CLASSIFICATION,
|
||||
"regression": AlgorithmOutput.ALGORITHM_OUTPUT_REGRESSION,
|
||||
}
|
||||
ALGORITHM_OUTPUT_OPTIONS = AlgorithmOutput.options(
|
||||
"classification", "regression", prefix="ALGORITHM_OUTPUT_"
|
||||
)
|
||||
|
||||
OperatingAge = bme68x_bsec2_ns.enum("OperatingAge")
|
||||
OPERATING_AGE_OPTIONS = {
|
||||
"4d": OperatingAge.OPERATING_AGE_4D,
|
||||
"28d": OperatingAge.OPERATING_AGE_28D,
|
||||
}
|
||||
OPERATING_AGE_OPTIONS = OperatingAge.options("4d", "28d", prefix="OPERATING_AGE_")
|
||||
|
||||
SampleRate = bme68x_bsec2_ns.enum("SampleRate")
|
||||
SAMPLE_RATE_OPTIONS = {
|
||||
"LP": SampleRate.SAMPLE_RATE_LP,
|
||||
"ULP": SampleRate.SAMPLE_RATE_ULP,
|
||||
}
|
||||
SAMPLE_RATE_OPTIONS = SampleRate.options("LP", "ULP", prefix="SAMPLE_RATE_")
|
||||
|
||||
Voltage = bme68x_bsec2_ns.enum("Voltage")
|
||||
VOLTAGE_OPTIONS = {
|
||||
"1.8V": Voltage.VOLTAGE_1_8V,
|
||||
"3.3V": Voltage.VOLTAGE_3_3V,
|
||||
}
|
||||
VOLTAGE_OPTIONS = Voltage.options("1.8V", "3.3V", prefix="VOLTAGE_")
|
||||
|
||||
ALGORITHM_OUTPUT_FILE_NAME = {
|
||||
"classification": "sel",
|
||||
|
||||
@@ -20,12 +20,9 @@ CONF_AUX_DEVICE = "aux_device"
|
||||
# Enum proxies (must match the C++ enum values exactly)
|
||||
BMI270AuxDevice = bmi270_ns.enum("BMI270AuxDevice")
|
||||
BMI270AccelRange = bmi270_ns.enum("BMI270AccelRange")
|
||||
ACCEL_RANGE_OPTIONS = {
|
||||
"2G": BMI270AccelRange.BMI270_ACCEL_RANGE_2G,
|
||||
"4G": BMI270AccelRange.BMI270_ACCEL_RANGE_4G,
|
||||
"8G": BMI270AccelRange.BMI270_ACCEL_RANGE_8G,
|
||||
"16G": BMI270AccelRange.BMI270_ACCEL_RANGE_16G,
|
||||
}
|
||||
ACCEL_RANGE_OPTIONS = BMI270AccelRange.options(
|
||||
"2G", "4G", "8G", "16G", prefix="BMI270_ACCEL_RANGE_"
|
||||
)
|
||||
|
||||
BMI270GyroRange = bmi270_ns.enum("BMI270GyroRange")
|
||||
GYRO_RANGE_OPTIONS = {
|
||||
|
||||
@@ -21,23 +21,14 @@ DOMAIN = "bmp280_base"
|
||||
|
||||
bmp280_ns = cg.esphome_ns.namespace("bmp280_base")
|
||||
BMP280Oversampling = bmp280_ns.enum("BMP280Oversampling")
|
||||
OVERSAMPLING_OPTIONS = {
|
||||
"NONE": BMP280Oversampling.BMP280_OVERSAMPLING_NONE,
|
||||
"1X": BMP280Oversampling.BMP280_OVERSAMPLING_1X,
|
||||
"2X": BMP280Oversampling.BMP280_OVERSAMPLING_2X,
|
||||
"4X": BMP280Oversampling.BMP280_OVERSAMPLING_4X,
|
||||
"8X": BMP280Oversampling.BMP280_OVERSAMPLING_8X,
|
||||
"16X": BMP280Oversampling.BMP280_OVERSAMPLING_16X,
|
||||
}
|
||||
OVERSAMPLING_OPTIONS = BMP280Oversampling.options(
|
||||
"NONE", "1X", "2X", "4X", "8X", "16X", prefix="BMP280_OVERSAMPLING_"
|
||||
)
|
||||
|
||||
BMP280IIRFilter = bmp280_ns.enum("BMP280IIRFilter")
|
||||
IIR_FILTER_OPTIONS = {
|
||||
"OFF": BMP280IIRFilter.BMP280_IIR_FILTER_OFF,
|
||||
"2X": BMP280IIRFilter.BMP280_IIR_FILTER_2X,
|
||||
"4X": BMP280IIRFilter.BMP280_IIR_FILTER_4X,
|
||||
"8X": BMP280IIRFilter.BMP280_IIR_FILTER_8X,
|
||||
"16X": BMP280IIRFilter.BMP280_IIR_FILTER_16X,
|
||||
}
|
||||
IIR_FILTER_OPTIONS = BMP280IIRFilter.options(
|
||||
"OFF", "2X", "4X", "8X", "16X", prefix="BMP280_IIR_FILTER_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA_BASE = cv.Schema(
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_BUTTON
|
||||
|
||||
#include "bq25186.h"
|
||||
#include "esphome/components/button/button.h"
|
||||
|
||||
namespace esphome::bq25186 {
|
||||
|
||||
/// Writes one SHIP_RST field when pressed
|
||||
class BQ25186Button final : public button::Button, public Parented<BQ25186Component> {
|
||||
public:
|
||||
BQ25186Button(uint8_t mask, uint8_t value) : mask_(mask), value_(value) {}
|
||||
|
||||
protected:
|
||||
void press_action() override { this->parent_->write_ship_rst(this->mask_, this->value_); }
|
||||
|
||||
const uint8_t mask_;
|
||||
const uint8_t value_;
|
||||
};
|
||||
|
||||
} // namespace esphome::bq25186
|
||||
|
||||
#endif // USE_BUTTON
|
||||
@@ -1,3 +1,4 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import button
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
@@ -9,10 +10,11 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import BQ25186_CHILD_SCHEMA, CONF_BQ25186_ID
|
||||
from . import BQ25186_CHILD_SCHEMA, CONF_BQ25186_ID, bq25186_ns
|
||||
|
||||
DEPENDENCIES = ["bq25186"]
|
||||
|
||||
BQ25186Button = bq25186_ns.class_("BQ25186Button", button.Button)
|
||||
|
||||
# SHIP_RST: bit 7 is the software reset, bits 6:5 the shutdown, ship and hardware reset codes
|
||||
SOFTWARE_RESET_MASK = 0x80
|
||||
@@ -31,7 +33,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
BQ25186_CHILD_SCHEMA.extend(
|
||||
{
|
||||
cv.Optional(key): button.button_schema(
|
||||
button.ApplyButton,
|
||||
BQ25186Button,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
icon=icon,
|
||||
device_class=device_class,
|
||||
@@ -44,6 +46,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
buttons = button.sub_buttons(config, parent=config[CONF_BQ25186_ID])
|
||||
for key, mask, value, _, _ in _BUTTONS:
|
||||
await buttons(key, None, apply=f"write_ship_rst({mask:#04x}, {value:#04x})")
|
||||
if (conf := config.get(key)) is not None:
|
||||
var = await button.new_button(conf, mask, value)
|
||||
await cg.register_parented(var, config[CONF_BQ25186_ID])
|
||||
@@ -18,7 +18,6 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.core import CORE, ID, CoroPriority, coroutine_with_priority
|
||||
from esphome.core.entity_helpers import (
|
||||
ApplyEntity,
|
||||
SubEntities,
|
||||
entity_duplicate_validator,
|
||||
queue_entity_register,
|
||||
@@ -42,7 +41,6 @@ DEVICE_CLASSES = [
|
||||
button_ns = cg.esphome_ns.namespace("button")
|
||||
Button = button_ns.class_("Button", cg.EntityBase)
|
||||
ButtonPtr = Button.operator("ptr")
|
||||
ApplyButton = button_ns.class_("ApplyButton", Button)
|
||||
|
||||
validate_device_class = cv.one_of(*DEVICE_CLASSES, lower=True, space="_")
|
||||
|
||||
@@ -118,14 +116,11 @@ async def new_button(config: ConfigType, *args: SafeExpType) -> MockObj:
|
||||
return var
|
||||
|
||||
|
||||
APPLY_ENTITY = ApplyEntity(ApplyButton, ((ButtonPtr, "entity"),))
|
||||
|
||||
|
||||
def sub_buttons(
|
||||
config: ConfigType, *, parent: MockObj | ID | None = None
|
||||
) -> SubEntities:
|
||||
"""Return a SubEntities bound to new_button; ``apply`` statements can use ``entity``."""
|
||||
return SubEntities(new_button, config, parent, APPLY_ENTITY)
|
||||
"""Return a SubEntities bound to new_button."""
|
||||
return SubEntities(new_button, config, parent)
|
||||
|
||||
|
||||
BUTTON_PRESS_SCHEMA = maybe_simple_id(
|
||||
|
||||
@@ -46,14 +46,4 @@ class Button : public EntityBase {
|
||||
LazyCallbackManager<void()> press_callback_{};
|
||||
};
|
||||
|
||||
/// Calls the codegen-generated Fn(this) on a press; the hub and any publish are baked into Fn.
|
||||
template<auto Fn> class ApplyButton final : public Button {
|
||||
public:
|
||||
// Not "= default": placement new would zero-fill .bss that is already zero.
|
||||
ApplyButton() {}
|
||||
|
||||
protected:
|
||||
void press_action() override { Fn(this); }
|
||||
};
|
||||
|
||||
} // namespace esphome::button
|
||||
@@ -56,29 +56,30 @@ CanbusTrigger = canbus_ns.class_(
|
||||
)
|
||||
CanSpeed = canbus_ns.enum("CAN_SPEED")
|
||||
|
||||
CAN_SPEEDS = {
|
||||
"1KBPS": CanSpeed.CAN_1KBPS,
|
||||
"5KBPS": CanSpeed.CAN_5KBPS,
|
||||
"10KBPS": CanSpeed.CAN_10KBPS,
|
||||
"12K5BPS": CanSpeed.CAN_12K5BPS,
|
||||
"16KBPS": CanSpeed.CAN_16KBPS,
|
||||
"20KBPS": CanSpeed.CAN_20KBPS,
|
||||
"25KBPS": CanSpeed.CAN_25KBPS,
|
||||
"31K25BPS": CanSpeed.CAN_31K25BPS,
|
||||
"33KBPS": CanSpeed.CAN_33KBPS,
|
||||
"40KBPS": CanSpeed.CAN_40KBPS,
|
||||
"50KBPS": CanSpeed.CAN_50KBPS,
|
||||
"80KBPS": CanSpeed.CAN_80KBPS,
|
||||
"83K3BPS": CanSpeed.CAN_83K3BPS,
|
||||
"95KBPS": CanSpeed.CAN_95KBPS,
|
||||
"100KBPS": CanSpeed.CAN_100KBPS,
|
||||
"125KBPS": CanSpeed.CAN_125KBPS,
|
||||
"200KBPS": CanSpeed.CAN_200KBPS,
|
||||
"250KBPS": CanSpeed.CAN_250KBPS,
|
||||
"500KBPS": CanSpeed.CAN_500KBPS,
|
||||
"800KBPS": CanSpeed.CAN_800KBPS,
|
||||
"1000KBPS": CanSpeed.CAN_1000KBPS,
|
||||
}
|
||||
CAN_SPEEDS = CanSpeed.options(
|
||||
"1KBPS",
|
||||
"5KBPS",
|
||||
"10KBPS",
|
||||
"12K5BPS",
|
||||
"16KBPS",
|
||||
"20KBPS",
|
||||
"25KBPS",
|
||||
"31K25BPS",
|
||||
"33KBPS",
|
||||
"40KBPS",
|
||||
"50KBPS",
|
||||
"80KBPS",
|
||||
"83K3BPS",
|
||||
"95KBPS",
|
||||
"100KBPS",
|
||||
"125KBPS",
|
||||
"200KBPS",
|
||||
"250KBPS",
|
||||
"500KBPS",
|
||||
"800KBPS",
|
||||
"1000KBPS",
|
||||
prefix="CAN_",
|
||||
)
|
||||
|
||||
|
||||
def get_rate(value: str) -> int:
|
||||
|
||||
@@ -67,41 +67,30 @@ CONF_GDO0_PIN = "gdo0_pin"
|
||||
|
||||
# Enums
|
||||
SyncMode = ns.enum("SyncMode", True)
|
||||
SYNC_MODE = {
|
||||
"None": SyncMode.SYNC_MODE_NONE,
|
||||
"15/16": SyncMode.SYNC_MODE_15_16,
|
||||
"16/16": SyncMode.SYNC_MODE_16_16,
|
||||
"30/32": SyncMode.SYNC_MODE_30_32,
|
||||
}
|
||||
SYNC_MODE = SyncMode.options("None", "15/16", "16/16", "30/32", prefix="SYNC_MODE_")
|
||||
|
||||
Modulation = ns.enum("Modulation", True)
|
||||
MODULATION = {
|
||||
"2-FSK": Modulation.MODULATION_2_FSK,
|
||||
"GFSK": Modulation.MODULATION_GFSK,
|
||||
"ASK/OOK": Modulation.MODULATION_ASK_OOK,
|
||||
"4-FSK": Modulation.MODULATION_4_FSK,
|
||||
"MSK": Modulation.MODULATION_MSK,
|
||||
}
|
||||
MODULATION = Modulation.options(
|
||||
"2-FSK", "GFSK", "ASK/OOK", "4-FSK", "MSK", prefix="MODULATION_"
|
||||
)
|
||||
|
||||
RxAttenuation = ns.enum("RxAttenuation", True)
|
||||
RX_ATTENUATION = {
|
||||
"0dB": RxAttenuation.RX_ATTENUATION_0DB,
|
||||
"6dB": RxAttenuation.RX_ATTENUATION_6DB,
|
||||
"12dB": RxAttenuation.RX_ATTENUATION_12DB,
|
||||
"18dB": RxAttenuation.RX_ATTENUATION_18DB,
|
||||
}
|
||||
RX_ATTENUATION = RxAttenuation.options(
|
||||
"0dB", "6dB", "12dB", "18dB", prefix="RX_ATTENUATION_"
|
||||
)
|
||||
|
||||
MagnTarget = ns.enum("MagnTarget", True)
|
||||
MAGN_TARGET = {
|
||||
"24dB": MagnTarget.MAGN_TARGET_24DB,
|
||||
"27dB": MagnTarget.MAGN_TARGET_27DB,
|
||||
"30dB": MagnTarget.MAGN_TARGET_30DB,
|
||||
"33dB": MagnTarget.MAGN_TARGET_33DB,
|
||||
"36dB": MagnTarget.MAGN_TARGET_36DB,
|
||||
"38dB": MagnTarget.MAGN_TARGET_38DB,
|
||||
"40dB": MagnTarget.MAGN_TARGET_40DB,
|
||||
"42dB": MagnTarget.MAGN_TARGET_42DB,
|
||||
}
|
||||
MAGN_TARGET = MagnTarget.options(
|
||||
"24dB",
|
||||
"27dB",
|
||||
"30dB",
|
||||
"33dB",
|
||||
"36dB",
|
||||
"38dB",
|
||||
"40dB",
|
||||
"42dB",
|
||||
prefix="MAGN_TARGET_",
|
||||
)
|
||||
|
||||
MaxLnaGain = ns.enum("MaxLnaGain", True)
|
||||
MAX_LNA_GAIN = {
|
||||
@@ -140,20 +129,14 @@ FILTER_LENGTH_FSK_MSK = {
|
||||
}
|
||||
|
||||
FilterLengthAskOok = ns.enum("FilterLengthAskOok", True)
|
||||
FILTER_LENGTH_ASK_OOK = {
|
||||
"4dB": FilterLengthAskOok.FILTER_LENGTH_4DB,
|
||||
"8dB": FilterLengthAskOok.FILTER_LENGTH_8DB,
|
||||
"12dB": FilterLengthAskOok.FILTER_LENGTH_12DB,
|
||||
"16dB": FilterLengthAskOok.FILTER_LENGTH_16DB,
|
||||
}
|
||||
FILTER_LENGTH_ASK_OOK = FilterLengthAskOok.options(
|
||||
"4dB", "8dB", "12dB", "16dB", prefix="FILTER_LENGTH_"
|
||||
)
|
||||
|
||||
Freeze = ns.enum("Freeze", True)
|
||||
FREEZE = {
|
||||
"Default": Freeze.FREEZE_DEFAULT,
|
||||
"On Sync": Freeze.FREEZE_ON_SYNC,
|
||||
"Analog Only": Freeze.FREEZE_ANALOG_ONLY,
|
||||
"Analog And Digital": Freeze.FREEZE_ANALOG_AND_DIGITAL,
|
||||
}
|
||||
FREEZE = Freeze.options(
|
||||
"Default", "On Sync", "Analog Only", "Analog And Digital", prefix="FREEZE_"
|
||||
)
|
||||
|
||||
WaitTime = ns.enum("WaitTime", True)
|
||||
WAIT_TIME = {
|
||||
@@ -164,34 +147,16 @@ WAIT_TIME = {
|
||||
}
|
||||
|
||||
HystLevel = ns.enum("HystLevel", True)
|
||||
HYST_LEVEL = {
|
||||
"None": HystLevel.HYST_LEVEL_NONE,
|
||||
"Low": HystLevel.HYST_LEVEL_LOW,
|
||||
"Medium": HystLevel.HYST_LEVEL_MEDIUM,
|
||||
"High": HystLevel.HYST_LEVEL_HIGH,
|
||||
}
|
||||
HYST_LEVEL = HystLevel.options("None", "Low", "Medium", "High", prefix="HYST_LEVEL_")
|
||||
|
||||
FocLimit = ns.enum("FocLimit", True)
|
||||
FOC_LIMIT = {
|
||||
"Disabled": FocLimit.FOC_LIMIT_DISABLED,
|
||||
"BW/8": FocLimit.FOC_LIMIT_BW_8,
|
||||
"BW/4": FocLimit.FOC_LIMIT_BW_4,
|
||||
"BW/2": FocLimit.FOC_LIMIT_BW_2,
|
||||
}
|
||||
FOC_LIMIT = FocLimit.options("Disabled", "BW/8", "BW/4", "BW/2", prefix="FOC_LIMIT_")
|
||||
|
||||
FocPreK = ns.enum("FocPreK", True)
|
||||
FOC_PRE_K = {
|
||||
"K": FocPreK.FOC_PRE_K_K,
|
||||
"2K": FocPreK.FOC_PRE_K_2K,
|
||||
"3K": FocPreK.FOC_PRE_K_3K,
|
||||
"4K": FocPreK.FOC_PRE_K_4K,
|
||||
}
|
||||
FOC_PRE_K = FocPreK.options("K", "2K", "3K", "4K", prefix="FOC_PRE_K_")
|
||||
|
||||
FocPostK = ns.enum("FocPostK", True)
|
||||
FOC_POST_K = {
|
||||
"Same": FocPostK.FOC_POST_K_SAME,
|
||||
"K/2": FocPostK.FOC_POST_K_K_2,
|
||||
}
|
||||
FOC_POST_K = FocPostK.options("Same", "K/2", prefix="FOC_POST_K_")
|
||||
|
||||
BsLimit = ns.enum("BsLimit", True)
|
||||
BS_LIMIT = {
|
||||
@@ -202,32 +167,16 @@ BS_LIMIT = {
|
||||
}
|
||||
|
||||
BsPreKi = ns.enum("BsPreKi", True)
|
||||
BS_PRE_KI = {
|
||||
"KI": BsPreKi.BS_PRE_KI_KI,
|
||||
"2KI": BsPreKi.BS_PRE_KI_2KI,
|
||||
"3KI": BsPreKi.BS_PRE_KI_3KI,
|
||||
"4KI": BsPreKi.BS_PRE_KI_4KI,
|
||||
}
|
||||
BS_PRE_KI = BsPreKi.options("KI", "2KI", "3KI", "4KI", prefix="BS_PRE_KI_")
|
||||
|
||||
BsPreKp = ns.enum("BsPreKp", True)
|
||||
BS_PRE_KP = {
|
||||
"KP": BsPreKp.BS_PRE_KP_KP,
|
||||
"2KP": BsPreKp.BS_PRE_KP_2KP,
|
||||
"3KP": BsPreKp.BS_PRE_KP_3KP,
|
||||
"4KP": BsPreKp.BS_PRE_KP_4KP,
|
||||
}
|
||||
BS_PRE_KP = BsPreKp.options("KP", "2KP", "3KP", "4KP", prefix="BS_PRE_KP_")
|
||||
|
||||
BsPostKi = ns.enum("BsPostKi", True)
|
||||
BS_POST_KI = {
|
||||
"Same": BsPostKi.BS_POST_KI_SAME,
|
||||
"KI/2": BsPostKi.BS_POST_KI_KI_2,
|
||||
}
|
||||
BS_POST_KI = BsPostKi.options("Same", "KI/2", prefix="BS_POST_KI_")
|
||||
|
||||
BsPostKp = ns.enum("BsPostKp", True)
|
||||
BS_POST_KP = {
|
||||
"Same": BsPostKp.BS_POST_KP_SAME,
|
||||
"KP": BsPostKp.BS_POST_KP_KP,
|
||||
}
|
||||
BS_POST_KP = BsPostKp.options("Same", "KP", prefix="BS_POST_KP_")
|
||||
|
||||
# Optional settings to generate setter calls for
|
||||
CONFIG_MAP = {
|
||||
|
||||
@@ -69,67 +69,68 @@ ClimateCall = climate_ns.class_("ClimateCall")
|
||||
ClimateTraits = climate_ns.class_("ClimateTraits")
|
||||
|
||||
ClimateMode = climate_ns.enum("ClimateMode")
|
||||
CLIMATE_MODES = {
|
||||
"OFF": ClimateMode.CLIMATE_MODE_OFF,
|
||||
"HEAT_COOL": ClimateMode.CLIMATE_MODE_HEAT_COOL,
|
||||
"COOL": ClimateMode.CLIMATE_MODE_COOL,
|
||||
"HEAT": ClimateMode.CLIMATE_MODE_HEAT,
|
||||
"DRY": ClimateMode.CLIMATE_MODE_DRY,
|
||||
"FAN_ONLY": ClimateMode.CLIMATE_MODE_FAN_ONLY,
|
||||
"AUTO": ClimateMode.CLIMATE_MODE_AUTO,
|
||||
}
|
||||
CLIMATE_MODES = ClimateMode.options(
|
||||
"OFF",
|
||||
"HEAT_COOL",
|
||||
"COOL",
|
||||
"HEAT",
|
||||
"DRY",
|
||||
"FAN_ONLY",
|
||||
"AUTO",
|
||||
prefix="CLIMATE_MODE_",
|
||||
)
|
||||
validate_climate_mode = cv.enum(CLIMATE_MODES, upper=True)
|
||||
|
||||
ClimateFanMode = climate_ns.enum("ClimateFanMode")
|
||||
CLIMATE_FAN_MODES = {
|
||||
"ON": ClimateFanMode.CLIMATE_FAN_ON,
|
||||
"OFF": ClimateFanMode.CLIMATE_FAN_OFF,
|
||||
"AUTO": ClimateFanMode.CLIMATE_FAN_AUTO,
|
||||
"LOW": ClimateFanMode.CLIMATE_FAN_LOW,
|
||||
"MEDIUM": ClimateFanMode.CLIMATE_FAN_MEDIUM,
|
||||
"HIGH": ClimateFanMode.CLIMATE_FAN_HIGH,
|
||||
"MIDDLE": ClimateFanMode.CLIMATE_FAN_MIDDLE,
|
||||
"FOCUS": ClimateFanMode.CLIMATE_FAN_FOCUS,
|
||||
"DIFFUSE": ClimateFanMode.CLIMATE_FAN_DIFFUSE,
|
||||
"QUIET": ClimateFanMode.CLIMATE_FAN_QUIET,
|
||||
}
|
||||
CLIMATE_FAN_MODES = ClimateFanMode.options(
|
||||
"ON",
|
||||
"OFF",
|
||||
"AUTO",
|
||||
"LOW",
|
||||
"MEDIUM",
|
||||
"HIGH",
|
||||
"MIDDLE",
|
||||
"FOCUS",
|
||||
"DIFFUSE",
|
||||
"QUIET",
|
||||
prefix="CLIMATE_FAN_",
|
||||
)
|
||||
|
||||
validate_climate_fan_mode = cv.enum(CLIMATE_FAN_MODES, upper=True)
|
||||
|
||||
ClimatePreset = climate_ns.enum("ClimatePreset")
|
||||
CLIMATE_PRESETS = {
|
||||
"NONE": ClimatePreset.CLIMATE_PRESET_NONE,
|
||||
"ECO": ClimatePreset.CLIMATE_PRESET_ECO,
|
||||
"AWAY": ClimatePreset.CLIMATE_PRESET_AWAY,
|
||||
"BOOST": ClimatePreset.CLIMATE_PRESET_BOOST,
|
||||
"COMFORT": ClimatePreset.CLIMATE_PRESET_COMFORT,
|
||||
"HOME": ClimatePreset.CLIMATE_PRESET_HOME,
|
||||
"SLEEP": ClimatePreset.CLIMATE_PRESET_SLEEP,
|
||||
"ACTIVITY": ClimatePreset.CLIMATE_PRESET_ACTIVITY,
|
||||
}
|
||||
CLIMATE_PRESETS = ClimatePreset.options(
|
||||
"NONE",
|
||||
"ECO",
|
||||
"AWAY",
|
||||
"BOOST",
|
||||
"COMFORT",
|
||||
"HOME",
|
||||
"SLEEP",
|
||||
"ACTIVITY",
|
||||
prefix="CLIMATE_PRESET_",
|
||||
)
|
||||
|
||||
validate_climate_preset = cv.enum(CLIMATE_PRESETS, upper=True)
|
||||
|
||||
ClimateSwingMode = climate_ns.enum("ClimateSwingMode")
|
||||
CLIMATE_SWING_MODES = {
|
||||
"OFF": ClimateSwingMode.CLIMATE_SWING_OFF,
|
||||
"BOTH": ClimateSwingMode.CLIMATE_SWING_BOTH,
|
||||
"VERTICAL": ClimateSwingMode.CLIMATE_SWING_VERTICAL,
|
||||
"HORIZONTAL": ClimateSwingMode.CLIMATE_SWING_HORIZONTAL,
|
||||
}
|
||||
CLIMATE_SWING_MODES = ClimateSwingMode.options(
|
||||
"OFF", "BOTH", "VERTICAL", "HORIZONTAL", prefix="CLIMATE_SWING_"
|
||||
)
|
||||
|
||||
validate_climate_swing_mode = cv.enum(CLIMATE_SWING_MODES, upper=True)
|
||||
|
||||
ClimateAction = climate_ns.enum("ClimateAction")
|
||||
CLIMATE_ACTIONS = {
|
||||
"OFF": ClimateAction.CLIMATE_ACTION_OFF,
|
||||
"COOLING": ClimateAction.CLIMATE_ACTION_COOLING,
|
||||
"HEATING": ClimateAction.CLIMATE_ACTION_HEATING,
|
||||
"IDLE": ClimateAction.CLIMATE_ACTION_IDLE,
|
||||
"DRYING": ClimateAction.CLIMATE_ACTION_DRYING,
|
||||
"FAN": ClimateAction.CLIMATE_ACTION_FAN,
|
||||
"DEFROSTING": ClimateAction.CLIMATE_ACTION_DEFROSTING,
|
||||
}
|
||||
CLIMATE_ACTIONS = ClimateAction.options(
|
||||
"OFF",
|
||||
"COOLING",
|
||||
"HEATING",
|
||||
"IDLE",
|
||||
"DRYING",
|
||||
"FAN",
|
||||
"DEFROSTING",
|
||||
prefix="CLIMATE_ACTION_",
|
||||
)
|
||||
|
||||
validate_climate_action = cv.enum(CLIMATE_ACTIONS, upper=True)
|
||||
|
||||
|
||||
@@ -80,11 +80,9 @@ COVER_STATES = {
|
||||
validate_cover_state = cv.enum(COVER_STATES, upper=True)
|
||||
|
||||
CoverOperation = cover_ns.enum("CoverOperation")
|
||||
COVER_OPERATIONS = {
|
||||
"IDLE": CoverOperation.COVER_OPERATION_IDLE,
|
||||
"OPENING": CoverOperation.COVER_OPERATION_OPENING,
|
||||
"CLOSING": CoverOperation.COVER_OPERATION_CLOSING,
|
||||
}
|
||||
COVER_OPERATIONS = CoverOperation.options(
|
||||
"IDLE", "OPENING", "CLOSING", prefix="COVER_OPERATION_"
|
||||
)
|
||||
validate_cover_operation = cv.enum(COVER_OPERATIONS, upper=True)
|
||||
|
||||
# Actions
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cs5460a.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome::cs5460a {
|
||||
@@ -304,7 +305,7 @@ bool CS5460AComponent::check_status_() {
|
||||
voltage_sensor_->publish_state(raw_voltage * voltage_multiplier_);
|
||||
|
||||
if (power_sensor_ != nullptr && raw_energy != prev_raw_energy_) {
|
||||
int32_t raw = (int32_t) (raw_energy << 8) >> 8; /* Sign-extend */
|
||||
int32_t raw = sign_extend<24>(raw_energy);
|
||||
power_sensor_->publish_state(raw * power_multiplier_);
|
||||
prev_raw_energy_ = raw_energy;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,7 @@ DEPENDENCIES = ["spi"]
|
||||
|
||||
cs5460a_ns = cg.esphome_ns.namespace("cs5460a")
|
||||
CS5460APGAGain = cs5460a_ns.enum("CS5460APGAGain")
|
||||
PGA_GAIN_OPTIONS = {
|
||||
"10X": CS5460APGAGain.CS5460A_PGA_GAIN_10X,
|
||||
"50X": CS5460APGAGain.CS5460A_PGA_GAIN_50X,
|
||||
}
|
||||
PGA_GAIN_OPTIONS = CS5460APGAGain.options("10X", "50X", prefix="CS5460A_PGA_GAIN_")
|
||||
|
||||
CS5460AComponent = cs5460a_ns.class_("CS5460AComponent", spi.SPIDevice, cg.Component)
|
||||
|
||||
|
||||
@@ -39,10 +39,9 @@ CONF_POWER_FACTOR_1 = "power_factor_1"
|
||||
CONF_CURRENT_INPUT = "current_input"
|
||||
|
||||
CSE7761CurrentInput = cse7761_ns.enum("CSE7761CurrentInput", is_class=True)
|
||||
CURRENT_INPUTS = {
|
||||
"shunt": CSE7761CurrentInput.CSE7761_CURRENT_INPUT_SHUNT,
|
||||
"current_transformer": CSE7761CurrentInput.CSE7761_CURRENT_INPUT_CURRENT_TRANSFORMER,
|
||||
}
|
||||
CURRENT_INPUTS = CSE7761CurrentInput.options(
|
||||
"shunt", "current_transformer", prefix="CSE7761_CURRENT_INPUT_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -223,19 +223,15 @@ DeepSleepComponent = deep_sleep_ns.class_("DeepSleepComponent", cg.Component)
|
||||
EnterDeepSleepAction = deep_sleep_ns.class_("EnterDeepSleepAction", automation.Action)
|
||||
|
||||
WakeupPinMode = deep_sleep_ns.enum("WakeupPinMode")
|
||||
WAKEUP_PIN_MODES = {
|
||||
"IGNORE": WakeupPinMode.WAKEUP_PIN_MODE_IGNORE,
|
||||
"KEEP_AWAKE": WakeupPinMode.WAKEUP_PIN_MODE_KEEP_AWAKE,
|
||||
"INVERT_WAKEUP": WakeupPinMode.WAKEUP_PIN_MODE_INVERT_WAKEUP,
|
||||
}
|
||||
WAKEUP_PIN_MODES = WakeupPinMode.options(
|
||||
"IGNORE", "KEEP_AWAKE", "INVERT_WAKEUP", prefix="WAKEUP_PIN_MODE_"
|
||||
)
|
||||
|
||||
esp_sleep_ext1_wakeup_mode_t = cg.global_ns.enum("esp_sleep_ext1_wakeup_mode_t")
|
||||
Ext1Wakeup = deep_sleep_ns.struct("Ext1Wakeup")
|
||||
EXT1_WAKEUP_MODES = {
|
||||
"ANY_LOW": esp_sleep_ext1_wakeup_mode_t.ESP_EXT1_WAKEUP_ANY_LOW,
|
||||
"ALL_LOW": esp_sleep_ext1_wakeup_mode_t.ESP_EXT1_WAKEUP_ALL_LOW,
|
||||
"ANY_HIGH": esp_sleep_ext1_wakeup_mode_t.ESP_EXT1_WAKEUP_ANY_HIGH,
|
||||
}
|
||||
EXT1_WAKEUP_MODES = esp_sleep_ext1_wakeup_mode_t.options(
|
||||
"ANY_LOW", "ALL_LOW", "ANY_HIGH", prefix="ESP_EXT1_WAKEUP_"
|
||||
)
|
||||
WakeupCauseToRunDuration = deep_sleep_ns.struct("WakeupCauseToRunDuration")
|
||||
|
||||
WakeupCause = deep_sleep_ns.enum("WakeupCause")
|
||||
|
||||
@@ -21,19 +21,9 @@ CONF_EQ_PRESET = "eq_preset"
|
||||
CONF_ON_FINISHED_PLAYBACK = "on_finished_playback"
|
||||
|
||||
EqPreset = dfplayer_ns.enum("EqPreset")
|
||||
EQ_PRESET = {
|
||||
"NORMAL": EqPreset.NORMAL,
|
||||
"POP": EqPreset.POP,
|
||||
"ROCK": EqPreset.ROCK,
|
||||
"JAZZ": EqPreset.JAZZ,
|
||||
"CLASSIC": EqPreset.CLASSIC,
|
||||
"BASS": EqPreset.BASS,
|
||||
}
|
||||
EQ_PRESET = EqPreset.options("NORMAL", "POP", "ROCK", "JAZZ", "CLASSIC", "BASS")
|
||||
Device = dfplayer_ns.enum("Device")
|
||||
DEVICE = {
|
||||
"USB": Device.USB,
|
||||
"TF_CARD": Device.TF_CARD,
|
||||
}
|
||||
DEVICE = Device.options("USB", "TF_CARD")
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
|
||||
@@ -19,16 +19,17 @@ from esphome.types import ConfigType
|
||||
|
||||
dht_ns = cg.esphome_ns.namespace("dht")
|
||||
DHTModel = dht_ns.enum("DHTModel")
|
||||
DHT_MODELS = {
|
||||
"AUTO_DETECT": DHTModel.DHT_MODEL_AUTO_DETECT,
|
||||
"DHT11": DHTModel.DHT_MODEL_DHT11,
|
||||
"DHT22": DHTModel.DHT_MODEL_DHT22,
|
||||
"AM2120": DHTModel.DHT_MODEL_AM2120,
|
||||
"AM2302": DHTModel.DHT_MODEL_AM2302,
|
||||
"RHT03": DHTModel.DHT_MODEL_RHT03,
|
||||
"SI7021": DHTModel.DHT_MODEL_SI7021,
|
||||
"DHT22_TYPE2": DHTModel.DHT_MODEL_DHT22_TYPE2,
|
||||
}
|
||||
DHT_MODELS = DHTModel.options(
|
||||
"AUTO_DETECT",
|
||||
"DHT11",
|
||||
"DHT22",
|
||||
"AM2120",
|
||||
"AM2302",
|
||||
"RHT03",
|
||||
"SI7021",
|
||||
"DHT22_TYPE2",
|
||||
prefix="DHT_MODEL_",
|
||||
)
|
||||
DHT = dht_ns.class_("DHT", cg.PollingComponent)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
|
||||
@@ -22,16 +22,17 @@ ES8311_BITS_PER_SAMPLE_ENUM = {
|
||||
}
|
||||
|
||||
es8311_mic_gain = es8311_ns.enum("ES8311MicGain")
|
||||
ES8311_MIC_GAIN_ENUM = {
|
||||
"0DB": es8311_mic_gain.ES8311_MIC_GAIN_0DB,
|
||||
"6DB": es8311_mic_gain.ES8311_MIC_GAIN_6DB,
|
||||
"12DB": es8311_mic_gain.ES8311_MIC_GAIN_12DB,
|
||||
"18DB": es8311_mic_gain.ES8311_MIC_GAIN_18DB,
|
||||
"24DB": es8311_mic_gain.ES8311_MIC_GAIN_24DB,
|
||||
"30DB": es8311_mic_gain.ES8311_MIC_GAIN_30DB,
|
||||
"36DB": es8311_mic_gain.ES8311_MIC_GAIN_36DB,
|
||||
"42DB": es8311_mic_gain.ES8311_MIC_GAIN_42DB,
|
||||
}
|
||||
ES8311_MIC_GAIN_ENUM = es8311_mic_gain.options(
|
||||
"0DB",
|
||||
"6DB",
|
||||
"12DB",
|
||||
"18DB",
|
||||
"24DB",
|
||||
"30DB",
|
||||
"36DB",
|
||||
"42DB",
|
||||
prefix="ES8311_MIC_GAIN_",
|
||||
)
|
||||
|
||||
|
||||
_validate_bits = cv.float_with_unit("bits", "bit")
|
||||
|
||||
@@ -14,26 +14,24 @@ CONF_DAC_OUTPUT = "dac_output"
|
||||
CONF_ADC_INPUT_MIC = "adc_input_mic"
|
||||
|
||||
DacOutputLine = es8388_ns.enum("DacOutputLine")
|
||||
DAC_OUTPUT_OPTIONS = {
|
||||
"LINE1": DacOutputLine.DAC_OUTPUT_LINE1,
|
||||
"LINE2": DacOutputLine.DAC_OUTPUT_LINE2,
|
||||
"BOTH": DacOutputLine.DAC_OUTPUT_BOTH,
|
||||
}
|
||||
DAC_OUTPUT_OPTIONS = DacOutputLine.options(
|
||||
"LINE1", "LINE2", "BOTH", prefix="DAC_OUTPUT_"
|
||||
)
|
||||
DAC_OUTPUT_OPTION_NAMES = list(DAC_OUTPUT_OPTIONS)
|
||||
AdcInputMicLine = es8388_ns.enum("AdcInputMicLine")
|
||||
ADC_INPUT_MIC_OPTIONS = {
|
||||
"LINE1": AdcInputMicLine.ADC_INPUT_MIC_LINE1,
|
||||
"LINE2": AdcInputMicLine.ADC_INPUT_MIC_LINE2,
|
||||
"DIFFERENCE": AdcInputMicLine.ADC_INPUT_MIC_DIFFERENCE,
|
||||
}
|
||||
ADC_INPUT_MIC_OPTIONS = AdcInputMicLine.options(
|
||||
"LINE1", "LINE2", "DIFFERENCE", prefix="ADC_INPUT_MIC_"
|
||||
)
|
||||
ADC_INPUT_MIC_OPTION_NAMES = list(ADC_INPUT_MIC_OPTIONS)
|
||||
|
||||
DacOutputSelect = es8388_ns.class_("DacOutputSelect", select.Select)
|
||||
ADCInputMicSelect = es8388_ns.class_("ADCInputMicSelect", select.Select)
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
{
|
||||
cv.GenerateID(CONF_ES8388_ID): cv.use_id(ES8388),
|
||||
cv.Optional(CONF_DAC_OUTPUT): select.select_schema(
|
||||
select.ApplySelect,
|
||||
DacOutputSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
icon=ICON_CHIP,
|
||||
).extend(
|
||||
@@ -44,7 +42,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_ADC_INPUT_MIC): select.select_schema(
|
||||
select.ApplySelect,
|
||||
ADCInputMicSelect,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
icon=ICON_CHIP,
|
||||
).extend(
|
||||
@@ -63,18 +61,12 @@ async def to_code(config: ConfigType) -> None:
|
||||
hub = await cg.get_variable(config[CONF_ES8388_ID])
|
||||
selects = select.sub_selects(config, parent=hub)
|
||||
await selects(
|
||||
CONF_DAC_OUTPUT,
|
||||
hub.set_dac_output_select,
|
||||
options=DAC_OUTPUT_OPTION_NAMES,
|
||||
apply="set_dac_output(static_cast<es8388::DacOutputLine>(index))",
|
||||
publish="before",
|
||||
CONF_DAC_OUTPUT, hub.set_dac_output_select, options=DAC_OUTPUT_OPTION_NAMES
|
||||
)
|
||||
await selects(
|
||||
CONF_ADC_INPUT_MIC,
|
||||
hub.set_adc_input_mic_select,
|
||||
options=ADC_INPUT_MIC_OPTION_NAMES,
|
||||
apply="set_adc_input_mic(static_cast<es8388::AdcInputMicLine>(index))",
|
||||
publish="before",
|
||||
)
|
||||
if (
|
||||
initial := config.get(CONF_DAC_OUTPUT, {}).get(CONF_INITIAL_OPTION)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "adc_input_mic_select.h"
|
||||
|
||||
namespace esphome::es8388 {
|
||||
|
||||
void ADCInputMicSelect::control(size_t index) {
|
||||
this->publish_state(index);
|
||||
this->parent_->set_adc_input_mic(static_cast<AdcInputMicLine>(index));
|
||||
}
|
||||
|
||||
} // namespace esphome::es8388
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/es8388/es8388.h"
|
||||
#include "esphome/components/select/select.h"
|
||||
|
||||
namespace esphome::es8388 {
|
||||
|
||||
class ADCInputMicSelect final : public select::Select, public Parented<ES8388> {
|
||||
protected:
|
||||
void control(size_t index) override;
|
||||
};
|
||||
|
||||
} // namespace esphome::es8388
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "dac_output_select.h"
|
||||
|
||||
namespace esphome::es8388 {
|
||||
|
||||
void DacOutputSelect::control(size_t index) {
|
||||
this->publish_state(index);
|
||||
this->parent_->set_dac_output(static_cast<DacOutputLine>(index));
|
||||
}
|
||||
|
||||
} // namespace esphome::es8388
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/es8388/es8388.h"
|
||||
#include "esphome/components/select/select.h"
|
||||
|
||||
namespace esphome::es8388 {
|
||||
|
||||
class DacOutputSelect final : public select::Select, public Parented<ES8388> {
|
||||
protected:
|
||||
void control(size_t index) override;
|
||||
};
|
||||
|
||||
} // namespace esphome::es8388
|
||||
@@ -42,12 +42,9 @@ FILTER_SHAPES = {
|
||||
}
|
||||
|
||||
DeemphasisMode = es9038q2m_katana_ns.enum("DeemphasisMode")
|
||||
DEEMPHASIS_MODES = {
|
||||
"bypass": DeemphasisMode.DEEMPHASIS_BYPASS,
|
||||
"32khz": DeemphasisMode.DEEMPHASIS_32KHZ,
|
||||
"44_1khz": DeemphasisMode.DEEMPHASIS_44_1KHZ,
|
||||
"48khz": DeemphasisMode.DEEMPHASIS_48KHZ,
|
||||
}
|
||||
DEEMPHASIS_MODES = DeemphasisMode.options(
|
||||
"bypass", "32khz", "44_1khz", "48khz", prefix="DEEMPHASIS_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -310,16 +310,17 @@ IO_CAPABILITY = {
|
||||
}
|
||||
|
||||
AuthReqMode = esp32_ble_ns.enum("AuthReqMode")
|
||||
AUTH_REQ_MODE = {
|
||||
"no_bond": AuthReqMode.AUTH_REQ_NO_BOND,
|
||||
"bond": AuthReqMode.AUTH_REQ_BOND,
|
||||
"mitm": AuthReqMode.AUTH_REQ_MITM,
|
||||
"bond_mitm": AuthReqMode.AUTH_REQ_BOND_MITM,
|
||||
"sc_only": AuthReqMode.AUTH_REQ_SC_ONLY,
|
||||
"sc_bond": AuthReqMode.AUTH_REQ_SC_BOND,
|
||||
"sc_mitm": AuthReqMode.AUTH_REQ_SC_MITM,
|
||||
"sc_mitm_bond": AuthReqMode.AUTH_REQ_SC_MITM_BOND,
|
||||
}
|
||||
AUTH_REQ_MODE = AuthReqMode.options(
|
||||
"no_bond",
|
||||
"bond",
|
||||
"mitm",
|
||||
"bond_mitm",
|
||||
"sc_only",
|
||||
"sc_bond",
|
||||
"sc_mitm",
|
||||
"sc_mitm_bond",
|
||||
prefix="AUTH_REQ_",
|
||||
)
|
||||
|
||||
esp_power_level_t = cg.global_ns.enum("esp_power_level_t")
|
||||
|
||||
|
||||
@@ -90,50 +90,42 @@ FRAME_SIZES = {
|
||||
"QSXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1920,
|
||||
}
|
||||
ESP32CameraPixelFormat = esp32_camera_ns.enum("ESP32CameraPixelFormat")
|
||||
PIXEL_FORMATS = {
|
||||
"RGB565": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_RGB565,
|
||||
"YUV422": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_YUV422,
|
||||
"YUV420": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_YUV420,
|
||||
"GRAYSCALE": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_GRAYSCALE,
|
||||
"JPEG": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_JPEG,
|
||||
"RGB888": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_RGB888,
|
||||
"RAW": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_RAW,
|
||||
"RGB444": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_RGB444,
|
||||
"RGB555": ESP32CameraPixelFormat.ESP32_PIXEL_FORMAT_RGB555,
|
||||
}
|
||||
PIXEL_FORMATS = ESP32CameraPixelFormat.options(
|
||||
"RGB565",
|
||||
"YUV422",
|
||||
"YUV420",
|
||||
"GRAYSCALE",
|
||||
"JPEG",
|
||||
"RGB888",
|
||||
"RAW",
|
||||
"RGB444",
|
||||
"RGB555",
|
||||
prefix="ESP32_PIXEL_FORMAT_",
|
||||
)
|
||||
ESP32GainControlMode = esp32_camera_ns.enum("ESP32GainControlMode")
|
||||
ENUM_GAIN_CONTROL_MODE = {
|
||||
"MANUAL": ESP32GainControlMode.ESP32_GC_MODE_MANU,
|
||||
"AUTO": ESP32GainControlMode.ESP32_GC_MODE_AUTO,
|
||||
}
|
||||
ESP32AgcGainCeiling = esp32_camera_ns.enum("ESP32AgcGainCeiling")
|
||||
ENUM_GAIN_CEILING = {
|
||||
"2X": ESP32AgcGainCeiling.ESP32_GAINCEILING_2X,
|
||||
"4X": ESP32AgcGainCeiling.ESP32_GAINCEILING_4X,
|
||||
"8X": ESP32AgcGainCeiling.ESP32_GAINCEILING_8X,
|
||||
"16X": ESP32AgcGainCeiling.ESP32_GAINCEILING_16X,
|
||||
"32X": ESP32AgcGainCeiling.ESP32_GAINCEILING_32X,
|
||||
"64X": ESP32AgcGainCeiling.ESP32_GAINCEILING_64X,
|
||||
"128X": ESP32AgcGainCeiling.ESP32_GAINCEILING_128X,
|
||||
}
|
||||
ENUM_GAIN_CEILING = ESP32AgcGainCeiling.options(
|
||||
"2X", "4X", "8X", "16X", "32X", "64X", "128X", prefix="ESP32_GAINCEILING_"
|
||||
)
|
||||
ESP32WhiteBalanceMode = esp32_camera_ns.enum("ESP32WhiteBalanceMode")
|
||||
ENUM_WB_MODE = {
|
||||
"AUTO": ESP32WhiteBalanceMode.ESP32_WB_MODE_AUTO,
|
||||
"SUNNY": ESP32WhiteBalanceMode.ESP32_WB_MODE_SUNNY,
|
||||
"CLOUDY": ESP32WhiteBalanceMode.ESP32_WB_MODE_CLOUDY,
|
||||
"OFFICE": ESP32WhiteBalanceMode.ESP32_WB_MODE_OFFICE,
|
||||
"HOME": ESP32WhiteBalanceMode.ESP32_WB_MODE_HOME,
|
||||
}
|
||||
ENUM_WB_MODE = ESP32WhiteBalanceMode.options(
|
||||
"AUTO", "SUNNY", "CLOUDY", "OFFICE", "HOME", prefix="ESP32_WB_MODE_"
|
||||
)
|
||||
ESP32SpecialEffect = esp32_camera_ns.enum("ESP32SpecialEffect")
|
||||
ENUM_SPECIAL_EFFECT = {
|
||||
"NONE": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_NONE,
|
||||
"NEGATIVE": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_NEGATIVE,
|
||||
"GRAYSCALE": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_GRAYSCALE,
|
||||
"RED_TINT": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_RED_TINT,
|
||||
"GREEN_TINT": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_GREEN_TINT,
|
||||
"BLUE_TINT": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_BLUE_TINT,
|
||||
"SEPIA": ESP32SpecialEffect.ESP32_SPECIAL_EFFECT_SEPIA,
|
||||
}
|
||||
ENUM_SPECIAL_EFFECT = ESP32SpecialEffect.options(
|
||||
"NONE",
|
||||
"NEGATIVE",
|
||||
"GRAYSCALE",
|
||||
"RED_TINT",
|
||||
"GREEN_TINT",
|
||||
"BLUE_TINT",
|
||||
"SEPIA",
|
||||
prefix="ESP32_SPECIAL_EFFECT_",
|
||||
)
|
||||
|
||||
camera_fb_location_t = cg.global_ns.enum("camera_fb_location_t")
|
||||
ENUM_FB_LOCATION = {
|
||||
|
||||
@@ -14,7 +14,7 @@ esp32_camera_web_server_ns = cg.esphome_ns.namespace("esp32_camera_web_server")
|
||||
CameraWebServer = esp32_camera_web_server_ns.class_("CameraWebServer", cg.Component)
|
||||
Mode = esp32_camera_web_server_ns.enum("Mode")
|
||||
|
||||
MODES = {"STREAM": Mode.STREAM, "SNAPSHOT": Mode.SNAPSHOT}
|
||||
MODES = Mode.options("STREAM", "SNAPSHOT")
|
||||
|
||||
|
||||
def _consume_camera_web_server_sockets(config: ConfigType) -> ConfigType:
|
||||
|
||||
@@ -38,15 +38,8 @@ CsiCapturePolicy = sdk_ns.enum("CsiCapturePolicy", is_class=True)
|
||||
TrafficGeneratorMode = sdk_ns.enum("TrafficGeneratorMode", is_class=True)
|
||||
WifiBandPolicy = sdk_ns.enum("WifiBandPolicy", is_class=True)
|
||||
|
||||
DETECTION_ALGORITHMS = {
|
||||
"lightweight": DetectionAlgorithm.LIGHTWEIGHT,
|
||||
"high_accuracy": DetectionAlgorithm.HIGH_ACCURACY,
|
||||
}
|
||||
CSI_CAPTURE_PROFILES = {
|
||||
"auto": CsiCapturePolicy.AUTO,
|
||||
"lltf": CsiCapturePolicy.LLTF,
|
||||
"ht_vht": CsiCapturePolicy.HT_VHT,
|
||||
}
|
||||
DETECTION_ALGORITHMS = DetectionAlgorithm.options("lightweight", "high_accuracy")
|
||||
CSI_CAPTURE_PROFILES = CsiCapturePolicy.options("auto", "lltf", "ht_vht")
|
||||
TRAFFIC_GENERATOR_MODES = {
|
||||
"ping": TrafficGeneratorMode.PING,
|
||||
"dns": TrafficGeneratorMode.DNS,
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import button
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import ENTITY_CATEGORY_CONFIG
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import CONF_ESPECTRE_ID, ESPectreComponent
|
||||
from .. import CONF_ESPECTRE_ID, ESPectreComponent, espectre_ns
|
||||
|
||||
DEPENDENCIES = ["espectre"]
|
||||
|
||||
RecalibrateButton = espectre_ns.class_("RecalibrateButton", button.Button)
|
||||
|
||||
CONFIG_SCHEMA = button.button_schema(
|
||||
button.ApplyButton, entity_category=ENTITY_CATEGORY_CONFIG
|
||||
RecalibrateButton, entity_category=ENTITY_CATEGORY_CONFIG
|
||||
).extend({cv.GenerateID(CONF_ESPECTRE_ID): cv.use_id(ESPectreComponent)})
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
buttons = button.sub_buttons(config, parent=config[CONF_ESPECTRE_ID])
|
||||
await buttons.create(config, None, apply="recalibrate()")
|
||||
var = await button.new_button(config)
|
||||
await cg.register_parented(var, config[CONF_ESPECTRE_ID])
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_ESPECTRE
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../espectre.h"
|
||||
|
||||
namespace esphome::espectre {
|
||||
|
||||
class RecalibrateButton final : public button::Button, public Parented<ESPectreComponent> {
|
||||
protected:
|
||||
void press_action() override { this->parent_->recalibrate(); }
|
||||
};
|
||||
|
||||
} // namespace esphome::espectre
|
||||
|
||||
#endif // USE_ESPECTRE
|
||||
@@ -9,23 +9,24 @@ from .. import (
|
||||
CONF_ESPECTRE_ID,
|
||||
DOMAIN,
|
||||
ESPectreComponent,
|
||||
espectre_ns,
|
||||
supported_traffic_generator_modes,
|
||||
)
|
||||
|
||||
DEPENDENCIES = ["espectre"]
|
||||
|
||||
TrafficModeSelect = espectre_ns.class_(
|
||||
"TrafficModeSelect", select.Select, cg.Parented.template(ESPectreComponent)
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = select.select_schema(
|
||||
select.ApplySelect, entity_category=ENTITY_CATEGORY_CONFIG
|
||||
TrafficModeSelect, entity_category=ENTITY_CATEGORY_CONFIG
|
||||
).extend({cv.GenerateID(CONF_ESPECTRE_ID): cv.use_id(ESPectreComponent)})
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
options = supported_traffic_generator_modes(CORE.config[DOMAIN])
|
||||
hub = await cg.get_variable(config[CONF_ESPECTRE_ID])
|
||||
await select.sub_selects(config, parent=hub).create(
|
||||
config,
|
||||
hub.set_traffic_mode_select,
|
||||
options=options,
|
||||
apply="request_traffic_generator_mode(entity->option_at(index))",
|
||||
)
|
||||
var = await select.new_select(config, options=options)
|
||||
await cg.register_parented(var, config[CONF_ESPECTRE_ID])
|
||||
parent = await cg.get_variable(config[CONF_ESPECTRE_ID])
|
||||
cg.add(parent.set_traffic_mode_select(var))
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "espectre_select.h"
|
||||
|
||||
#ifdef USE_ESPECTRE
|
||||
|
||||
namespace esphome::espectre {
|
||||
|
||||
void TrafficModeSelect::control(size_t index) { this->parent_->request_traffic_generator_mode(this->option_at(index)); }
|
||||
|
||||
} // namespace esphome::espectre
|
||||
|
||||
#endif // USE_ESPECTRE
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_ESPECTRE
|
||||
|
||||
#include "esphome/components/select/select.h"
|
||||
#include "../espectre.h"
|
||||
|
||||
namespace esphome::espectre {
|
||||
|
||||
class TrafficModeSelect final : public select::Select, public Parented<ESPectreComponent> {
|
||||
protected:
|
||||
void control(size_t index) override;
|
||||
};
|
||||
|
||||
} // namespace esphome::espectre
|
||||
|
||||
#endif // USE_ESPECTRE
|
||||
@@ -117,27 +117,28 @@ CONF_INTERFACE = "interface"
|
||||
CONF_CLOCK_SPEED = "clock_speed"
|
||||
|
||||
EthernetType = ethernet_ns.enum("EthernetType")
|
||||
ETHERNET_TYPES = {
|
||||
"LAN8720": EthernetType.ETHERNET_TYPE_LAN8720,
|
||||
"RTL8201": EthernetType.ETHERNET_TYPE_RTL8201,
|
||||
"DP83848": EthernetType.ETHERNET_TYPE_DP83848,
|
||||
"IP101": EthernetType.ETHERNET_TYPE_IP101,
|
||||
"JL1101": EthernetType.ETHERNET_TYPE_JL1101,
|
||||
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
|
||||
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
|
||||
"W5100": EthernetType.ETHERNET_TYPE_W5100,
|
||||
"W5500": EthernetType.ETHERNET_TYPE_W5500,
|
||||
"OPENETH": EthernetType.ETHERNET_TYPE_OPENETH,
|
||||
"DM9051": EthernetType.ETHERNET_TYPE_DM9051,
|
||||
"LAN8670": EthernetType.ETHERNET_TYPE_LAN8670,
|
||||
"ENC28J60": EthernetType.ETHERNET_TYPE_ENC28J60,
|
||||
"W6100": EthernetType.ETHERNET_TYPE_W6100,
|
||||
"W6300": EthernetType.ETHERNET_TYPE_W6300,
|
||||
"GENERIC": EthernetType.ETHERNET_TYPE_GENERIC,
|
||||
"YT8531": EthernetType.ETHERNET_TYPE_YT8531,
|
||||
"CH390": EthernetType.ETHERNET_TYPE_CH390,
|
||||
"KSZ8851SNL": EthernetType.ETHERNET_TYPE_KSZ8851SNL,
|
||||
}
|
||||
ETHERNET_TYPES = EthernetType.options(
|
||||
"LAN8720",
|
||||
"RTL8201",
|
||||
"DP83848",
|
||||
"IP101",
|
||||
"JL1101",
|
||||
"KSZ8081",
|
||||
"KSZ8081RNA",
|
||||
"W5100",
|
||||
"W5500",
|
||||
"OPENETH",
|
||||
"DM9051",
|
||||
"LAN8670",
|
||||
"ENC28J60",
|
||||
"W6100",
|
||||
"W6300",
|
||||
"GENERIC",
|
||||
"YT8531",
|
||||
"CH390",
|
||||
"KSZ8851SNL",
|
||||
prefix="ETHERNET_TYPE_",
|
||||
)
|
||||
|
||||
# PHY types that need compile-time defines for conditional compilation
|
||||
# Each RMII PHY type gets a define so unused PHY drivers are excluded by the linker
|
||||
@@ -207,10 +208,7 @@ SPI_ETHERNET_DEFAULT_POLLING_INTERVAL = TimePeriodMilliseconds(milliseconds=10)
|
||||
|
||||
emac_rmii_clock_mode_t = cg.global_ns.enum("emac_rmii_clock_mode_t")
|
||||
|
||||
CLK_MODES = {
|
||||
"CLK_EXT_IN": emac_rmii_clock_mode_t.EMAC_CLK_EXT_IN,
|
||||
"CLK_OUT": emac_rmii_clock_mode_t.EMAC_CLK_OUT,
|
||||
}
|
||||
CLK_MODES = emac_rmii_clock_mode_t.options("CLK_EXT_IN", "CLK_OUT", prefix="EMAC_")
|
||||
|
||||
spi_host_device_t = cg.global_ns.enum("spi_host_device_t")
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ ExponentialMovingAverageSensor = exponential_moving_average_ns.class_(
|
||||
)
|
||||
|
||||
TimeWeighting = exponential_moving_average_ns.enum("TimeWeighting")
|
||||
TIME_WEIGHTINGS: dict[str, cg.MockObj] = {
|
||||
"new": TimeWeighting.TIME_WEIGHTING_NEW,
|
||||
"previous": TimeWeighting.TIME_WEIGHTING_PREVIOUS,
|
||||
"linear": TimeWeighting.TIME_WEIGHTING_LINEAR,
|
||||
}
|
||||
TIME_WEIGHTINGS: dict[str, cg.MockObj] = TimeWeighting.options(
|
||||
"new", "previous", "linear", prefix="TIME_WEIGHTING_"
|
||||
)
|
||||
|
||||
CONF_TIME_WEIGHTING: str = "time_weighting"
|
||||
|
||||
|
||||
@@ -45,21 +45,18 @@ fan_ns = cg.esphome_ns.namespace("fan")
|
||||
Fan = fan_ns.class_("Fan", cg.EntityBase)
|
||||
|
||||
FanDirection = fan_ns.enum("FanDirection", is_class=True)
|
||||
FAN_DIRECTION_ENUM = {
|
||||
"FORWARD": FanDirection.FORWARD,
|
||||
"REVERSE": FanDirection.REVERSE,
|
||||
}
|
||||
FAN_DIRECTION_ENUM = FanDirection.options("FORWARD", "REVERSE")
|
||||
|
||||
FanRestoreMode = fan_ns.enum("FanRestoreMode", is_class=True)
|
||||
RESTORE_MODES = {
|
||||
"NO_RESTORE": FanRestoreMode.NO_RESTORE,
|
||||
"ALWAYS_OFF": FanRestoreMode.ALWAYS_OFF,
|
||||
"ALWAYS_ON": FanRestoreMode.ALWAYS_ON,
|
||||
"RESTORE_DEFAULT_OFF": FanRestoreMode.RESTORE_DEFAULT_OFF,
|
||||
"RESTORE_DEFAULT_ON": FanRestoreMode.RESTORE_DEFAULT_ON,
|
||||
"RESTORE_INVERTED_DEFAULT_OFF": FanRestoreMode.RESTORE_INVERTED_DEFAULT_OFF,
|
||||
"RESTORE_INVERTED_DEFAULT_ON": FanRestoreMode.RESTORE_INVERTED_DEFAULT_ON,
|
||||
}
|
||||
RESTORE_MODES = FanRestoreMode.options(
|
||||
"NO_RESTORE",
|
||||
"ALWAYS_OFF",
|
||||
"ALWAYS_ON",
|
||||
"RESTORE_DEFAULT_OFF",
|
||||
"RESTORE_DEFAULT_ON",
|
||||
"RESTORE_INVERTED_DEFAULT_OFF",
|
||||
"RESTORE_INVERTED_DEFAULT_ON",
|
||||
)
|
||||
|
||||
# Actions
|
||||
CycleSpeedAction = fan_ns.class_("CycleSpeedAction", automation.Action)
|
||||
|
||||
@@ -40,25 +40,14 @@ FingerprintGrowComponent = fingerprint_grow_ns.class_(
|
||||
|
||||
|
||||
AuraLEDState = fingerprint_grow_ns.enum("GrowAuraLEDState", True)
|
||||
AURA_LED_STATES = {
|
||||
"BREATHING": AuraLEDState.BREATHING,
|
||||
"FLASHING": AuraLEDState.FLASHING,
|
||||
"ALWAYS_ON": AuraLEDState.ALWAYS_ON,
|
||||
"ALWAYS_OFF": AuraLEDState.ALWAYS_OFF,
|
||||
"GRADUAL_ON": AuraLEDState.GRADUAL_ON,
|
||||
"GRADUAL_OFF": AuraLEDState.GRADUAL_OFF,
|
||||
}
|
||||
AURA_LED_STATES = AuraLEDState.options(
|
||||
"BREATHING", "FLASHING", "ALWAYS_ON", "ALWAYS_OFF", "GRADUAL_ON", "GRADUAL_OFF"
|
||||
)
|
||||
validate_aura_led_states = cv.enum(AURA_LED_STATES, upper=True)
|
||||
AuraLEDColor = fingerprint_grow_ns.enum("GrowAuraLEDColor", True)
|
||||
AURA_LED_COLORS = {
|
||||
"RED": AuraLEDColor.RED,
|
||||
"BLUE": AuraLEDColor.BLUE,
|
||||
"PURPLE": AuraLEDColor.PURPLE,
|
||||
"GREEN": AuraLEDColor.GREEN,
|
||||
"YELLOW": AuraLEDColor.YELLOW,
|
||||
"CYAN": AuraLEDColor.CYAN,
|
||||
"WHITE": AuraLEDColor.WHITE,
|
||||
}
|
||||
AURA_LED_COLORS = AuraLEDColor.options(
|
||||
"RED", "BLUE", "PURPLE", "GREEN", "YELLOW", "CYAN", "WHITE"
|
||||
)
|
||||
validate_aura_led_colors = cv.enum(AURA_LED_COLORS, upper=True)
|
||||
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@ friedrich_ns = cg.esphome_ns.namespace("friedrich")
|
||||
FriedrichClimate = friedrich_ns.class_("FriedrichClimate", climate_ir.ClimateIR)
|
||||
|
||||
Model = friedrich_ns.enum("Model", is_class=True)
|
||||
MODELS = {
|
||||
"MW12Y3H": Model.MODEL_MW12Y3H,
|
||||
}
|
||||
MODELS = Model.options("MW12Y3H", prefix="MODEL_")
|
||||
|
||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(FriedrichClimate).extend(
|
||||
{
|
||||
|
||||
@@ -17,15 +17,9 @@ GP8403Model = gp8403_ns.enum("GP8403Model")
|
||||
|
||||
CONF_GP8403_ID = "gp8403_id"
|
||||
|
||||
MODELS = {
|
||||
"GP8403": GP8403Model.GP8403,
|
||||
"GP8413": GP8403Model.GP8413,
|
||||
}
|
||||
MODELS = GP8403Model.options("GP8403", "GP8413")
|
||||
|
||||
VOLTAGES = {
|
||||
"5V": GP8403Voltage.GP8403_VOLTAGE_5V,
|
||||
"10V": GP8403Voltage.GP8403_VOLTAGE_10V,
|
||||
}
|
||||
VOLTAGES = GP8403Voltage.options("5V", "10V", prefix="GP8403_VOLTAGE_")
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -43,26 +43,17 @@ GraphTrace = graph_ns.class_("GraphTrace")
|
||||
GraphLegend = graph_ns.class_("GraphLegend")
|
||||
|
||||
LineType = graph_ns.enum("LineType")
|
||||
LINE_TYPE = {
|
||||
"SOLID": LineType.LINE_TYPE_SOLID,
|
||||
"DOTTED": LineType.LINE_TYPE_DOTTED,
|
||||
"DASHED": LineType.LINE_TYPE_DASHED,
|
||||
}
|
||||
LINE_TYPE = LineType.options("SOLID", "DOTTED", "DASHED", prefix="LINE_TYPE_")
|
||||
|
||||
DirectionType = graph_ns.enum("DirectionType")
|
||||
DIRECTION_TYPE = {
|
||||
"AUTO": DirectionType.DIRECTION_TYPE_AUTO,
|
||||
"HORIZONTAL": DirectionType.DIRECTION_TYPE_HORIZONTAL,
|
||||
"VERTICAL": DirectionType.DIRECTION_TYPE_VERTICAL,
|
||||
}
|
||||
DIRECTION_TYPE = DirectionType.options(
|
||||
"AUTO", "HORIZONTAL", "VERTICAL", prefix="DIRECTION_TYPE_"
|
||||
)
|
||||
|
||||
ValuePositionType = graph_ns.enum("ValuePositionType")
|
||||
VALUE_POSITION_TYPE = {
|
||||
"NONE": ValuePositionType.VALUE_POSITION_TYPE_NONE,
|
||||
"AUTO": ValuePositionType.VALUE_POSITION_TYPE_AUTO,
|
||||
"BESIDE": ValuePositionType.VALUE_POSITION_TYPE_BESIDE,
|
||||
"BELOW": ValuePositionType.VALUE_POSITION_TYPE_BELOW,
|
||||
}
|
||||
VALUE_POSITION_TYPE = ValuePositionType.options(
|
||||
"NONE", "AUTO", "BESIDE", "BELOW", prefix="VALUE_POSITION_TYPE_"
|
||||
)
|
||||
|
||||
GRAPH_TRACE_SCHEMA = cv.Schema(
|
||||
{
|
||||
|
||||
@@ -12,15 +12,9 @@ AUTO_LOAD = ["climate_ir"]
|
||||
GreeClimate = gree_ns.class_("GreeClimate", climate_ir.ClimateIR)
|
||||
|
||||
Model = gree_ns.enum("Model")
|
||||
MODELS = {
|
||||
"generic": Model.GREE_GENERIC,
|
||||
"yan": Model.GREE_YAN,
|
||||
"yaa": Model.GREE_YAA,
|
||||
"yac": Model.GREE_YAC,
|
||||
"yac1fb9": Model.GREE_YAC1FB9,
|
||||
"yx1ff": Model.GREE_YX1FF,
|
||||
"yag": Model.GREE_YAG,
|
||||
}
|
||||
MODELS = Model.options(
|
||||
"generic", "yan", "yaa", "yac", "yac1fb9", "yx1ff", "yag", prefix="GREE_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(GreeClimate).extend(
|
||||
{
|
||||
|
||||
@@ -100,10 +100,7 @@ PV_SCHEMA = cv.Schema(
|
||||
)
|
||||
|
||||
GrowattProtocolVersion = growatt_solar_ns.enum("GrowattProtocolVersion")
|
||||
PROTOCOL_VERSIONS = {
|
||||
"RTU": GrowattProtocolVersion.RTU,
|
||||
"RTU2": GrowattProtocolVersion.RTU2,
|
||||
}
|
||||
PROTOCOL_VERSIONS = GrowattProtocolVersion.options("RTU", "RTU2")
|
||||
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import button
|
||||
import esphome.config_validation as cv
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from ..climate import CONF_HAIER_ID, HonClimate
|
||||
from ..climate import CONF_HAIER_ID, HonClimate, haier_ns
|
||||
|
||||
CODEOWNERS = ["@paveldn"]
|
||||
SelfCleaningButton = haier_ns.class_("SelfCleaningButton", button.Button)
|
||||
SteriCleaningButton = haier_ns.class_("SteriCleaningButton", button.Button)
|
||||
|
||||
|
||||
# Haier buttons
|
||||
@@ -18,18 +20,19 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.Optional(CONF_SELF_CLEANING): button.button_schema(
|
||||
button.ApplyButton,
|
||||
SelfCleaningButton,
|
||||
icon=ICON_SPRAY_BOTTLE,
|
||||
),
|
||||
cv.Optional(CONF_STERI_CLEANING): button.button_schema(
|
||||
button.ApplyButton,
|
||||
SteriCleaningButton,
|
||||
icon=ICON_SPRAY_BOTTLE,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
buttons = button.sub_buttons(config, parent=config[CONF_HAIER_ID])
|
||||
await buttons(CONF_SELF_CLEANING, None, apply="start_self_cleaning()")
|
||||
await buttons(CONF_STERI_CLEANING, None, apply="start_steri_cleaning()")
|
||||
async def to_code(config):
|
||||
for button_type in [CONF_SELF_CLEANING, CONF_STERI_CLEANING]:
|
||||
if conf := config.get(button_type):
|
||||
btn = await button.new_button(conf)
|
||||
await cg.register_parented(btn, config[CONF_HAIER_ID])
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "self_cleaning.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
void SelfCleaningButton::press_action() { this->parent_->start_self_cleaning(); }
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../hon_climate.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
class SelfCleaningButton final : public button::Button, public Parented<HonClimate> {
|
||||
public:
|
||||
SelfCleaningButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "steri_cleaning.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
void SteriCleaningButton::press_action() { this->parent_->start_steri_cleaning(); }
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../hon_climate.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
class SteriCleaningButton final : public button::Button, public Parented<HonClimate> {
|
||||
public:
|
||||
SteriCleaningButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -67,23 +67,14 @@ Smartair2Climate = haier_ns.class_("Smartair2Climate", HaierClimateBase)
|
||||
CONF_HAIER_ID = "haier_id"
|
||||
|
||||
AirflowVerticalDirection = hon_protocol_ns.enum("VerticalSwingMode", True)
|
||||
AIRFLOW_VERTICAL_DIRECTION_OPTIONS = {
|
||||
"HEALTH_UP": AirflowVerticalDirection.HEALTH_UP,
|
||||
"MAX_UP": AirflowVerticalDirection.MAX_UP,
|
||||
"UP": AirflowVerticalDirection.UP,
|
||||
"CENTER": AirflowVerticalDirection.CENTER,
|
||||
"DOWN": AirflowVerticalDirection.DOWN,
|
||||
"HEALTH_DOWN": AirflowVerticalDirection.HEALTH_DOWN,
|
||||
}
|
||||
AIRFLOW_VERTICAL_DIRECTION_OPTIONS = AirflowVerticalDirection.options(
|
||||
"HEALTH_UP", "MAX_UP", "UP", "CENTER", "DOWN", "HEALTH_DOWN"
|
||||
)
|
||||
|
||||
AirflowHorizontalDirection = hon_protocol_ns.enum("HorizontalSwingMode", True)
|
||||
AIRFLOW_HORIZONTAL_DIRECTION_OPTIONS = {
|
||||
"MAX_LEFT": AirflowHorizontalDirection.MAX_LEFT,
|
||||
"LEFT": AirflowHorizontalDirection.LEFT,
|
||||
"CENTER": AirflowHorizontalDirection.CENTER,
|
||||
"RIGHT": AirflowHorizontalDirection.RIGHT,
|
||||
"MAX_RIGHT": AirflowHorizontalDirection.MAX_RIGHT,
|
||||
}
|
||||
AIRFLOW_HORIZONTAL_DIRECTION_OPTIONS = AirflowHorizontalDirection.options(
|
||||
"MAX_LEFT", "LEFT", "CENTER", "RIGHT", "MAX_RIGHT"
|
||||
)
|
||||
|
||||
SUPPORTED_SWING_MODES_OPTIONS = {
|
||||
"OFF": ClimateSwingMode.CLIMATE_SWING_OFF,
|
||||
@@ -114,11 +105,9 @@ SUPPORTED_CLIMATE_PRESETS_HON_OPTIONS = {
|
||||
}
|
||||
|
||||
HonControlMethod = haier_ns.enum("HonControlMethod", True)
|
||||
SUPPORTED_HON_CONTROL_METHODS = {
|
||||
"MONITOR_ONLY": HonControlMethod.MONITOR_ONLY,
|
||||
"SET_GROUP_PARAMETERS": HonControlMethod.SET_GROUP_PARAMETERS,
|
||||
"SET_SINGLE_PARAMETER": HonControlMethod.SET_SINGLE_PARAMETER,
|
||||
}
|
||||
SUPPORTED_HON_CONTROL_METHODS = HonControlMethod.options(
|
||||
"MONITOR_ONLY", "SET_GROUP_PARAMETERS", "SET_SINGLE_PARAMETER"
|
||||
)
|
||||
|
||||
|
||||
def validate_visual(config):
|
||||
|
||||
@@ -9,9 +9,12 @@ from ..climate import (
|
||||
CONF_HORIZONTAL_AIRFLOW,
|
||||
CONF_VERTICAL_AIRFLOW,
|
||||
HonClimate,
|
||||
haier_ns,
|
||||
)
|
||||
|
||||
CODEOWNERS = ["@paveldn"]
|
||||
VerticalAirflowSelect = haier_ns.class_("VerticalAirflowSelect", select.Select)
|
||||
HorizontalAirflowSelect = haier_ns.class_("HorizontalAirflowSelect", select.Select)
|
||||
|
||||
# Same order as VERTICAL_SWING_MODES_ORDER and HORIZONTAL_SWING_MODES_ORDER in hon_climate.h
|
||||
AIRFLOW_VERTICAL_DIRECTION_OPTIONS = [
|
||||
@@ -36,12 +39,12 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.Optional(CONF_VERTICAL_AIRFLOW): select.select_schema(
|
||||
select.ApplySelect,
|
||||
VerticalAirflowSelect,
|
||||
icon="mdi:arrow-expand-vertical",
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
cv.Optional(CONF_HORIZONTAL_AIRFLOW): select.select_schema(
|
||||
select.ApplySelect,
|
||||
HorizontalAirflowSelect,
|
||||
icon="mdi:arrow-expand-horizontal",
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
),
|
||||
@@ -56,13 +59,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
CONF_VERTICAL_AIRFLOW,
|
||||
hub.set_vertical_airflow_select,
|
||||
options=AIRFLOW_VERTICAL_DIRECTION_OPTIONS,
|
||||
apply="set_vertical_airflow("
|
||||
"haier::airflow_order_at(haier::VERTICAL_SWING_MODES_ORDER, index))",
|
||||
)
|
||||
await selects(
|
||||
CONF_HORIZONTAL_AIRFLOW,
|
||||
hub.set_horizontal_airflow_select,
|
||||
options=AIRFLOW_HORIZONTAL_DIRECTION_OPTIONS,
|
||||
apply="set_horizontal_airflow("
|
||||
"haier::airflow_order_at(haier::HORIZONTAL_SWING_MODES_ORDER, index))",
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/select/select.h"
|
||||
#include "../hon_climate.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
class HorizontalAirflowSelect : public select::Select, public Parented<HonClimate> {
|
||||
protected:
|
||||
void control(size_t index) override {
|
||||
this->parent_->set_horizontal_airflow(airflow_order_at(HORIZONTAL_SWING_MODES_ORDER, index));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/select/select.h"
|
||||
#include "../hon_climate.h"
|
||||
|
||||
namespace esphome::haier {
|
||||
|
||||
class VerticalAirflowSelect : public select::Select, public Parented<HonClimate> {
|
||||
protected:
|
||||
void control(size_t index) override {
|
||||
this->parent_->set_vertical_airflow(airflow_order_at(VERTICAL_SWING_MODES_ORDER, index));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -12,10 +12,7 @@ HaierTundra = haier_tundra_ns.class_("HaierTundra", climate_ir.ClimateIR)
|
||||
|
||||
CONF_UNIT = "unit"
|
||||
Unit = haier_tundra_ns.enum("Unit")
|
||||
UNITS = {
|
||||
"a": Unit.HAIER_HEADER_UNIT_A,
|
||||
"b": Unit.HAIER_HEADER_UNIT_B,
|
||||
}
|
||||
UNITS = Unit.options("a", "b", prefix="HAIER_HEADER_UNIT_")
|
||||
|
||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(HaierTundra).extend(
|
||||
{
|
||||
|
||||
@@ -22,10 +22,7 @@ CODEOWNERS = ["@WeekendWarrior"]
|
||||
HBridgeFan = hbridge_ns.class_("HBridgeFan", cg.Component, fan.Fan)
|
||||
|
||||
DecayMode = hbridge_ns.enum("DecayMode")
|
||||
DECAY_MODE_OPTIONS = {
|
||||
"SLOW": DecayMode.DECAY_MODE_SLOW,
|
||||
"FAST": DecayMode.DECAY_MODE_FAST,
|
||||
}
|
||||
DECAY_MODE_OPTIONS = DecayMode.options("SLOW", "FAST", prefix="DECAY_MODE_")
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
fan.fan_schema(HBridgeFan)
|
||||
|
||||
@@ -28,12 +28,9 @@ HDC302XComponent = hdc302x_ns.class_(
|
||||
)
|
||||
|
||||
HDC302XPowerMode = hdc302x_ns.enum("HDC302XPowerMode")
|
||||
POWER_MODE_OPTIONS = {
|
||||
"HIGH_ACCURACY": HDC302XPowerMode.HIGH_ACCURACY,
|
||||
"BALANCED": HDC302XPowerMode.BALANCED,
|
||||
"LOW_POWER": HDC302XPowerMode.LOW_POWER,
|
||||
"ULTRA_LOW_POWER": HDC302XPowerMode.ULTRA_LOW_POWER,
|
||||
}
|
||||
POWER_MODE_OPTIONS = HDC302XPowerMode.options(
|
||||
"HIGH_ACCURACY", "BALANCED", "LOW_POWER", "ULTRA_LOW_POWER"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -78,25 +78,15 @@ PROTOCOLS = {
|
||||
|
||||
CONF_HORIZONTAL_DEFAULT = "horizontal_default"
|
||||
HorizontalDirections = heatpumpir_ns.enum("HorizontalDirections")
|
||||
HORIZONTAL_DIRECTIONS = {
|
||||
"auto": HorizontalDirections.HORIZONTAL_DIRECTION_AUTO,
|
||||
"middle": HorizontalDirections.HORIZONTAL_DIRECTION_MIDDLE,
|
||||
"left": HorizontalDirections.HORIZONTAL_DIRECTION_LEFT,
|
||||
"mleft": HorizontalDirections.HORIZONTAL_DIRECTION_MLEFT,
|
||||
"mright": HorizontalDirections.HORIZONTAL_DIRECTION_MRIGHT,
|
||||
"right": HorizontalDirections.HORIZONTAL_DIRECTION_RIGHT,
|
||||
}
|
||||
HORIZONTAL_DIRECTIONS = HorizontalDirections.options(
|
||||
"auto", "middle", "left", "mleft", "mright", "right", prefix="HORIZONTAL_DIRECTION_"
|
||||
)
|
||||
|
||||
CONF_VERTICAL_DEFAULT = "vertical_default"
|
||||
VerticalDirections = heatpumpir_ns.enum("VerticalDirections")
|
||||
VERTICAL_DIRECTIONS = {
|
||||
"auto": VerticalDirections.VERTICAL_DIRECTION_AUTO,
|
||||
"up": VerticalDirections.VERTICAL_DIRECTION_UP,
|
||||
"mup": VerticalDirections.VERTICAL_DIRECTION_MUP,
|
||||
"middle": VerticalDirections.VERTICAL_DIRECTION_MIDDLE,
|
||||
"mdown": VerticalDirections.VERTICAL_DIRECTION_MDOWN,
|
||||
"down": VerticalDirections.VERTICAL_DIRECTION_DOWN,
|
||||
}
|
||||
VERTICAL_DIRECTIONS = VerticalDirections.options(
|
||||
"auto", "up", "mup", "middle", "mdown", "down", prefix="VERTICAL_DIRECTION_"
|
||||
)
|
||||
|
||||
|
||||
def _default_visual(config: ConfigType) -> ConfigType:
|
||||
|
||||
@@ -41,11 +41,9 @@ INITIAL_MODES = {
|
||||
CONF_VOLTAGE: HLW8012InitialMode.HLW8012_INITIAL_MODE_VOLTAGE,
|
||||
}
|
||||
|
||||
MODELS = {
|
||||
"HLW8012": HLW8012SensorModels.HLW8012_SENSOR_MODEL_HLW8012,
|
||||
"CSE7759": HLW8012SensorModels.HLW8012_SENSOR_MODEL_CSE7759,
|
||||
"BL0937": HLW8012SensorModels.HLW8012_SENSOR_MODEL_BL0937,
|
||||
}
|
||||
MODELS = HLW8012SensorModels.options(
|
||||
"HLW8012", "CSE7759", "BL0937", prefix="HLW8012_SENSOR_MODEL_"
|
||||
)
|
||||
|
||||
CONF_CF1_PIN = "cf1_pin"
|
||||
CONF_CF_PIN = "cf_pin"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import button
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import ICON_AIR_FILTER
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import CONF_HOERMANN_HCP_ID, HoermannHcp
|
||||
from .. import CONF_HOERMANN_HCP_ID, HoermannHcp, hoermann_hcp_ns
|
||||
|
||||
DEPENDENCIES = ["hoermann_hcp"]
|
||||
|
||||
@@ -12,6 +13,10 @@ CONF_VENT = "vent"
|
||||
|
||||
ICON_GARAGE_OPEN_VARIANT = "mdi:garage-open-variant"
|
||||
|
||||
HoermannHcpVentButton = hoermann_hcp_ns.class_("HoermannHcpVentButton", button.Button)
|
||||
HoermannHcpHalfOpenButton = hoermann_hcp_ns.class_(
|
||||
"HoermannHcpHalfOpenButton", button.Button
|
||||
)
|
||||
|
||||
BUTTON_KEYS = (CONF_VENT, CONF_HALF_OPEN)
|
||||
|
||||
@@ -20,10 +25,10 @@ CONFIG_SCHEMA = cv.All(
|
||||
{
|
||||
cv.GenerateID(CONF_HOERMANN_HCP_ID): cv.use_id(HoermannHcp),
|
||||
cv.Optional(CONF_VENT): button.button_schema(
|
||||
button.ApplyButton, icon=ICON_AIR_FILTER
|
||||
HoermannHcpVentButton, icon=ICON_AIR_FILTER
|
||||
),
|
||||
cv.Optional(CONF_HALF_OPEN): button.button_schema(
|
||||
button.ApplyButton, icon=ICON_GARAGE_OPEN_VARIANT
|
||||
HoermannHcpHalfOpenButton, icon=ICON_GARAGE_OPEN_VARIANT
|
||||
),
|
||||
}
|
||||
),
|
||||
@@ -32,6 +37,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
buttons = button.sub_buttons(config, parent=config[CONF_HOERMANN_HCP_ID])
|
||||
await buttons(CONF_VENT, None, apply="vent_door()")
|
||||
await buttons(CONF_HALF_OPEN, None, apply="half_open_door()")
|
||||
parent = await cg.get_variable(config[CONF_HOERMANN_HCP_ID])
|
||||
for key in BUTTON_KEYS:
|
||||
if (conf := config.get(key)) is not None:
|
||||
await button.new_button(conf, parent)
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../hoermann_hcp.h"
|
||||
|
||||
namespace esphome::hoermann_hcp {
|
||||
|
||||
// The door commands the cover has no equivalent for. A refused command is already reported by the hub and
|
||||
// leaves nothing to correct here, because a button carries no state of its own.
|
||||
class HoermannHcpButton : public button::Button {
|
||||
public:
|
||||
explicit HoermannHcpButton(HoermannHcp *parent) : parent_(parent) {}
|
||||
|
||||
protected:
|
||||
HoermannHcp *const parent_;
|
||||
};
|
||||
|
||||
class HoermannHcpVentButton final : public HoermannHcpButton {
|
||||
public:
|
||||
using HoermannHcpButton::HoermannHcpButton;
|
||||
|
||||
protected:
|
||||
void press_action() override { this->parent_->vent_door(); }
|
||||
};
|
||||
|
||||
class HoermannHcpHalfOpenButton final : public HoermannHcpButton {
|
||||
public:
|
||||
using HoermannHcpButton::HoermannHcpButton;
|
||||
|
||||
protected:
|
||||
void press_action() override { this->parent_->half_open_door(); }
|
||||
};
|
||||
|
||||
} // namespace esphome::hoermann_hcp
|
||||
@@ -20,10 +20,7 @@ CONF_MIN_PRESSURE = "min_pressure"
|
||||
CONF_MAX_PRESSURE = "max_pressure"
|
||||
TRANSFER_FUNCTION = "transfer_function"
|
||||
ABP2TRANFERFUNCTION = honeywellabp2_ns.enum("ABP2TRANFERFUNCTION")
|
||||
TRANS_FUNC_OPTIONS = {
|
||||
"A": ABP2TRANFERFUNCTION.ABP2_TRANS_FUNC_A,
|
||||
"B": ABP2TRANFERFUNCTION.ABP2_TRANS_FUNC_B,
|
||||
}
|
||||
TRANS_FUNC_OPTIONS = ABP2TRANFERFUNCTION.options("A", "B", prefix="ABP2_TRANS_FUNC_")
|
||||
|
||||
HONEYWELLABP2Sensor = honeywellabp2_ns.class_(
|
||||
"HONEYWELLABP2Sensor", sensor.Sensor, cg.PollingComponent, i2c.I2CDevice
|
||||
|
||||
@@ -31,6 +31,10 @@ bool random_bytes(uint8_t *data, size_t len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The host has no interrupts to mask
|
||||
InterruptLock::InterruptLock() {}
|
||||
InterruptLock::~InterruptLock() {}
|
||||
|
||||
// Host platform uses std::mutex for proper thread synchronization
|
||||
Mutex::Mutex() { handle_ = new std::mutex(); }
|
||||
Mutex::~Mutex() { delete static_cast<std::mutex *>(handle_); }
|
||||
|
||||
@@ -27,11 +27,9 @@ HTU21DComponent = htu21d_ns.class_(
|
||||
)
|
||||
HTU21DSensorModels = htu21d_ns.enum("HTU21DSensorModels")
|
||||
|
||||
MODELS = {
|
||||
"HTU21D": HTU21DSensorModels.HTU21D_SENSOR_MODEL_HTU21D,
|
||||
"SI7021": HTU21DSensorModels.HTU21D_SENSOR_MODEL_SI7021,
|
||||
"SHT21": HTU21DSensorModels.HTU21D_SENSOR_MODEL_SHT21,
|
||||
}
|
||||
MODELS = HTU21DSensorModels.options(
|
||||
"HTU21D", "SI7021", "SHT21", prefix="HTU21D_SENSOR_MODEL_"
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
|
||||
@@ -97,37 +97,32 @@ CONF_MIN_REFRESH_RATE = "min_refresh_rate"
|
||||
|
||||
# Map to hub75 library enums (in global namespace)
|
||||
Hub75ShiftDriver = cg.global_ns.enum("Hub75ShiftDriver", is_class=True)
|
||||
SHIFT_DRIVERS = {
|
||||
"GENERIC": Hub75ShiftDriver.GENERIC,
|
||||
"FM6126A": Hub75ShiftDriver.FM6126A,
|
||||
"ICN2038S": Hub75ShiftDriver.ICN2038S,
|
||||
"FM6124": Hub75ShiftDriver.FM6124,
|
||||
"MBI5124": Hub75ShiftDriver.MBI5124,
|
||||
"DP3246": Hub75ShiftDriver.DP3246,
|
||||
}
|
||||
SHIFT_DRIVERS = Hub75ShiftDriver.options(
|
||||
"GENERIC", "FM6126A", "ICN2038S", "FM6124", "MBI5124", "DP3246"
|
||||
)
|
||||
|
||||
Hub75PanelLayout = cg.global_ns.enum("Hub75PanelLayout", is_class=True)
|
||||
PANEL_LAYOUTS = {
|
||||
"HORIZONTAL": Hub75PanelLayout.HORIZONTAL,
|
||||
"TOP_LEFT_DOWN": Hub75PanelLayout.TOP_LEFT_DOWN,
|
||||
"TOP_RIGHT_DOWN": Hub75PanelLayout.TOP_RIGHT_DOWN,
|
||||
"BOTTOM_LEFT_UP": Hub75PanelLayout.BOTTOM_LEFT_UP,
|
||||
"BOTTOM_RIGHT_UP": Hub75PanelLayout.BOTTOM_RIGHT_UP,
|
||||
"TOP_LEFT_DOWN_ZIGZAG": Hub75PanelLayout.TOP_LEFT_DOWN_ZIGZAG,
|
||||
"TOP_RIGHT_DOWN_ZIGZAG": Hub75PanelLayout.TOP_RIGHT_DOWN_ZIGZAG,
|
||||
"BOTTOM_LEFT_UP_ZIGZAG": Hub75PanelLayout.BOTTOM_LEFT_UP_ZIGZAG,
|
||||
"BOTTOM_RIGHT_UP_ZIGZAG": Hub75PanelLayout.BOTTOM_RIGHT_UP_ZIGZAG,
|
||||
}
|
||||
PANEL_LAYOUTS = Hub75PanelLayout.options(
|
||||
"HORIZONTAL",
|
||||
"TOP_LEFT_DOWN",
|
||||
"TOP_RIGHT_DOWN",
|
||||
"BOTTOM_LEFT_UP",
|
||||
"BOTTOM_RIGHT_UP",
|
||||
"TOP_LEFT_DOWN_ZIGZAG",
|
||||
"TOP_RIGHT_DOWN_ZIGZAG",
|
||||
"BOTTOM_LEFT_UP_ZIGZAG",
|
||||
"BOTTOM_RIGHT_UP_ZIGZAG",
|
||||
)
|
||||
|
||||
Hub75ScanWiring = cg.global_ns.enum("Hub75ScanWiring", is_class=True)
|
||||
SCAN_WIRINGS = {
|
||||
"STANDARD_TWO_SCAN": Hub75ScanWiring.STANDARD_TWO_SCAN,
|
||||
"SCAN_1_4_16PX_HIGH": Hub75ScanWiring.SCAN_1_4_16PX_HIGH,
|
||||
"SCAN_1_8_32PX_HIGH": Hub75ScanWiring.SCAN_1_8_32PX_HIGH,
|
||||
"SCAN_1_8_32PX_FULL": Hub75ScanWiring.SCAN_1_8_32PX_FULL,
|
||||
"SCAN_1_8_40PX_HIGH": Hub75ScanWiring.SCAN_1_8_40PX_HIGH,
|
||||
"SCAN_1_8_64PX_HIGH": Hub75ScanWiring.SCAN_1_8_64PX_HIGH,
|
||||
}
|
||||
SCAN_WIRINGS = Hub75ScanWiring.options(
|
||||
"STANDARD_TWO_SCAN",
|
||||
"SCAN_1_4_16PX_HIGH",
|
||||
"SCAN_1_8_32PX_HIGH",
|
||||
"SCAN_1_8_32PX_FULL",
|
||||
"SCAN_1_8_40PX_HIGH",
|
||||
"SCAN_1_8_64PX_HIGH",
|
||||
)
|
||||
|
||||
|
||||
def _validate_scan_wiring(value: Any) -> str:
|
||||
|
||||
@@ -67,9 +67,7 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
|
||||
|
||||
this->status_clear_warning();
|
||||
|
||||
if (data & 0x800000ULL) {
|
||||
data |= 0xFF000000ULL;
|
||||
}
|
||||
data = static_cast<uint32_t>(sign_extend<24>(data));
|
||||
|
||||
if (result != nullptr)
|
||||
*result = data;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <memory>
|
||||
|
||||
namespace esphome::i2c {
|
||||
|
||||
@@ -22,6 +21,10 @@ void I2CBus::i2c_scan_() {
|
||||
}
|
||||
}
|
||||
|
||||
void log_wrong_chip_id(uint8_t id, uint8_t expected) {
|
||||
ESP_LOGE(TAG, "Wrong chip ID 0x%02X, expected 0x%02X", id, expected);
|
||||
}
|
||||
|
||||
ErrorCode I2CDevice::read_register(uint8_t a_register, uint8_t *data, size_t len) {
|
||||
return bus_->write_readv(this->address_, &a_register, 1, data, len);
|
||||
}
|
||||
@@ -59,11 +62,22 @@ bool I2CDevice::read_bytes_16(uint8_t a_register, uint16_t *data, uint8_t len) {
|
||||
}
|
||||
|
||||
bool I2CDevice::write_bytes_16(uint8_t a_register, const uint16_t *data, uint8_t len) const {
|
||||
// we have to copy in order to be able to change byte order
|
||||
std::unique_ptr<uint16_t[]> temp{new uint16_t[len]};
|
||||
for (size_t i = 0; i < len; i++)
|
||||
temp[i] = htoi2cs(data[i]);
|
||||
return write_register(a_register, reinterpret_cast<const uint8_t *>(temp.get()), len * 2) == ERROR_OK;
|
||||
const size_t size = 1 + len * 2;
|
||||
SmallBufferWithHeapFallback<17> buffer_alloc(size); // Register plus up to 8 words
|
||||
uint8_t *buffer = buffer_alloc.get();
|
||||
|
||||
buffer[0] = a_register;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
const uint16_t word = data[i];
|
||||
buffer[1 + i * 2] = word >> 8;
|
||||
buffer[2 + i * 2] = word;
|
||||
}
|
||||
return this->bus_->write_readv(this->address_, buffer, size, nullptr, 0) == ERROR_OK;
|
||||
}
|
||||
|
||||
bool I2CDevice::write_byte_16(uint8_t a_register, uint16_t data) const {
|
||||
const uint8_t buffer[3] = {a_register, static_cast<uint8_t>(data >> 8), static_cast<uint8_t>(data)};
|
||||
return this->bus_->write_readv(this->address_, buffer, sizeof(buffer), nullptr, 0) == ERROR_OK;
|
||||
}
|
||||
|
||||
I2CRegister &I2CRegister::operator=(uint8_t value) {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/optional.h"
|
||||
#include "i2c_bus.h"
|
||||
|
||||
@@ -12,6 +14,9 @@ namespace esphome::i2c {
|
||||
|
||||
class I2CDevice; // forward declaration
|
||||
|
||||
/// Out of line so each check_chip_id() caller only pays for a call.
|
||||
void log_wrong_chip_id(uint8_t id, uint8_t expected);
|
||||
|
||||
/// @brief This class is used to create I2CRegister objects that act as proxies to read/write internal registers on an
|
||||
/// I2C device.
|
||||
/// @details
|
||||
@@ -208,6 +213,19 @@ class I2CDevice {
|
||||
/// @return an i2c::ErrorCode
|
||||
ErrorCode write_register16(uint16_t a_register, const uint8_t *data, size_t len) const;
|
||||
|
||||
/// Read the 8-bit ID at \p a_register and accept it when it matches \p expected in the bits set in \p mask.
|
||||
/// Otherwise mark \p component failed and return false.
|
||||
bool check_chip_id(Component *component, uint8_t a_register, uint8_t expected, uint8_t mask = 0xFF) {
|
||||
uint8_t id;
|
||||
const ErrorCode err = this->read_register(a_register, &id, 1);
|
||||
if (err == ERROR_OK && (id & mask) == (expected & mask))
|
||||
return true;
|
||||
if (err == ERROR_OK)
|
||||
log_wrong_chip_id(id, expected & mask);
|
||||
component->mark_failed(err == ERROR_OK ? LOG_STR("Wrong chip ID") : LOG_STR(ESP_LOG_MSG_COMM_FAIL));
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Compat APIs
|
||||
/// All methods below have been added for compatibility reasons. They do not bring any functionality and therefore on
|
||||
@@ -264,7 +282,7 @@ class I2CDevice {
|
||||
|
||||
bool write_byte(uint8_t a_register, uint8_t data) const { return write_bytes(a_register, &data, 1); }
|
||||
|
||||
bool write_byte_16(uint8_t a_register, uint16_t data) const { return write_bytes_16(a_register, &data, 1); }
|
||||
bool write_byte_16(uint8_t a_register, uint16_t data) const;
|
||||
|
||||
protected:
|
||||
uint8_t address_{0x00}; ///< store the address of the device on the bus
|
||||
|
||||
@@ -68,18 +68,19 @@ INTERNAL_DAC_OPTIONS = {
|
||||
}
|
||||
|
||||
i2s_comm_format_t = cg.global_ns.enum("i2s_comm_format_t")
|
||||
I2C_COMM_FMT_OPTIONS = {
|
||||
"stand_i2s": i2s_comm_format_t.I2S_COMM_FORMAT_STAND_I2S,
|
||||
"stand_msb": i2s_comm_format_t.I2S_COMM_FORMAT_STAND_MSB,
|
||||
"stand_pcm_short": i2s_comm_format_t.I2S_COMM_FORMAT_STAND_PCM_SHORT,
|
||||
"stand_pcm_long": i2s_comm_format_t.I2S_COMM_FORMAT_STAND_PCM_LONG,
|
||||
"stand_max": i2s_comm_format_t.I2S_COMM_FORMAT_STAND_MAX,
|
||||
"i2s_msb": i2s_comm_format_t.I2S_COMM_FORMAT_I2S_MSB,
|
||||
"i2s_lsb": i2s_comm_format_t.I2S_COMM_FORMAT_I2S_LSB,
|
||||
"pcm": i2s_comm_format_t.I2S_COMM_FORMAT_PCM,
|
||||
"pcm_short": i2s_comm_format_t.I2S_COMM_FORMAT_PCM_SHORT,
|
||||
"pcm_long": i2s_comm_format_t.I2S_COMM_FORMAT_PCM_LONG,
|
||||
}
|
||||
I2C_COMM_FMT_OPTIONS = i2s_comm_format_t.options(
|
||||
"stand_i2s",
|
||||
"stand_msb",
|
||||
"stand_pcm_short",
|
||||
"stand_pcm_long",
|
||||
"stand_max",
|
||||
"i2s_msb",
|
||||
"i2s_lsb",
|
||||
"pcm",
|
||||
"pcm_short",
|
||||
"pcm_long",
|
||||
prefix="I2S_COMM_FORMAT_",
|
||||
)
|
||||
|
||||
INTERNAL_DAC_VARIANTS = [esp32.VARIANT_ESP32]
|
||||
|
||||
|
||||
@@ -11,12 +11,9 @@ DEPENDENCIES = ["spi"]
|
||||
|
||||
# Enum proxies (must match the C++ enum values exactly)
|
||||
ICM20689AccelRange = icm20689_ns.enum("ICM20689AccelRange")
|
||||
ACCEL_RANGE_OPTIONS = {
|
||||
"2G": ICM20689AccelRange.ICM20689_ACCEL_RANGE_2G,
|
||||
"4G": ICM20689AccelRange.ICM20689_ACCEL_RANGE_4G,
|
||||
"8G": ICM20689AccelRange.ICM20689_ACCEL_RANGE_8G,
|
||||
"16G": ICM20689AccelRange.ICM20689_ACCEL_RANGE_16G,
|
||||
}
|
||||
ACCEL_RANGE_OPTIONS = ICM20689AccelRange.options(
|
||||
"2G", "4G", "8G", "16G", prefix="ICM20689_ACCEL_RANGE_"
|
||||
)
|
||||
|
||||
ICM20689GyroRange = icm20689_ns.enum("ICM20689GyroRange")
|
||||
GYRO_RANGE_OPTIONS = {
|
||||
|
||||
@@ -57,14 +57,14 @@ Inkplate = inkplate_ns.class_(
|
||||
|
||||
InkplateModel = inkplate_ns.enum("InkplateModel")
|
||||
|
||||
MODELS = {
|
||||
"inkplate_6": InkplateModel.INKPLATE_6,
|
||||
"inkplate_10": InkplateModel.INKPLATE_10,
|
||||
"inkplate_6_plus": InkplateModel.INKPLATE_6_PLUS,
|
||||
"inkplate_6_v2": InkplateModel.INKPLATE_6_V2,
|
||||
"inkplate_5": InkplateModel.INKPLATE_5,
|
||||
"inkplate_5_v2": InkplateModel.INKPLATE_5_V2,
|
||||
}
|
||||
MODELS = InkplateModel.options(
|
||||
"inkplate_6",
|
||||
"inkplate_10",
|
||||
"inkplate_6_plus",
|
||||
"inkplate_6_v2",
|
||||
"inkplate_5",
|
||||
"inkplate_5_v2",
|
||||
)
|
||||
|
||||
CONF_CUSTOM_WAVEFORM = "custom_waveform"
|
||||
|
||||
|
||||
@@ -28,11 +28,9 @@ INTEGRATION_TIMES = {
|
||||
"d": IntegrationSensorTime.INTEGRATION_SENSOR_TIME_DAY,
|
||||
}
|
||||
IntegrationMethod = integration_ns.enum("IntegrationMethod")
|
||||
INTEGRATION_METHODS = {
|
||||
"trapezoid": IntegrationMethod.INTEGRATION_METHOD_TRAPEZOID,
|
||||
"left": IntegrationMethod.INTEGRATION_METHOD_LEFT,
|
||||
"right": IntegrationMethod.INTEGRATION_METHOD_RIGHT,
|
||||
}
|
||||
INTEGRATION_METHODS = IntegrationMethod.options(
|
||||
"trapezoid", "left", "right", prefix="INTEGRATION_METHOD_"
|
||||
)
|
||||
|
||||
CONF_TIME_UNIT = "time_unit"
|
||||
CONF_INTEGRATION_METHOD = "integration_method"
|
||||
|
||||
@@ -17,10 +17,7 @@ Jsnsr04tComponent = jsn_sr04t_ns.class_(
|
||||
"Jsnsr04tComponent", sensor.Sensor, cg.PollingComponent, uart.UARTDevice
|
||||
)
|
||||
Model = jsn_sr04t_ns.enum("Model")
|
||||
MODEL = {
|
||||
"jsn_sr04t": Model.JSN_SR04T,
|
||||
"aj_sr04m": Model.AJ_SR04M,
|
||||
}
|
||||
MODEL = Model.options("jsn_sr04t", "aj_sr04m")
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
sensor.sensor_schema(
|
||||
|
||||
@@ -25,10 +25,9 @@ DEPENDENCIES = ["i2c"]
|
||||
lc709203f_ns = cg.esphome_ns.namespace("lc709203f")
|
||||
|
||||
LC709203FBatteryVoltage = lc709203f_ns.enum("LC709203FBatteryVoltage")
|
||||
BATTERY_VOLTAGE_OPTIONS = {
|
||||
"3.7": LC709203FBatteryVoltage.LC709203F_BATTERY_VOLTAGE_3_7,
|
||||
"3.8": LC709203FBatteryVoltage.LC709203F_BATTERY_VOLTAGE_3_8,
|
||||
}
|
||||
BATTERY_VOLTAGE_OPTIONS = LC709203FBatteryVoltage.options(
|
||||
"3.7", "3.8", prefix="LC709203F_BATTERY_VOLTAGE_"
|
||||
)
|
||||
|
||||
lc709203f = lc709203f_ns.class_("Lc709203f", cg.PollingComponent, i2c.I2CDevice)
|
||||
|
||||
|
||||
@@ -15,25 +15,29 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import CONF_LD2410_ID, LD2410Component
|
||||
from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns
|
||||
|
||||
FactoryResetButton = ld2410_ns.class_("FactoryResetButton", button.Button)
|
||||
QueryButton = ld2410_ns.class_("QueryButton", button.Button)
|
||||
RestartButton = ld2410_ns.class_("RestartButton", button.Button)
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
cv.GenerateID(CONF_ID): cv.declare_id(cg.EntityBase),
|
||||
cv.GenerateID(CONF_LD2410_ID): cv.use_id(LD2410Component),
|
||||
cv.Optional(CONF_FACTORY_RESET): button.button_schema(
|
||||
button.ApplyButton,
|
||||
FactoryResetButton,
|
||||
device_class=DEVICE_CLASS_RESTART,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
icon=ICON_RESTART_ALERT,
|
||||
),
|
||||
cv.Optional(CONF_RESTART): button.button_schema(
|
||||
button.ApplyButton,
|
||||
RestartButton,
|
||||
device_class=DEVICE_CLASS_RESTART,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
icon=ICON_RESTART,
|
||||
),
|
||||
cv.Optional(CONF_QUERY_PARAMS): button.button_schema(
|
||||
button.ApplyButton,
|
||||
QueryButton,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
icon=ICON_DATABASE,
|
||||
),
|
||||
@@ -43,10 +47,6 @@ CONFIG_SCHEMA = {
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
hub = await cg.get_variable(config[CONF_LD2410_ID])
|
||||
buttons = button.sub_buttons(config, parent=hub)
|
||||
await buttons(
|
||||
CONF_FACTORY_RESET, hub.set_factory_reset_button, apply="factory_reset()"
|
||||
)
|
||||
await buttons(
|
||||
CONF_RESTART, hub.set_restart_button, apply="restart_and_read_all_info()"
|
||||
)
|
||||
await buttons(CONF_QUERY_PARAMS, hub.set_query_button, apply="read_all_info()")
|
||||
await buttons(CONF_FACTORY_RESET, hub.set_factory_reset_button)
|
||||
await buttons(CONF_RESTART, hub.set_restart_button)
|
||||
await buttons(CONF_QUERY_PARAMS, hub.set_query_button)
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "factory_reset_button.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
void FactoryResetButton::press_action() { this->parent_->factory_reset(); }
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../ld2410.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
class FactoryResetButton final : public button::Button, public Parented<LD2410Component> {
|
||||
public:
|
||||
FactoryResetButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "query_button.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
void QueryButton::press_action() { this->parent_->read_all_info(); }
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../ld2410.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
class QueryButton final : public button::Button, public Parented<LD2410Component> {
|
||||
public:
|
||||
QueryButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "restart_button.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); }
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../ld2410.h"
|
||||
|
||||
namespace esphome::ld2410 {
|
||||
|
||||
class RestartButton final : public button::Button, public Parented<LD2410Component> {
|
||||
public:
|
||||
RestartButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::ld2410
|
||||
Loaded 100 of 354 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user