mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 23:14:54 +01:00
fix CONF_* and macros
This commit is contained in:
parent
95c16c3453
commit
7a357d1b6b
6 changed files with 127 additions and 120 deletions
|
@ -4,7 +4,19 @@ from esphome import automation, pins
|
||||||
from esphome.components import i2c, sensor, binary_sensor, text_sensor
|
from esphome.components import i2c, sensor, binary_sensor, text_sensor
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
|
CONF_ANALOG,
|
||||||
|
CONF_SENSOR,
|
||||||
CONF_FREQUENCY,
|
CONF_FREQUENCY,
|
||||||
|
CONF_POWER,
|
||||||
|
CONF_LEVEL,
|
||||||
|
CONF_ATTENUATION,
|
||||||
|
CONF_CHANNELS,
|
||||||
|
CONF_MODE,
|
||||||
|
CONF_SOURCE,
|
||||||
|
CONF_THRESHOLD,
|
||||||
|
CONF_GAIN,
|
||||||
|
CONF_PRESET,
|
||||||
|
CONF_TEXT,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
ICON_CHIP,
|
ICON_CHIP,
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
@ -19,7 +31,7 @@ UNIT_MEGA_HERTZ = "MHz"
|
||||||
UNIT_KILO_HERTZ = "kHz"
|
UNIT_KILO_HERTZ = "kHz"
|
||||||
UNIT_MILLI_VOLT = "mV"
|
UNIT_MILLI_VOLT = "mV"
|
||||||
UNIT_MICRO_AMPERE = "mA"
|
UNIT_MICRO_AMPERE = "mA"
|
||||||
UNIT_DECIBEL_MICRO_VOLT = "dBµV"
|
UNIT_DECIBEL_MICRO_VOLT = "dBuV"
|
||||||
UNIT_PICO_FARAD = "pF"
|
UNIT_PICO_FARAD = "pF"
|
||||||
UNIT_KILO_OHM = "kOhm"
|
UNIT_KILO_OHM = "kOhm"
|
||||||
UNIT_DECIBEL_FS = "dBfs"
|
UNIT_DECIBEL_FS = "dBfs"
|
||||||
|
@ -39,17 +51,14 @@ Si4713Component = si4713_ns.class_(
|
||||||
|
|
||||||
CONF_SI4713_ID = "si4713_id"
|
CONF_SI4713_ID = "si4713_id"
|
||||||
CONF_RESET_PIN = "reset_pin"
|
CONF_RESET_PIN = "reset_pin"
|
||||||
CONF_SECTION_TUNER = "tuner"
|
CONF_TUNER = "tuner"
|
||||||
CONF_SECTION_ANALOG = "analog"
|
CONF_DIGITAL = "digital"
|
||||||
CONF_SECTION_DIGITAL = "digital"
|
CONF_PILOT = "pilot"
|
||||||
CONF_SECTION_PILOT = "pilot"
|
CONF_REFCLK = "refclk"
|
||||||
CONF_SECTION_REFCLK = "refclk"
|
CONF_COMPRESSOR = "compressor"
|
||||||
CONF_SECTION_COMPRESSOR = "compressor"
|
CONF_LIMITER = "limiter"
|
||||||
CONF_SECTION_LIMITER = "limiter"
|
CONF_ASQ = "asq"
|
||||||
CONF_SECTION_ASQ = "asq"
|
CONF_RDS = "rds"
|
||||||
CONF_SECTION_RDS = "rds"
|
|
||||||
CONF_SECTION_OUTPUT = "output"
|
|
||||||
CONF_SECTION_SENSOR = "sensor"
|
|
||||||
# general config
|
# general config
|
||||||
CONF_OP_MODE = "op_mode"
|
CONF_OP_MODE = "op_mode"
|
||||||
CONF_MUTE = "mute"
|
CONF_MUTE = "mute"
|
||||||
|
@ -58,16 +67,16 @@ CONF_PRE_EMPHASIS = "pre_emphasis"
|
||||||
# tuner
|
# tuner
|
||||||
# CONF_FREQUENCY = "frequency"
|
# CONF_FREQUENCY = "frequency"
|
||||||
CONF_DEVIATION = "deviation"
|
CONF_DEVIATION = "deviation"
|
||||||
CONF_POWER = "power"
|
# CONF_POWER = "power"
|
||||||
CONF_ANTCAP = "antcap"
|
CONF_ANTCAP = "antcap"
|
||||||
# analog
|
# analog
|
||||||
CONF_LEVEL = "level"
|
# CONF_LEVEL = "level"
|
||||||
CONF_ATTENUATION = "attenuation"
|
# CONF_ATTENUATION = "attenuation"
|
||||||
# digital
|
# digital
|
||||||
CONF_SAMPLE_RATE = "sample_rate"
|
CONF_SAMPLE_RATE = "sample_rate"
|
||||||
CONF_SAMPLE_BITS = "sample_bits"
|
CONF_SAMPLE_BITS = "sample_bits"
|
||||||
CONF_CHANNELS = "channels"
|
# CONF_CHANNELS = "channels"
|
||||||
CONF_MODE = "mode"
|
# CONF_MODE = "mode"
|
||||||
CONF_CLOCK_EDGE = "clock_edge"
|
CONF_CLOCK_EDGE = "clock_edge"
|
||||||
# pilot
|
# pilot
|
||||||
CONF_ENABLE = "enable"
|
CONF_ENABLE = "enable"
|
||||||
|
@ -75,15 +84,15 @@ CONF_ENABLE = "enable"
|
||||||
CONF_DEVIATION = "deviation"
|
CONF_DEVIATION = "deviation"
|
||||||
# refclk
|
# refclk
|
||||||
# CONF_FREQUENCY = "frequency"
|
# CONF_FREQUENCY = "frequency"
|
||||||
CONF_SOURCE = "source"
|
# CONF_SOURCE = "source"
|
||||||
CONF_PRESCALER = "prescaler"
|
CONF_PRESCALER = "prescaler"
|
||||||
# compressor
|
# compressor
|
||||||
CONF_ENABLE = "enable"
|
CONF_ENABLE = "enable"
|
||||||
CONF_THRESHOLD = "threshold"
|
# CONF_THRESHOLD = "threshold"
|
||||||
CONF_ATTACK = "attack"
|
CONF_ATTACK = "attack"
|
||||||
CONF_RELEASE = "release"
|
CONF_RELEASE = "release"
|
||||||
CONF_GAIN = "gain"
|
# CONF_GAIN = "gain"
|
||||||
CONF_PRESET = "preset"
|
# CONF_PRESET = "preset"
|
||||||
# limiter
|
# limiter
|
||||||
CONF_ENABLE = "enable"
|
CONF_ENABLE = "enable"
|
||||||
CONF_RELEASE_TIME = "release_time"
|
CONF_RELEASE_TIME = "release_time"
|
||||||
|
@ -99,7 +108,7 @@ CONF_DURATION_HIGH = "duration_high"
|
||||||
CONF_ENABLE = "enable"
|
CONF_ENABLE = "enable"
|
||||||
CONF_DEVIATION = "deviation"
|
CONF_DEVIATION = "deviation"
|
||||||
CONF_STATION = "station"
|
CONF_STATION = "station"
|
||||||
CONF_TEXT = "text"
|
# CONF_TEXT = "text"
|
||||||
# output
|
# output
|
||||||
CONF_GPIO1 = "gpio1"
|
CONF_GPIO1 = "gpio1"
|
||||||
CONF_GPIO2 = "gpio2"
|
CONF_GPIO2 = "gpio2"
|
||||||
|
@ -351,16 +360,16 @@ CONFIG_SCHEMA = (
|
||||||
cv.Optional(CONF_MUTE, default=False): cv.boolean,
|
cv.Optional(CONF_MUTE, default=False): cv.boolean,
|
||||||
cv.Optional(CONF_MONO, default=False): cv.boolean,
|
cv.Optional(CONF_MONO, default=False): cv.boolean,
|
||||||
cv.Optional(CONF_PRE_EMPHASIS, default="75us"): cv.enum(PRE_EMPHASIS),
|
cv.Optional(CONF_PRE_EMPHASIS, default="75us"): cv.enum(PRE_EMPHASIS),
|
||||||
cv.Optional(CONF_SECTION_TUNER): TUNER_SCHEMA,
|
cv.Optional(CONF_TUNER): TUNER_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_ANALOG): ANALOG_SCHEMA,
|
cv.Optional(CONF_ANALOG): ANALOG_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_DIGITAL): DIGITAL_SCHEMA,
|
cv.Optional(CONF_DIGITAL): DIGITAL_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_PILOT): PILOT_SCHEMA,
|
cv.Optional(CONF_PILOT): PILOT_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_REFCLK): REFCLK_SCHEMA,
|
cv.Optional(CONF_REFCLK): REFCLK_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_COMPRESSOR): COMPRESSOR_SCHEMA,
|
cv.Optional(CONF_COMPRESSOR): COMPRESSOR_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_LIMITER): LIMITER_SCHEMA,
|
cv.Optional(CONF_LIMITER): LIMITER_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_ASQ): ASQ_SCHEMA,
|
cv.Optional(CONF_ASQ): ASQ_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_RDS): RDS_SCHEMA,
|
cv.Optional(CONF_RDS): RDS_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_SENSOR): SENSOR_SCHEMA,
|
cv.Optional(CONF_SENSOR): SENSOR_SCHEMA,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.extend(cv.polling_component_schema("60s"))
|
.extend(cv.polling_component_schema("60s"))
|
||||||
|
@ -424,39 +433,39 @@ async def to_code(config):
|
||||||
await set_var(config, CONF_MUTE, var.set_mute)
|
await set_var(config, CONF_MUTE, var.set_mute)
|
||||||
await set_var(config, CONF_MONO, var.set_mono)
|
await set_var(config, CONF_MONO, var.set_mono)
|
||||||
await set_var(config, CONF_PRE_EMPHASIS, var.set_pre_emphasis)
|
await set_var(config, CONF_PRE_EMPHASIS, var.set_pre_emphasis)
|
||||||
if tuner_config := config.get(CONF_SECTION_TUNER):
|
if tuner_config := config.get(CONF_TUNER):
|
||||||
await set_var(tuner_config, CONF_FREQUENCY, var.set_frequency)
|
await set_var(tuner_config, CONF_FREQUENCY, var.set_frequency)
|
||||||
await set_var(tuner_config, CONF_DEVIATION, var.set_audio_deviation)
|
await set_var(tuner_config, CONF_DEVIATION, var.set_audio_deviation)
|
||||||
await set_var(tuner_config, CONF_POWER, var.set_power)
|
await set_var(tuner_config, CONF_POWER, var.set_power)
|
||||||
await set_var(tuner_config, CONF_ANTCAP, var.set_antcap)
|
await set_var(tuner_config, CONF_ANTCAP, var.set_antcap)
|
||||||
if analog_config := config.get(CONF_SECTION_ANALOG):
|
if analog_config := config.get(CONF_ANALOG):
|
||||||
await set_var(analog_config, CONF_LEVEL, var.set_analog_level)
|
await set_var(analog_config, CONF_LEVEL, var.set_analog_level)
|
||||||
await set_var(analog_config, CONF_ATTENUATION, var.set_analog_attenuation)
|
await set_var(analog_config, CONF_ATTENUATION, var.set_analog_attenuation)
|
||||||
if digital_config := config.get(CONF_SECTION_DIGITAL):
|
if digital_config := config.get(CONF_DIGITAL):
|
||||||
await set_var(digital_config, CONF_SAMPLE_RATE, var.set_digital_sample_rate)
|
await set_var(digital_config, CONF_SAMPLE_RATE, var.set_digital_sample_rate)
|
||||||
await set_var(digital_config, CONF_SAMPLE_BITS, var.set_digital_sample_bits)
|
await set_var(digital_config, CONF_SAMPLE_BITS, var.set_digital_sample_bits)
|
||||||
await set_var(digital_config, CONF_CHANNELS, var.set_digital_channels)
|
await set_var(digital_config, CONF_CHANNELS, var.set_digital_channels)
|
||||||
await set_var(digital_config, CONF_MODE, var.set_digital_mode)
|
await set_var(digital_config, CONF_MODE, var.set_digital_mode)
|
||||||
await set_var(digital_config, CONF_CLOCK_EDGE, var.set_digital_clock_edge)
|
await set_var(digital_config, CONF_CLOCK_EDGE, var.set_digital_clock_edge)
|
||||||
if pilot_config := config.get(CONF_SECTION_PILOT):
|
if pilot_config := config.get(CONF_PILOT):
|
||||||
await set_var(pilot_config, CONF_ENABLE, var.set_pilot_enable)
|
await set_var(pilot_config, CONF_ENABLE, var.set_pilot_enable)
|
||||||
await set_var(pilot_config, CONF_FREQUENCY, var.set_pilot_frequency)
|
await set_var(pilot_config, CONF_FREQUENCY, var.set_pilot_frequency)
|
||||||
await set_var(pilot_config, CONF_DEVIATION, var.set_pilot_deviation)
|
await set_var(pilot_config, CONF_DEVIATION, var.set_pilot_deviation)
|
||||||
if refclk_config := config.get(CONF_SECTION_REFCLK):
|
if refclk_config := config.get(CONF_REFCLK):
|
||||||
await set_var(refclk_config, CONF_FREQUENCY, var.set_refclk_frequency)
|
await set_var(refclk_config, CONF_FREQUENCY, var.set_refclk_frequency)
|
||||||
await set_var(refclk_config, CONF_SOURCE, var.set_refclk_source)
|
await set_var(refclk_config, CONF_SOURCE, var.set_refclk_source)
|
||||||
await set_var(refclk_config, CONF_PRESCALER, var.set_refclk_prescaler)
|
await set_var(refclk_config, CONF_PRESCALER, var.set_refclk_prescaler)
|
||||||
if compressor_config := config.get(CONF_SECTION_COMPRESSOR):
|
if compressor_config := config.get(CONF_COMPRESSOR):
|
||||||
await set_var(compressor_config, CONF_ENABLE, var.set_acomp_enable)
|
await set_var(compressor_config, CONF_ENABLE, var.set_acomp_enable)
|
||||||
await set_var(compressor_config, CONF_THRESHOLD, var.set_acomp_threshold)
|
await set_var(compressor_config, CONF_THRESHOLD, var.set_acomp_threshold)
|
||||||
await set_var(compressor_config, CONF_ATTACK, var.set_acomp_attack)
|
await set_var(compressor_config, CONF_ATTACK, var.set_acomp_attack)
|
||||||
await set_var(compressor_config, CONF_RELEASE, var.set_acomp_release)
|
await set_var(compressor_config, CONF_RELEASE, var.set_acomp_release)
|
||||||
await set_var(compressor_config, CONF_GAIN, var.set_acomp_gain)
|
await set_var(compressor_config, CONF_GAIN, var.set_acomp_gain)
|
||||||
await set_var(compressor_config, CONF_PRESET, var.set_acomp_preset)
|
await set_var(compressor_config, CONF_PRESET, var.set_acomp_preset)
|
||||||
if limiter_config := config.get(CONF_SECTION_LIMITER):
|
if limiter_config := config.get(CONF_LIMITER):
|
||||||
await set_var(limiter_config, CONF_ENABLE, var.set_limiter_enable)
|
await set_var(limiter_config, CONF_ENABLE, var.set_limiter_enable)
|
||||||
await set_var(limiter_config, CONF_RELEASE_TIME, var.set_limiter_release_time)
|
await set_var(limiter_config, CONF_RELEASE_TIME, var.set_limiter_release_time)
|
||||||
if asq_config := config.get(CONF_SECTION_ASQ):
|
if asq_config := config.get(CONF_ASQ):
|
||||||
await set_var(asq_config, CONF_IALL, var.set_asq_iall_enable)
|
await set_var(asq_config, CONF_IALL, var.set_asq_iall_enable)
|
||||||
await set_var(asq_config, CONF_IALH, var.set_asq_ialh_enable)
|
await set_var(asq_config, CONF_IALH, var.set_asq_ialh_enable)
|
||||||
await set_var(asq_config, CONF_OVERMOD, var.set_asq_overmod_enable)
|
await set_var(asq_config, CONF_OVERMOD, var.set_asq_overmod_enable)
|
||||||
|
@ -464,12 +473,12 @@ async def to_code(config):
|
||||||
await set_var(asq_config, CONF_DURATION_LOW, var.set_asq_duration_low)
|
await set_var(asq_config, CONF_DURATION_LOW, var.set_asq_duration_low)
|
||||||
await set_var(asq_config, CONF_LEVEL_HIGH, var.set_asq_level_high)
|
await set_var(asq_config, CONF_LEVEL_HIGH, var.set_asq_level_high)
|
||||||
await set_var(asq_config, CONF_DURATION_HIGH, var.set_asq_duration_high)
|
await set_var(asq_config, CONF_DURATION_HIGH, var.set_asq_duration_high)
|
||||||
if rds_config := config.get(CONF_SECTION_RDS):
|
if rds_config := config.get(CONF_RDS):
|
||||||
await set_var(rds_config, CONF_ENABLE, var.set_rds_enable)
|
await set_var(rds_config, CONF_ENABLE, var.set_rds_enable)
|
||||||
await set_var(rds_config, CONF_DEVIATION, var.set_rds_deviation)
|
await set_var(rds_config, CONF_DEVIATION, var.set_rds_deviation)
|
||||||
await set_var(rds_config, CONF_STATION, var.set_rds_station)
|
await set_var(rds_config, CONF_STATION, var.set_rds_station)
|
||||||
await set_var(rds_config, CONF_TEXT, var.set_rds_text)
|
await set_var(rds_config, CONF_TEXT, var.set_rds_text)
|
||||||
if sensor_config := config.get(CONF_SECTION_SENSOR):
|
if sensor_config := config.get(CONF_SENSOR):
|
||||||
await new_text_sensor(sensor_config, CONF_CHIP_ID, var.set_chip_id_text_sensor)
|
await new_text_sensor(sensor_config, CONF_CHIP_ID, var.set_chip_id_text_sensor)
|
||||||
await new_sensor(
|
await new_sensor(
|
||||||
sensor_config, CONF_READ_FREQUENCY, var.set_read_frequency_sensor
|
sensor_config, CONF_READ_FREQUENCY, var.set_read_frequency_sensor
|
||||||
|
|
|
@ -4,6 +4,11 @@ import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_FREQUENCY,
|
CONF_FREQUENCY,
|
||||||
CONF_MODE,
|
CONF_MODE,
|
||||||
|
CONF_ANALOG,
|
||||||
|
CONF_POWER,
|
||||||
|
CONF_LEVEL,
|
||||||
|
CONF_THRESHOLD,
|
||||||
|
CONF_GAIN,
|
||||||
UNIT_HERTZ,
|
UNIT_HERTZ,
|
||||||
UNIT_MILLISECOND,
|
UNIT_MILLISECOND,
|
||||||
UNIT_DECIBEL,
|
UNIT_DECIBEL,
|
||||||
|
@ -19,24 +24,18 @@ from .. import (
|
||||||
CONF_SI4713_ID,
|
CONF_SI4713_ID,
|
||||||
Si4713Component,
|
Si4713Component,
|
||||||
si4713_ns,
|
si4713_ns,
|
||||||
CONF_SECTION_TUNER,
|
CONF_TUNER,
|
||||||
CONF_SECTION_ANALOG,
|
CONF_DIGITAL,
|
||||||
CONF_SECTION_DIGITAL,
|
CONF_PILOT,
|
||||||
CONF_SECTION_PILOT,
|
CONF_REFCLK,
|
||||||
CONF_SECTION_REFCLK,
|
CONF_COMPRESSOR,
|
||||||
CONF_SECTION_COMPRESSOR,
|
CONF_LIMITER,
|
||||||
CONF_SECTION_LIMITER,
|
CONF_ASQ,
|
||||||
CONF_SECTION_ASQ,
|
CONF_RDS,
|
||||||
CONF_SECTION_RDS,
|
|
||||||
CONF_FREQUENCY,
|
|
||||||
CONF_DEVIATION,
|
CONF_DEVIATION,
|
||||||
CONF_POWER,
|
|
||||||
CONF_ANTCAP,
|
CONF_ANTCAP,
|
||||||
CONF_LEVEL,
|
|
||||||
CONF_SAMPLE_RATE,
|
CONF_SAMPLE_RATE,
|
||||||
CONF_PRESCALER,
|
CONF_PRESCALER,
|
||||||
CONF_THRESHOLD,
|
|
||||||
CONF_GAIN,
|
|
||||||
CONF_RELEASE_TIME,
|
CONF_RELEASE_TIME,
|
||||||
CONF_LEVEL_LOW,
|
CONF_LEVEL_LOW,
|
||||||
CONF_DURATION_LOW,
|
CONF_DURATION_LOW,
|
||||||
|
@ -71,7 +70,7 @@ RdsDeviationNumber = si4713_ns.class_("RdsDeviationNumber", number.Number)
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_SI4713_ID): cv.use_id(Si4713Component),
|
cv.GenerateID(CONF_SI4713_ID): cv.use_id(Si4713Component),
|
||||||
cv.Optional(CONF_SECTION_TUNER): cv.Schema(
|
cv.Optional(CONF_TUNER): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
||||||
FrequencyNumber,
|
FrequencyNumber,
|
||||||
|
@ -99,7 +98,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_ANALOG): cv.Schema(
|
cv.Optional(CONF_ANALOG): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_LEVEL): number.number_schema(
|
cv.Optional(CONF_LEVEL): number.number_schema(
|
||||||
AnalogLevelNumber,
|
AnalogLevelNumber,
|
||||||
|
@ -109,7 +108,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_DIGITAL): cv.Schema(
|
cv.Optional(CONF_DIGITAL): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_SAMPLE_RATE): number.number_schema(
|
cv.Optional(CONF_SAMPLE_RATE): number.number_schema(
|
||||||
DigitalSampleRateNumber,
|
DigitalSampleRateNumber,
|
||||||
|
@ -119,7 +118,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_PILOT): cv.Schema(
|
cv.Optional(CONF_PILOT): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
||||||
PilotFrequencyNumber,
|
PilotFrequencyNumber,
|
||||||
|
@ -135,7 +134,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_REFCLK): cv.Schema(
|
cv.Optional(CONF_REFCLK): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
cv.Optional(CONF_FREQUENCY): number.number_schema(
|
||||||
RefClkFrequencyNumber,
|
RefClkFrequencyNumber,
|
||||||
|
@ -151,7 +150,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_COMPRESSOR): cv.Schema(
|
cv.Optional(CONF_COMPRESSOR): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_THRESHOLD): number.number_schema(
|
cv.Optional(CONF_THRESHOLD): number.number_schema(
|
||||||
AcompThresholdNumber,
|
AcompThresholdNumber,
|
||||||
|
@ -167,7 +166,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_LIMITER): cv.Schema(
|
cv.Optional(CONF_LIMITER): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_RELEASE_TIME): number.number_schema(
|
cv.Optional(CONF_RELEASE_TIME): number.number_schema(
|
||||||
LimiterReleaseTimeNumber,
|
LimiterReleaseTimeNumber,
|
||||||
|
@ -177,7 +176,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_ASQ): cv.Schema(
|
cv.Optional(CONF_ASQ): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_LEVEL_LOW): number.number_schema(
|
cv.Optional(CONF_LEVEL_LOW): number.number_schema(
|
||||||
AsqLevelLowNumber,
|
AsqLevelLowNumber,
|
||||||
|
@ -205,7 +204,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_RDS): cv.Schema(
|
cv.Optional(CONF_RDS): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_DEVIATION): number.number_schema(
|
cv.Optional(CONF_DEVIATION): number.number_schema(
|
||||||
RdsDeviationNumber,
|
RdsDeviationNumber,
|
||||||
|
@ -234,30 +233,30 @@ async def new_number(p, config, id, setter, min_value, max_value, step, *args, *
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
p = await cg.get_variable(config[CONF_SI4713_ID])
|
p = await cg.get_variable(config[CONF_SI4713_ID])
|
||||||
if tuner_config := config.get(CONF_SECTION_TUNER):
|
if tuner_config := config.get(CONF_TUNER):
|
||||||
await new_number(p, tuner_config, CONF_FREQUENCY, p.set_frequency_number, 76, 108, 0.05)
|
await new_number(p, tuner_config, CONF_FREQUENCY, p.set_frequency_number, 76, 108, 0.05)
|
||||||
await new_number(p, tuner_config, CONF_DEVIATION, p.set_audio_deviation_number, 0, 90, 0.01)
|
await new_number(p, tuner_config, CONF_DEVIATION, p.set_audio_deviation_number, 0, 90, 0.01)
|
||||||
await new_number(p, tuner_config, CONF_POWER, p.set_power_number, 88, 120, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
await new_number(p, tuner_config, CONF_POWER, p.set_power_number, 88, 120, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
||||||
await new_number(p, tuner_config, CONF_ANTCAP, p.set_antcap_number, 0, 191, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
await new_number(p, tuner_config, CONF_ANTCAP, p.set_antcap_number, 0, 191, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
||||||
if analog_config := config.get(CONF_SECTION_ANALOG):
|
if analog_config := config.get(CONF_ANALOG):
|
||||||
await new_number(p, analog_config, CONF_LEVEL, p.set_analog_level_number, 0, 1023, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
await new_number(p, analog_config, CONF_LEVEL, p.set_analog_level_number, 0, 1023, 1, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
||||||
if digital_config := config.get(CONF_SECTION_DIGITAL):
|
if digital_config := config.get(CONF_DIGITAL):
|
||||||
await new_number(p, digital_config, CONF_SAMPLE_RATE, p.set_digital_sample_rate_number, 32000, 48000, 1)
|
await new_number(p, digital_config, CONF_SAMPLE_RATE, p.set_digital_sample_rate_number, 32000, 48000, 1)
|
||||||
if pilot_config := config.get(CONF_SECTION_PILOT):
|
if pilot_config := config.get(CONF_PILOT):
|
||||||
await new_number(p, pilot_config, CONF_FREQUENCY, p.set_pilot_frequency_number, 0, 19, 0.001)
|
await new_number(p, pilot_config, CONF_FREQUENCY, p.set_pilot_frequency_number, 0, 19, 0.001)
|
||||||
await new_number(p, pilot_config, CONF_DEVIATION, p.set_pilot_deviation_number, 0, 90, 0.001)
|
await new_number(p, pilot_config, CONF_DEVIATION, p.set_pilot_deviation_number, 0, 90, 0.001)
|
||||||
if refclk_config := config.get(CONF_SECTION_REFCLK):
|
if refclk_config := config.get(CONF_REFCLK):
|
||||||
await new_number(p, refclk_config, CONF_FREQUENCY, p.set_refclk_frequency_number, 31130, 34406, 1)
|
await new_number(p, refclk_config, CONF_FREQUENCY, p.set_refclk_frequency_number, 31130, 34406, 1)
|
||||||
await new_number(p, refclk_config, CONF_PRESCALER, p.set_refclk_prescaler_number, 0, 4095, 1)
|
await new_number(p, refclk_config, CONF_PRESCALER, p.set_refclk_prescaler_number, 0, 4095, 1)
|
||||||
if compressor_config := config.get(CONF_SECTION_COMPRESSOR):
|
if compressor_config := config.get(CONF_COMPRESSOR):
|
||||||
await new_number(p, compressor_config, CONF_THRESHOLD, p.set_acomp_threshold_number, -40, 0, 1)
|
await new_number(p, compressor_config, CONF_THRESHOLD, p.set_acomp_threshold_number, -40, 0, 1)
|
||||||
await new_number(p, compressor_config, CONF_GAIN, p.set_acomp_gain_number, 0, 20, 1)
|
await new_number(p, compressor_config, CONF_GAIN, p.set_acomp_gain_number, 0, 20, 1)
|
||||||
if limiter_config := config.get(CONF_SECTION_LIMITER):
|
if limiter_config := config.get(CONF_LIMITER):
|
||||||
await new_number(p, limiter_config, CONF_RELEASE_TIME, p.set_limiter_release_time_number, 0.25, 102.4, 0.01, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
await new_number(p, limiter_config, CONF_RELEASE_TIME, p.set_limiter_release_time_number, 0.25, 102.4, 0.01, mode = number.NumberMode.NUMBER_MODE_SLIDER)
|
||||||
if asq_config := config.get(CONF_SECTION_ASQ):
|
if asq_config := config.get(CONF_ASQ):
|
||||||
await new_number(p, asq_config, CONF_LEVEL_LOW, p.set_asq_level_low_number, -70, 0, 1)
|
await new_number(p, asq_config, CONF_LEVEL_LOW, p.set_asq_level_low_number, -70, 0, 1)
|
||||||
await new_number(p, asq_config, CONF_DURATION_LOW, p.set_asq_duration_low_number, 0, 65535, 1)
|
await new_number(p, asq_config, CONF_DURATION_LOW, p.set_asq_duration_low_number, 0, 65535, 1)
|
||||||
await new_number(p, asq_config, CONF_LEVEL_HIGH, p.set_asq_level_high_number, -70, 0, 1)
|
await new_number(p, asq_config, CONF_LEVEL_HIGH, p.set_asq_level_high_number, -70, 0, 1)
|
||||||
await new_number(p, asq_config, CONF_DURATION_HIGH, p.set_asq_duration_high_number, 0, 65535, 1)
|
await new_number(p, asq_config, CONF_DURATION_HIGH, p.set_asq_duration_high_number, 0, 65535, 1)
|
||||||
if rds_config := config.get(CONF_SECTION_RDS):
|
if rds_config := config.get(CONF_RDS):
|
||||||
await new_number(p, rds_config, CONF_DEVIATION, p.set_rds_deviation_number, 0, 7.5, 0.01)
|
await new_number(p, rds_config, CONF_DEVIATION, p.set_rds_deviation_number, 0, 7.5, 0.01)
|
||||||
|
|
|
@ -2,6 +2,12 @@ import esphome.codegen as cg
|
||||||
from esphome.components import select
|
from esphome.components import select
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_ANALOG,
|
||||||
|
CONF_ATTENUATION,
|
||||||
|
CONF_CHANNELS,
|
||||||
|
CONF_MODE,
|
||||||
|
CONF_SOURCE,
|
||||||
|
CONF_PRESET,
|
||||||
ENTITY_CATEGORY_CONFIG,
|
ENTITY_CATEGORY_CONFIG,
|
||||||
ICON_PULSE,
|
ICON_PULSE,
|
||||||
)
|
)
|
||||||
|
@ -9,20 +15,14 @@ from .. import (
|
||||||
CONF_SI4713_ID,
|
CONF_SI4713_ID,
|
||||||
Si4713Component,
|
Si4713Component,
|
||||||
si4713_ns,
|
si4713_ns,
|
||||||
CONF_SECTION_ANALOG,
|
CONF_DIGITAL,
|
||||||
CONF_SECTION_DIGITAL,
|
CONF_REFCLK,
|
||||||
CONF_SECTION_REFCLK,
|
CONF_COMPRESSOR,
|
||||||
CONF_SECTION_COMPRESSOR,
|
|
||||||
CONF_PRE_EMPHASIS,
|
CONF_PRE_EMPHASIS,
|
||||||
CONF_ATTENUATION,
|
|
||||||
CONF_SAMPLE_BITS,
|
CONF_SAMPLE_BITS,
|
||||||
CONF_CHANNELS,
|
|
||||||
CONF_MODE,
|
|
||||||
CONF_CLOCK_EDGE,
|
CONF_CLOCK_EDGE,
|
||||||
CONF_SOURCE,
|
|
||||||
CONF_ATTACK,
|
CONF_ATTACK,
|
||||||
CONF_RELEASE,
|
CONF_RELEASE,
|
||||||
CONF_PRESET,
|
|
||||||
ICON_SINE_WAVE,
|
ICON_SINE_WAVE,
|
||||||
ICON_RESISTOR,
|
ICON_RESISTOR,
|
||||||
ICON_EAR_HEARING,
|
ICON_EAR_HEARING,
|
||||||
|
@ -57,7 +57,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
icon=ICON_SINE_WAVE,
|
icon=ICON_SINE_WAVE,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_ANALOG): cv.Schema(
|
cv.Optional(CONF_ANALOG): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_ATTENUATION): select.select_schema(
|
cv.Optional(CONF_ATTENUATION): select.select_schema(
|
||||||
AnalogAttenuationSelect,
|
AnalogAttenuationSelect,
|
||||||
|
@ -66,7 +66,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_DIGITAL): cv.Schema(
|
cv.Optional(CONF_DIGITAL): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_SAMPLE_BITS): select.select_schema(
|
cv.Optional(CONF_SAMPLE_BITS): select.select_schema(
|
||||||
DigitalSampleBitsSelect,
|
DigitalSampleBitsSelect,
|
||||||
|
@ -90,7 +90,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_REFCLK): cv.Schema(
|
cv.Optional(CONF_REFCLK): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_SOURCE): select.select_schema(
|
cv.Optional(CONF_SOURCE): select.select_schema(
|
||||||
RefClkSourceSelect,
|
RefClkSourceSelect,
|
||||||
|
@ -99,7 +99,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_COMPRESSOR): cv.Schema(
|
cv.Optional(CONF_COMPRESSOR): cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(CONF_ATTACK): select.select_schema(
|
cv.Optional(CONF_ATTACK): select.select_schema(
|
||||||
AcompAttackSelect,
|
AcompAttackSelect,
|
||||||
|
@ -133,16 +133,16 @@ async def new_select(p, config, id, setter, options):
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
p = await cg.get_variable(config[CONF_SI4713_ID])
|
p = await cg.get_variable(config[CONF_SI4713_ID])
|
||||||
await new_select(p, config, CONF_PRE_EMPHASIS, p.set_pre_emphasis_select, PRE_EMPHASIS)
|
await new_select(p, config, CONF_PRE_EMPHASIS, p.set_pre_emphasis_select, PRE_EMPHASIS)
|
||||||
if analog_config := config.get(CONF_SECTION_ANALOG):
|
if analog_config := config.get(CONF_ANALOG):
|
||||||
await new_select(p, analog_config, CONF_ATTENUATION, p.set_analog_attenuation_select, LINE_ATTENUATION)
|
await new_select(p, analog_config, CONF_ATTENUATION, p.set_analog_attenuation_select, LINE_ATTENUATION)
|
||||||
if digital_config := config.get(CONF_SECTION_DIGITAL):
|
if digital_config := config.get(CONF_DIGITAL):
|
||||||
await new_select(p, digital_config, CONF_SAMPLE_BITS, p.set_digital_sample_bits_select, SAMPLE_BITS)
|
await new_select(p, digital_config, CONF_SAMPLE_BITS, p.set_digital_sample_bits_select, SAMPLE_BITS)
|
||||||
await new_select(p, digital_config, CONF_CHANNELS, p.set_digital_channels_select, SAMPLE_CHANNELS)
|
await new_select(p, digital_config, CONF_CHANNELS, p.set_digital_channels_select, SAMPLE_CHANNELS)
|
||||||
await new_select(p, digital_config, CONF_MODE, p.set_digital_mode_select, DIGITAL_MODE)
|
await new_select(p, digital_config, CONF_MODE, p.set_digital_mode_select, DIGITAL_MODE)
|
||||||
await new_select(p, digital_config, CONF_CLOCK_EDGE, p.set_digital_clock_edge_select, DIGITAL_CLOCK_EDGE)
|
await new_select(p, digital_config, CONF_CLOCK_EDGE, p.set_digital_clock_edge_select, DIGITAL_CLOCK_EDGE)
|
||||||
if refclk_config := config.get(CONF_SECTION_REFCLK):
|
if refclk_config := config.get(CONF_REFCLK):
|
||||||
await new_select(p, refclk_config, CONF_SOURCE, p.set_refclk_source_select, REFCLK_SOURCE)
|
await new_select(p, refclk_config, CONF_SOURCE, p.set_refclk_source_select, REFCLK_SOURCE)
|
||||||
if compressor_config := config.get(CONF_SECTION_COMPRESSOR):
|
if compressor_config := config.get(CONF_COMPRESSOR):
|
||||||
await new_select(p, compressor_config, CONF_ATTACK, p.set_acomp_attack_select, ACOMP_ATTACK)
|
await new_select(p, compressor_config, CONF_ATTACK, p.set_acomp_attack_select, ACOMP_ATTACK)
|
||||||
await new_select(p, compressor_config, CONF_RELEASE, p.set_acomp_release_select, ACOMP_RELEASE)
|
await new_select(p, compressor_config, CONF_RELEASE, p.set_acomp_release_select, ACOMP_RELEASE)
|
||||||
await new_select(p, compressor_config, CONF_PRESET, p.set_acomp_preset_select, ACOMP_PRESET)
|
await new_select(p, compressor_config, CONF_PRESET, p.set_acomp_preset_select, ACOMP_PRESET)
|
||||||
|
|
|
@ -326,26 +326,26 @@ template<typename T> T GET_ENUM_LAST(T value) { return T::LAST; }
|
||||||
|
|
||||||
#define CHECK_ENUM(value) \
|
#define CHECK_ENUM(value) \
|
||||||
if (value >= GET_ENUM_LAST(value)) { \
|
if (value >= GET_ENUM_LAST(value)) { \
|
||||||
ESP_LOGE(TAG, "%s(%d) invalid", __func__, (int) value); \
|
ESP_LOGE(TAG, "%s(%d) invalid", __func__, (int) (value)); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_FLOAT_RANGE(value, min_value, max_value) \
|
#define CHECK_FLOAT_RANGE(value, min_value, max_value) \
|
||||||
if (!(min_value <= value && value <= max_value)) { \
|
if (!((min_value) <= (value) && (value) <= (max_value))) { \
|
||||||
ESP_LOGE(TAG, "%s(%.2f) invalid (%.2f - %.2f)", __func__, value, min_value, max_value); \
|
ESP_LOGE(TAG, "%s(%.2f) invalid (%.2f - %.2f)", __func__, value, min_value, max_value); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_INT_RANGE(value, min_value, max_value) \
|
#define CHECK_INT_RANGE(value, min_value, max_value) \
|
||||||
if (!(min_value <= value && value <= max_value)) { \
|
if (!((min_value) <= (value) && (value) <= (max_value))) { \
|
||||||
ESP_LOGE(TAG, "%s(%d) invalid (%d - %d)", __func__, value, min_value, max_value); \
|
ESP_LOGE(TAG, "%s(%d) invalid (%d - %d)", __func__, value, min_value, max_value); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_TEXT_RANGE(value, max_size) \
|
#define CHECK_TEXT_RANGE(value, max_size) \
|
||||||
if (value.size() > max_size) { \
|
if ((value).size() > max_size) { \
|
||||||
ESP_LOGW(TAG, "%s(%s) trimmed (max %d characters)", __func__, value.c_str(), max_size); \
|
ESP_LOGW(TAG, "%s(%s) trimmed (max %d characters)", __func__, (value).c_str(), max_size); \
|
||||||
value.resize(max_size); \
|
(value).resize(max_size); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si4713Component::set_reset_pin(InternalGPIOPin *pin) { this->reset_pin_ = pin; }
|
void Si4713Component::set_reset_pin(InternalGPIOPin *pin) { this->reset_pin_ = pin; }
|
||||||
|
|
|
@ -2,20 +2,19 @@ import esphome.codegen as cg
|
||||||
from esphome.components import switch
|
from esphome.components import switch
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_OUTPUT,
|
||||||
DEVICE_CLASS_SWITCH,
|
DEVICE_CLASS_SWITCH,
|
||||||
ENTITY_CATEGORY_CONFIG,
|
ENTITY_CATEGORY_CONFIG,
|
||||||
ICON_SECURITY,
|
|
||||||
)
|
)
|
||||||
from .. import (
|
from .. import (
|
||||||
CONF_SI4713_ID,
|
CONF_SI4713_ID,
|
||||||
Si4713Component,
|
Si4713Component,
|
||||||
si4713_ns,
|
si4713_ns,
|
||||||
CONF_SECTION_PILOT,
|
CONF_PILOT,
|
||||||
CONF_SECTION_COMPRESSOR,
|
CONF_COMPRESSOR,
|
||||||
CONF_SECTION_LIMITER,
|
CONF_LIMITER,
|
||||||
CONF_SECTION_ASQ,
|
CONF_ASQ,
|
||||||
CONF_SECTION_RDS,
|
CONF_RDS,
|
||||||
CONF_SECTION_OUTPUT,
|
|
||||||
CONF_MUTE,
|
CONF_MUTE,
|
||||||
CONF_MONO,
|
CONF_MONO,
|
||||||
CONF_ENABLE,
|
CONF_ENABLE,
|
||||||
|
@ -148,12 +147,12 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
icon=ICON_EAR_HEARING,
|
icon=ICON_EAR_HEARING,
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_SECTION_PILOT): PILOT_SCHEMA,
|
cv.Optional(CONF_PILOT): PILOT_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_COMPRESSOR): COMPRESSOR_SCHEMA,
|
cv.Optional(CONF_COMPRESSOR): COMPRESSOR_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_LIMITER): LIMITER_SCHEMA,
|
cv.Optional(CONF_LIMITER): LIMITER_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_ASQ): ASQ_SCHEMA,
|
cv.Optional(CONF_ASQ): ASQ_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_RDS): RDS_SCHEMA,
|
cv.Optional(CONF_RDS): RDS_SCHEMA,
|
||||||
cv.Optional(CONF_SECTION_OUTPUT): OUTPUT_SCHEMA,
|
cv.Optional(CONF_OUTPUT): OUTPUT_SCHEMA,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -170,19 +169,19 @@ async def to_code(config):
|
||||||
p = await cg.get_variable(config[CONF_SI4713_ID])
|
p = await cg.get_variable(config[CONF_SI4713_ID])
|
||||||
await new_switch(p, config, CONF_MUTE, p.set_mute_switch)
|
await new_switch(p, config, CONF_MUTE, p.set_mute_switch)
|
||||||
await new_switch(p, config, CONF_MONO, p.set_mono_switch)
|
await new_switch(p, config, CONF_MONO, p.set_mono_switch)
|
||||||
if pilot_config := config.get(CONF_SECTION_PILOT):
|
if pilot_config := config.get(CONF_PILOT):
|
||||||
await new_switch(p, pilot_config, CONF_ENABLE, p.set_pilot_enable_switch)
|
await new_switch(p, pilot_config, CONF_ENABLE, p.set_pilot_enable_switch)
|
||||||
if compressor_config := config.get(CONF_SECTION_COMPRESSOR):
|
if compressor_config := config.get(CONF_COMPRESSOR):
|
||||||
await new_switch(p, compressor_config, CONF_ENABLE, p.set_acomp_enable_switch)
|
await new_switch(p, compressor_config, CONF_ENABLE, p.set_acomp_enable_switch)
|
||||||
if limiter_config := config.get(CONF_SECTION_LIMITER):
|
if limiter_config := config.get(CONF_LIMITER):
|
||||||
await new_switch(p, limiter_config, CONF_ENABLE, p.set_limiter_enable_switch)
|
await new_switch(p, limiter_config, CONF_ENABLE, p.set_limiter_enable_switch)
|
||||||
if asq_config := config.get(CONF_SECTION_ASQ):
|
if asq_config := config.get(CONF_ASQ):
|
||||||
await new_switch(p, asq_config, CONF_IALL, p.set_asq_iall_enable_switch)
|
await new_switch(p, asq_config, CONF_IALL, p.set_asq_iall_enable_switch)
|
||||||
await new_switch(p, asq_config, CONF_IALH, p.set_asq_ialh_enable_switch)
|
await new_switch(p, asq_config, CONF_IALH, p.set_asq_ialh_enable_switch)
|
||||||
await new_switch(p, asq_config, CONF_OVERMOD, p.set_asq_overmod_enable_switch)
|
await new_switch(p, asq_config, CONF_OVERMOD, p.set_asq_overmod_enable_switch)
|
||||||
if rds_config := config.get(CONF_SECTION_RDS):
|
if rds_config := config.get(CONF_RDS):
|
||||||
await new_switch(p, rds_config, CONF_ENABLE, p.set_rds_enable_switch)
|
await new_switch(p, rds_config, CONF_ENABLE, p.set_rds_enable_switch)
|
||||||
if output_config := config.get(CONF_SECTION_OUTPUT):
|
if output_config := config.get(CONF_OUTPUT):
|
||||||
gpio1 = await new_switch(p, output_config, CONF_GPIO1, p.set_gpio1_switch)
|
gpio1 = await new_switch(p, output_config, CONF_GPIO1, p.set_gpio1_switch)
|
||||||
gpio2 = await new_switch(p, output_config, CONF_GPIO2, p.set_gpio2_switch)
|
gpio2 = await new_switch(p, output_config, CONF_GPIO2, p.set_gpio2_switch)
|
||||||
gpio3 = await new_switch(p, output_config, CONF_GPIO3, p.set_gpio3_switch)
|
gpio3 = await new_switch(p, output_config, CONF_GPIO3, p.set_gpio3_switch)
|
||||||
|
|
|
@ -5,6 +5,7 @@ from esphome.components import mqtt, web_server
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
|
CONF_TEXT,
|
||||||
CONF_ENTITY_CATEGORY,
|
CONF_ENTITY_CATEGORY,
|
||||||
CONF_ICON,
|
CONF_ICON,
|
||||||
CONF_MQTT_ID,
|
CONF_MQTT_ID,
|
||||||
|
@ -18,9 +19,8 @@ from .. import (
|
||||||
CONF_SI4713_ID,
|
CONF_SI4713_ID,
|
||||||
Si4713Component,
|
Si4713Component,
|
||||||
si4713_ns,
|
si4713_ns,
|
||||||
CONF_SECTION_RDS,
|
CONF_RDS,
|
||||||
CONF_STATION,
|
CONF_STATION,
|
||||||
CONF_TEXT,
|
|
||||||
ICON_FORMAT_TEXT,
|
ICON_FORMAT_TEXT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ RDS_SCHEMA = cv.Schema(
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_SI4713_ID): cv.use_id(Si4713Component),
|
cv.GenerateID(CONF_SI4713_ID): cv.use_id(Si4713Component),
|
||||||
cv.Optional(CONF_SECTION_RDS): RDS_SCHEMA,
|
cv.Optional(CONF_RDS): RDS_SCHEMA,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -154,6 +154,6 @@ async def new_text_simple(p, config, id, setter, min_length, max_length, *args):
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
p = await cg.get_variable(config[CONF_SI4713_ID])
|
p = await cg.get_variable(config[CONF_SI4713_ID])
|
||||||
if rds_config := config.get(CONF_SECTION_RDS):
|
if rds_config := config.get(CONF_RDS):
|
||||||
await new_text_simple(p, rds_config, CONF_STATION, p.set_rds_station_text, 0, 8)
|
await new_text_simple(p, rds_config, CONF_STATION, p.set_rds_station_text, 0, 8)
|
||||||
await new_text_simple(p, rds_config, CONF_TEXT, p.set_rds_text_text, 0, 64)
|
await new_text_simple(p, rds_config, CONF_TEXT, p.set_rds_text_text, 0, 64)
|
||||||
|
|
Loading…
Reference in a new issue