mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
@@ -339,7 +339,7 @@ jobs:
|
||||
echo "binary=$BINARY" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run CodSpeed benchmarks
|
||||
uses: CodSpeedHQ/action@d872884a306dd4853acf0f584f4b706cf0cc72a2 # v4
|
||||
uses: CodSpeedHQ/action@db35df748deb45fdef0960669f57d627c1956c30 # v4
|
||||
with:
|
||||
run: ${{ steps.build.outputs.binary }}
|
||||
mode: simulation
|
||||
|
||||
@@ -2,30 +2,29 @@ name: Status check labels
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled, unlabeled]
|
||||
types: [opened, reopened, labeled, unlabeled, synchronize]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check ${{ matrix.label }}
|
||||
name: Check blocking labels
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
label:
|
||||
- needs-docs
|
||||
- merge-after-release
|
||||
- chained-pr
|
||||
steps:
|
||||
- name: Check for ${{ matrix.label }} label
|
||||
- name: Check for blocking labels
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
script: |
|
||||
const blockingLabels = ['needs-docs', 'merge-after-release', 'chained-pr'];
|
||||
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number
|
||||
});
|
||||
const hasLabel = labels.find(label => label.name === '${{ matrix.label }}');
|
||||
if (hasLabel) {
|
||||
core.setFailed('Pull request cannot be merged, it is labeled as ${{ matrix.label }}');
|
||||
const labelNames = labels.map(l => l.name);
|
||||
const found = blockingLabels.filter(bl => labelNames.includes(bl));
|
||||
if (found.length > 0) {
|
||||
core.setFailed(`Pull request cannot be merged, it has blocking label(s): ${found.join(', ')}`);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace ade7953_base {
|
||||
|
||||
static const char *const TAG = "ade7953";
|
||||
|
||||
constexpr uint16_t CONFIG_DEFAULT = 0x8004u;
|
||||
constexpr uint16_t CONFIG_LOCK_BIT = 0x8000u;
|
||||
|
||||
static const float ADE_POWER_FACTOR = 154.0f;
|
||||
static const float ADE_WATTSEC_POWER_FACTOR = ADE_POWER_FACTOR * ADE_POWER_FACTOR / 3600;
|
||||
|
||||
@@ -18,7 +21,12 @@ void ADE7953::setup() {
|
||||
|
||||
// The chip might take up to 100ms to initialise
|
||||
this->set_timeout(100, [this]() {
|
||||
// this->ade_write_8(0x0010, 0x04);
|
||||
// Lock communication interface (SPI or I2C)
|
||||
uint16_t config_v = CONFIG_DEFAULT;
|
||||
this->ade_read_16(CONFIG_16, &config_v);
|
||||
config_v &= static_cast<uint16_t>(~CONFIG_LOCK_BIT); // Clear the lock bit
|
||||
this->ade_write_16(CONFIG_16, config_v);
|
||||
// Configure optimum settings according to datasheet
|
||||
this->ade_write_8(0x00FE, 0xAD);
|
||||
this->ade_write_16(0x0120, 0x0030);
|
||||
// Set gains
|
||||
|
||||
@@ -9,31 +9,35 @@
|
||||
namespace esphome {
|
||||
namespace ade7953_base {
|
||||
|
||||
static const uint8_t PGA_V_8 =
|
||||
static constexpr uint8_t PGA_V_8 =
|
||||
0x007; // PGA_V, (R/W) Default: 0x00, Unsigned, Voltage channel gain configuration (Bits[2:0])
|
||||
static const uint8_t PGA_IA_8 =
|
||||
static constexpr uint8_t PGA_IA_8 =
|
||||
0x008; // PGA_IA, (R/W) Default: 0x00, Unsigned, Current Channel A gain configuration (Bits[2:0])
|
||||
static const uint8_t PGA_IB_8 =
|
||||
static constexpr uint8_t PGA_IB_8 =
|
||||
0x009; // PGA_IB, (R/W) Default: 0x00, Unsigned, Current Channel B gain configuration (Bits[2:0])
|
||||
|
||||
static const uint32_t AIGAIN_32 =
|
||||
static constexpr uint16_t CONFIG_16 = 0x102; // CONFIG, (R/W) Default: 0x8004, Unsigned, Configuration register
|
||||
|
||||
static constexpr uint16_t AIGAIN_32 =
|
||||
0x380; // AIGAIN, (R/W) Default: 0x400000, Unsigned,Current channel gain (Current Channel A)(32 bit)
|
||||
static const uint32_t AVGAIN_32 = 0x381; // AVGAIN, (R/W) Default: 0x400000, Unsigned,Voltage channel gain(32 bit)
|
||||
static const uint32_t AWGAIN_32 =
|
||||
static constexpr uint16_t AVGAIN_32 =
|
||||
0x381; // AVGAIN, (R/W) Default: 0x400000, Unsigned,Voltage channel gain(32 bit)
|
||||
static constexpr uint16_t AWGAIN_32 =
|
||||
0x382; // AWGAIN, (R/W) Default: 0x400000, Unsigned,Active power gain (Current Channel A)(32 bit)
|
||||
static const uint32_t AVARGAIN_32 =
|
||||
static constexpr uint16_t AVARGAIN_32 =
|
||||
0x383; // AVARGAIN, (R/W) Default: 0x400000, Unsigned, Reactive power gain (Current Channel A)(32 bit)
|
||||
static const uint32_t AVAGAIN_32 =
|
||||
static constexpr uint16_t AVAGAIN_32 =
|
||||
0x384; // AVAGAIN, (R/W) Default: 0x400000, Unsigned,Apparent power gain (Current Channel A)(32 bit)
|
||||
|
||||
static const uint32_t BIGAIN_32 =
|
||||
static constexpr uint16_t BIGAIN_32 =
|
||||
0x38C; // BIGAIN, (R/W) Default: 0x400000, Unsigned,Current channel gain (Current Channel B)(32 bit)
|
||||
static const uint32_t BVGAIN_32 = 0x38D; // BVGAIN, (R/W) Default: 0x400000, Unsigned,Voltage channel gain(32 bit)
|
||||
static const uint32_t BWGAIN_32 =
|
||||
static constexpr uint16_t BVGAIN_32 =
|
||||
0x38D; // BVGAIN, (R/W) Default: 0x400000, Unsigned,Voltage channel gain(32 bit)
|
||||
static constexpr uint16_t BWGAIN_32 =
|
||||
0x38E; // BWGAIN, (R/W) Default: 0x400000, Unsigned,Active power gain (Current Channel B)(32 bit)
|
||||
static const uint32_t BVARGAIN_32 =
|
||||
static constexpr uint16_t BVARGAIN_32 =
|
||||
0x38F; // BVARGAIN, (R/W) Default: 0x400000, Unsigned, Reactive power gain (Current Channel B)(32 bit)
|
||||
static const uint32_t BVAGAIN_32 =
|
||||
static constexpr uint16_t BVAGAIN_32 =
|
||||
0x390; // BVAGAIN, (R/W) Default: 0x400000, Unsigned,Apparent power gain (Current Channel B)(32 bit)
|
||||
|
||||
class ADE7953 : public PollingComponent, public sensor::Sensor {
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace ade7953_spi {
|
||||
|
||||
static const char *const TAG = "ade7953";
|
||||
|
||||
// Datasheet requires at least 1.2µs after clearing CONFIG LOCK_BIT before raising CS
|
||||
constexpr uint8_t CONFIG_LOCK_SETTLE_US = 2;
|
||||
|
||||
void AdE7953Spi::setup() {
|
||||
this->spi_setup();
|
||||
ade7953_base::ADE7953::setup();
|
||||
@@ -32,6 +35,9 @@ bool AdE7953Spi::ade_write_16(uint16_t reg, uint16_t value) {
|
||||
this->write_byte16(reg);
|
||||
this->transfer_byte(0);
|
||||
this->write_byte16(value);
|
||||
if (reg == ade7953_base::CONFIG_16) {
|
||||
delayMicroseconds(CONFIG_LOCK_SETTLE_US);
|
||||
}
|
||||
this->disable();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace esphome {
|
||||
namespace ade7953_spi {
|
||||
|
||||
class AdE7953Spi : public ade7953_base::ADE7953,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_LEADING,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
|
||||
spi::DATA_RATE_1MHZ> {
|
||||
public:
|
||||
void setup() override;
|
||||
|
||||
@@ -40,10 +40,10 @@ async def to_code(config):
|
||||
cg.add(var.set_sensor(sens))
|
||||
|
||||
if isinstance(config[CONF_THRESHOLD], dict):
|
||||
lower = await cg.templatable(config[CONF_THRESHOLD][CONF_LOWER], [], float)
|
||||
upper = await cg.templatable(config[CONF_THRESHOLD][CONF_UPPER], [], float)
|
||||
lower = await cg.templatable(config[CONF_THRESHOLD][CONF_LOWER], [], cg.float_)
|
||||
upper = await cg.templatable(config[CONF_THRESHOLD][CONF_UPPER], [], cg.float_)
|
||||
else:
|
||||
lower = await cg.templatable(config[CONF_THRESHOLD], [], float)
|
||||
lower = await cg.templatable(config[CONF_THRESHOLD], [], cg.float_)
|
||||
upper = lower
|
||||
cg.add(var.set_upper_threshold(upper))
|
||||
cg.add(var.set_lower_threshold(lower))
|
||||
|
||||
@@ -179,7 +179,7 @@ async def at581x_settings_to_code(config, action_id, template_arg, args):
|
||||
cg.add(var.set_frequency(template_))
|
||||
|
||||
if (sens_dist := config.get(CONF_SENSING_DISTANCE)) is not None:
|
||||
template_ = await cg.templatable(sens_dist, args, int)
|
||||
template_ = await cg.templatable(sens_dist, args, cg.int_)
|
||||
cg.add(var.set_sensing_distance(template_))
|
||||
|
||||
if selfcheck := config.get(CONF_POWERON_SELFCHECK_TIME):
|
||||
@@ -199,7 +199,7 @@ async def at581x_settings_to_code(config, action_id, template_arg, args):
|
||||
cg.add(var.set_trigger_keep(template_))
|
||||
|
||||
if (stage_gain := config.get(CONF_STAGE_GAIN)) is not None:
|
||||
template_ = await cg.templatable(stage_gain, args, int)
|
||||
template_ = await cg.templatable(stage_gain, args, cg.int_)
|
||||
cg.add(var.set_stage_gain(template_))
|
||||
|
||||
if power := config.get(CONF_POWER_CONSUMPTION):
|
||||
|
||||
@@ -32,7 +32,7 @@ async def audio_adc_set_mic_gain_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config.get(CONF_MIC_GAIN), args, float)
|
||||
template_ = await cg.templatable(config.get(CONF_MIC_GAIN), args, cg.float_)
|
||||
cg.add(var.set_mic_gain(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -52,7 +52,7 @@ async def audio_dac_set_volume_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config.get(CONF_VOLUME), args, float)
|
||||
template_ = await cg.templatable(config.get(CONF_VOLUME), args, cg.float_)
|
||||
cg.add(var.set_volume(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -488,16 +488,16 @@ async def climate_control_to_code(config, action_id, template_arg, args):
|
||||
template_ = await cg.templatable(mode, args, ClimateMode)
|
||||
cg.add(var.set_mode(template_))
|
||||
if (target_temp := config.get(CONF_TARGET_TEMPERATURE)) is not None:
|
||||
template_ = await cg.templatable(target_temp, args, float)
|
||||
template_ = await cg.templatable(target_temp, args, cg.float_)
|
||||
cg.add(var.set_target_temperature(template_))
|
||||
if (target_temp_low := config.get(CONF_TARGET_TEMPERATURE_LOW)) is not None:
|
||||
template_ = await cg.templatable(target_temp_low, args, float)
|
||||
template_ = await cg.templatable(target_temp_low, args, cg.float_)
|
||||
cg.add(var.set_target_temperature_low(template_))
|
||||
if (target_temp_high := config.get(CONF_TARGET_TEMPERATURE_HIGH)) is not None:
|
||||
template_ = await cg.templatable(target_temp_high, args, float)
|
||||
template_ = await cg.templatable(target_temp_high, args, cg.float_)
|
||||
cg.add(var.set_target_temperature_high(template_))
|
||||
if (target_humidity := config.get(CONF_TARGET_HUMIDITY)) is not None:
|
||||
template_ = await cg.templatable(target_humidity, args, float)
|
||||
template_ = await cg.templatable(target_humidity, args, cg.float_)
|
||||
cg.add(var.set_target_humidity(template_))
|
||||
if (fan_mode := config.get(CONF_FAN_MODE)) is not None:
|
||||
template_ = await cg.templatable(fan_mode, args, ClimateFanMode)
|
||||
|
||||
@@ -300,16 +300,16 @@ async def cover_control_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
if (stop := config.get(CONF_STOP)) is not None:
|
||||
template_ = await cg.templatable(stop, args, bool)
|
||||
template_ = await cg.templatable(stop, args, cg.bool_)
|
||||
cg.add(var.set_stop(template_))
|
||||
if (state := config.get(CONF_STATE)) is not None:
|
||||
template_ = await cg.templatable(state, args, float)
|
||||
template_ = await cg.templatable(state, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if (position := config.get(CONF_POSITION)) is not None:
|
||||
template_ = await cg.templatable(position, args, float)
|
||||
template_ = await cg.templatable(position, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if (tilt := config.get(CONF_TILT)) is not None:
|
||||
template_ = await cg.templatable(tilt, args, float)
|
||||
template_ = await cg.templatable(tilt, args, cg.float_)
|
||||
cg.add(var.set_tilt(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -166,24 +166,24 @@ async def dfrobot_sen0395_settings_to_code(config, action_id, template_arg, args
|
||||
segments = config[CONF_DETECTION_SEGMENTS]
|
||||
|
||||
if len(segments) >= 2:
|
||||
template_ = await cg.templatable(segments[0], args, float)
|
||||
template_ = await cg.templatable(segments[0], args, cg.float_)
|
||||
cg.add(var.set_det_min1(template_))
|
||||
template_ = await cg.templatable(segments[1], args, float)
|
||||
template_ = await cg.templatable(segments[1], args, cg.float_)
|
||||
cg.add(var.set_det_max1(template_))
|
||||
if len(segments) >= 4:
|
||||
template_ = await cg.templatable(segments[2], args, float)
|
||||
template_ = await cg.templatable(segments[2], args, cg.float_)
|
||||
cg.add(var.set_det_min2(template_))
|
||||
template_ = await cg.templatable(segments[3], args, float)
|
||||
template_ = await cg.templatable(segments[3], args, cg.float_)
|
||||
cg.add(var.set_det_max2(template_))
|
||||
if len(segments) >= 6:
|
||||
template_ = await cg.templatable(segments[4], args, float)
|
||||
template_ = await cg.templatable(segments[4], args, cg.float_)
|
||||
cg.add(var.set_det_min3(template_))
|
||||
template_ = await cg.templatable(segments[5], args, float)
|
||||
template_ = await cg.templatable(segments[5], args, cg.float_)
|
||||
cg.add(var.set_det_max3(template_))
|
||||
if len(segments) >= 8:
|
||||
template_ = await cg.templatable(segments[6], args, float)
|
||||
template_ = await cg.templatable(segments[6], args, cg.float_)
|
||||
cg.add(var.set_det_min4(template_))
|
||||
template_ = await cg.templatable(segments[7], args, float)
|
||||
template_ = await cg.templatable(segments[7], args, cg.float_)
|
||||
cg.add(var.set_det_max4(template_))
|
||||
if CONF_OUTPUT_LATENCY in config:
|
||||
template_ = await cg.templatable(
|
||||
|
||||
@@ -62,6 +62,6 @@ async def to_code(config) -> None:
|
||||
async def esp8266_set_frequency_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, float)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, cg.float_)
|
||||
cg.add(var.set_frequency(template_))
|
||||
return var
|
||||
|
||||
@@ -202,7 +202,7 @@ async def ezo_pmp_dose_volume_over_time_to_code(config, action_id, template_arg,
|
||||
template_ = await cg.templatable(config[CONF_VOLUME], args, cg.double)
|
||||
cg.add(var.set_volume(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_DURATION], args, int)
|
||||
template_ = await cg.templatable(config[CONF_DURATION], args, cg.int_)
|
||||
cg.add(var.set_duration(template_))
|
||||
|
||||
return var
|
||||
@@ -236,7 +236,7 @@ async def ezo_pmp_dose_with_constant_flow_rate_to_code(
|
||||
template_ = await cg.templatable(config[CONF_VOLUME_PER_MINUTE], args, cg.double)
|
||||
cg.add(var.set_volume(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_DURATION], args, int)
|
||||
template_ = await cg.templatable(config[CONF_DURATION], args, cg.int_)
|
||||
cg.add(var.set_duration(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -345,10 +345,10 @@ async def fan_turn_on_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
if (oscillating := config.get(CONF_OSCILLATING)) is not None:
|
||||
template_ = await cg.templatable(oscillating, args, bool)
|
||||
template_ = await cg.templatable(oscillating, args, cg.bool_)
|
||||
cg.add(var.set_oscillating(template_))
|
||||
if (speed := config.get(CONF_SPEED)) is not None:
|
||||
template_ = await cg.templatable(speed, args, int)
|
||||
template_ = await cg.templatable(speed, args, cg.int_)
|
||||
cg.add(var.set_speed(template_))
|
||||
if (direction := config.get(CONF_DIRECTION)) is not None:
|
||||
template_ = await cg.templatable(direction, args, FanDirection)
|
||||
@@ -370,7 +370,7 @@ async def fan_turn_on_to_code(config, action_id, template_arg, args):
|
||||
async def fan_cycle_speed_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_OFF_SPEED_CYCLE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_OFF_SPEED_CYCLE], args, cg.bool_)
|
||||
cg.add(var.set_no_off_cycle(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -118,6 +118,6 @@ async def set_heater_level_to_code(config, action_id, template_arg, args):
|
||||
async def set_heater_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
status_ = await cg.templatable(config[CONF_STATUS], args, bool)
|
||||
status_ = await cg.templatable(config[CONF_STATUS], args, cg.bool_)
|
||||
cg.add(var.set_status(status_))
|
||||
return var
|
||||
|
||||
@@ -133,6 +133,6 @@ async def sensor_integration_reset_to_code(config, action_id, template_arg, args
|
||||
async def sensor_integration_set_value_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, cg.float_)
|
||||
cg.add(var.set_value(template_))
|
||||
return var
|
||||
|
||||
@@ -140,8 +140,11 @@ SerializationBuffer<> JsonBuilder::serialize() {
|
||||
heap_size *= 2;
|
||||
}
|
||||
// Payload exceeds 5120 bytes - return truncated result
|
||||
ESP_LOGW(TAG, "JSON payload too large, truncated to %zu bytes", size);
|
||||
result.set_size_(size);
|
||||
// heap_size was doubled after the last iteration, so the actual allocated
|
||||
// buffer capacity is heap_size/2. Clamp to avoid writing past the buffer.
|
||||
size_t max_content = heap_size / 2 - 1;
|
||||
ESP_LOGW(TAG, "JSON payload too large, truncated to %zu bytes", max_content);
|
||||
result.set_size_(max_content);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,6 @@ async def to_code(config):
|
||||
async def ledc_set_frequency_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, float)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, cg.float_)
|
||||
cg.add(var.set_frequency(template_))
|
||||
return var
|
||||
|
||||
@@ -43,6 +43,6 @@ async def to_code(config):
|
||||
async def libretiny_pwm_set_frequency_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, float)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, cg.float_)
|
||||
cg.add(var.set_frequency(template_))
|
||||
return var
|
||||
|
||||
@@ -183,18 +183,18 @@ async def light_control_to_code(config, action_id, template_arg, args):
|
||||
# (config_key, setter_name, c++ type)
|
||||
FIELDS = (
|
||||
(CONF_COLOR_MODE, "set_color_mode", ColorMode),
|
||||
(CONF_STATE, "set_state", bool),
|
||||
(CONF_STATE, "set_state", cg.bool_),
|
||||
(CONF_TRANSITION_LENGTH, "set_transition_length", cg.uint32),
|
||||
(CONF_FLASH_LENGTH, "set_flash_length", cg.uint32),
|
||||
(CONF_BRIGHTNESS, "set_brightness", float),
|
||||
(CONF_COLOR_BRIGHTNESS, "set_color_brightness", float),
|
||||
(CONF_RED, "set_red", float),
|
||||
(CONF_GREEN, "set_green", float),
|
||||
(CONF_BLUE, "set_blue", float),
|
||||
(CONF_WHITE, "set_white", float),
|
||||
(CONF_COLOR_TEMPERATURE, "set_color_temperature", float),
|
||||
(CONF_COLD_WHITE, "set_cold_white", float),
|
||||
(CONF_WARM_WHITE, "set_warm_white", float),
|
||||
(CONF_BRIGHTNESS, "set_brightness", cg.float_),
|
||||
(CONF_COLOR_BRIGHTNESS, "set_color_brightness", cg.float_),
|
||||
(CONF_RED, "set_red", cg.float_),
|
||||
(CONF_GREEN, "set_green", cg.float_),
|
||||
(CONF_BLUE, "set_blue", cg.float_),
|
||||
(CONF_WHITE, "set_white", cg.float_),
|
||||
(CONF_COLOR_TEMPERATURE, "set_color_temperature", cg.float_),
|
||||
(CONF_COLD_WHITE, "set_cold_white", cg.float_),
|
||||
(CONF_WARM_WHITE, "set_warm_white", cg.float_),
|
||||
)
|
||||
for conf_key, setter, type_ in FIELDS:
|
||||
if conf_key in config:
|
||||
@@ -262,7 +262,7 @@ LIGHT_DIM_RELATIVE_ACTION_SCHEMA = cv.Schema(
|
||||
async def light_dim_relative_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
templ = await cg.templatable(config[CONF_RELATIVE_BRIGHTNESS], args, float)
|
||||
templ = await cg.templatable(config[CONF_RELATIVE_BRIGHTNESS], args, cg.float_)
|
||||
cg.add(var.set_relative_brightness(templ))
|
||||
if CONF_TRANSITION_LENGTH in config:
|
||||
templ = await cg.templatable(config[CONF_TRANSITION_LENGTH], args, cg.uint32)
|
||||
|
||||
@@ -305,7 +305,7 @@ _register_state_conditions()
|
||||
async def media_player_volume_set_action(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
volume = await cg.templatable(config[CONF_VOLUME], args, float)
|
||||
volume = await cg.templatable(config[CONF_VOLUME], args, cg.float_)
|
||||
cg.add(var.set_volume(volume))
|
||||
return var
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from .. import (
|
||||
modbus_controller_ns,
|
||||
)
|
||||
from ..const import (
|
||||
CONF_CUSTOM_COMMAND,
|
||||
CONF_MODBUS_CONTROLLER_ID,
|
||||
CONF_REGISTER_TYPE,
|
||||
CONF_USE_WRITE_MULTIPLE,
|
||||
@@ -35,6 +36,10 @@ CONFIG_SCHEMA = cv.typed_schema(
|
||||
"coil": output.BINARY_OUTPUT_SCHEMA.extend(ModbusItemBaseSchema).extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(ModbusBinaryOutput),
|
||||
cv.Required(CONF_ADDRESS): cv.positive_int,
|
||||
cv.Optional(CONF_CUSTOM_COMMAND): cv.invalid(
|
||||
"custom_command is not supported for outputs"
|
||||
),
|
||||
cv.Optional(CONF_WRITE_LAMBDA): cv.returning_lambda,
|
||||
cv.Optional(CONF_USE_WRITE_MULTIPLE, default=False): cv.boolean,
|
||||
}
|
||||
@@ -42,6 +47,10 @@ CONFIG_SCHEMA = cv.typed_schema(
|
||||
"holding": output.FLOAT_OUTPUT_SCHEMA.extend(ModbusItemBaseSchema).extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(ModbusFloatOutput),
|
||||
cv.Required(CONF_ADDRESS): cv.positive_int,
|
||||
cv.Optional(CONF_CUSTOM_COMMAND): cv.invalid(
|
||||
"custom_command is not supported for outputs"
|
||||
),
|
||||
cv.Optional(CONF_VALUE_TYPE, default="U_WORD"): cv.enum(
|
||||
SENSOR_VALUE_TYPE
|
||||
),
|
||||
|
||||
@@ -61,7 +61,7 @@ async def to_code(config):
|
||||
response_size = config[CONF_RESPONSE_SIZE]
|
||||
reg_count = config[CONF_REGISTER_COUNT]
|
||||
if reg_count == 0:
|
||||
reg_count = response_size / 2
|
||||
reg_count = response_size // 2
|
||||
var = cg.new_Pvariable(
|
||||
config[CONF_ID],
|
||||
config[CONF_REGISTER_TYPE],
|
||||
|
||||
@@ -504,7 +504,7 @@ async def mqtt_publish_action_to_code(config, action_id, template_arg, args):
|
||||
cg.add(var.set_payload(template_))
|
||||
template_ = await cg.templatable(config[CONF_QOS], args, cg.uint8)
|
||||
cg.add(var.set_qos(template_))
|
||||
template_ = await cg.templatable(config[CONF_RETAIN], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_RETAIN], args, cg.bool_)
|
||||
cg.add(var.set_retain(template_))
|
||||
return var
|
||||
|
||||
@@ -537,7 +537,7 @@ async def mqtt_publish_json_action_to_code(config, action_id, template_arg, args
|
||||
cg.add(var.set_payload(lambda_))
|
||||
template_ = await cg.templatable(config[CONF_QOS], args, cg.uint8)
|
||||
cg.add(var.set_qos(template_))
|
||||
template_ = await cg.templatable(config[CONF_RETAIN], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_RETAIN], args, cg.bool_)
|
||||
cg.add(var.set_retain(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -76,13 +76,13 @@ async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.bool_)
|
||||
cg.add(var.set_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, cg.bool_)
|
||||
cg.add(var.set_publish_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, cg.bool_)
|
||||
cg.add(var.set_send_to_nextion(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -148,7 +148,7 @@ async def nextion_set_brightness_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, float)
|
||||
template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, cg.float_)
|
||||
cg.add(var.set_brightness(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -116,13 +116,13 @@ async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.float_)
|
||||
cg.add(var.set_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, cg.bool_)
|
||||
cg.add(var.set_publish_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, cg.bool_)
|
||||
cg.add(var.set_send_to_nextion(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -58,13 +58,13 @@ async def sensor_nextion_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.bool_)
|
||||
cg.add(var.set_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_PUBLISH_STATE], args, cg.bool_)
|
||||
cg.add(var.set_publish_state(template_))
|
||||
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_SEND_TO_NEXTION], args, cg.bool_)
|
||||
cg.add(var.set_send_to_nextion(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -257,10 +257,14 @@ async def _build_number_automations(var, config):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await cg.register_component(trigger, conf)
|
||||
if CONF_ABOVE in conf:
|
||||
template_ = await cg.templatable(conf[CONF_ABOVE], [(float, "x")], float)
|
||||
template_ = await cg.templatable(
|
||||
conf[CONF_ABOVE], [(float, "x")], cg.float_
|
||||
)
|
||||
cg.add(trigger.set_min(template_))
|
||||
if CONF_BELOW in conf:
|
||||
template_ = await cg.templatable(conf[CONF_BELOW], [(float, "x")], float)
|
||||
template_ = await cg.templatable(
|
||||
conf[CONF_BELOW], [(float, "x")], cg.float_
|
||||
)
|
||||
cg.add(trigger.set_max(template_))
|
||||
await automation.build_automation(trigger, [(float, "x")], conf)
|
||||
|
||||
@@ -362,7 +366,7 @@ OPERATION_BASE_SCHEMA = cv.Schema(
|
||||
async def number_set_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, cg.float_)
|
||||
cg.add(var.set_value(template_))
|
||||
return var
|
||||
|
||||
@@ -445,7 +449,7 @@ async def number_to_to_code(config, action_id, template_arg, args):
|
||||
to_ = await cg.templatable(operation, args, NumberOperation)
|
||||
cg.add(var.set_operation(to_))
|
||||
if (cycle := config.get(CONF_CYCLE)) is not None:
|
||||
template_ = await cg.templatable(cycle, args, bool)
|
||||
template_ = await cg.templatable(cycle, args, cg.bool_)
|
||||
cg.add(var.set_cycle(template_))
|
||||
if (mode := config.get(CONF_MODE)) is not None:
|
||||
template_ = await cg.templatable(
|
||||
|
||||
@@ -100,7 +100,7 @@ async def online_image_action_to_code(config, action_id, template_arg, args):
|
||||
template_ = await cg.templatable(config[CONF_URL], args, cg.std_string)
|
||||
cg.add(var.set_url(template_))
|
||||
if CONF_UPDATE in config:
|
||||
template_ = await cg.templatable(config[CONF_UPDATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_UPDATE], args, cg.bool_)
|
||||
cg.add(var.set_update(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ async def output_turn_off_to_code(config, action_id, template_arg, args):
|
||||
async def output_set_level_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, float)
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, cg.float_)
|
||||
cg.add(var.set_level(template_))
|
||||
return var
|
||||
|
||||
@@ -123,7 +123,7 @@ async def output_set_level_to_code(config, action_id, template_arg, args):
|
||||
async def output_set_min_power_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_MIN_POWER], args, float)
|
||||
template_ = await cg.templatable(config[CONF_MIN_POWER], args, cg.float_)
|
||||
cg.add(var.set_min_power(template_))
|
||||
return var
|
||||
|
||||
@@ -142,7 +142,7 @@ async def output_set_min_power_to_code(config, action_id, template_arg, args):
|
||||
async def output_set_max_power_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_MAX_POWER], args, float)
|
||||
template_ = await cg.templatable(config[CONF_MAX_POWER], args, cg.float_)
|
||||
cg.add(var.set_max_power(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -189,13 +189,13 @@ async def set_control_parameters(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
kp_template_ = await cg.templatable(config[CONF_KP], args, float)
|
||||
kp_template_ = await cg.templatable(config[CONF_KP], args, cg.float_)
|
||||
cg.add(var.set_kp(kp_template_))
|
||||
|
||||
ki_template_ = await cg.templatable(config[CONF_KI], args, float)
|
||||
ki_template_ = await cg.templatable(config[CONF_KI], args, cg.float_)
|
||||
cg.add(var.set_ki(ki_template_))
|
||||
|
||||
kd_template_ = await cg.templatable(config[CONF_KD], args, float)
|
||||
kd_template_ = await cg.templatable(config[CONF_KD], args, cg.float_)
|
||||
cg.add(var.set_kd(kd_template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -103,6 +103,6 @@ async def to_code(config):
|
||||
async def output_pipsolar_set_level_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, cg.float_)
|
||||
cg.add(var.set_level(template_))
|
||||
return var
|
||||
|
||||
@@ -137,6 +137,6 @@ PMWCS3_NEW_I2C_ADDRESS_SCHEMA = cv.maybe_simple_value(
|
||||
async def pmwcs3newi2caddress_to_code(config, action_id, template_arg, args):
|
||||
parent = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, parent)
|
||||
address = await cg.templatable(config[CONF_ADDRESS], args, int)
|
||||
address = await cg.templatable(config[CONF_ADDRESS], args, cg.int_)
|
||||
cg.add(var.set_new_address(address))
|
||||
return var
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
|
||||
CONF_DRAW_FROM_ORIGIN = "draw_from_origin"
|
||||
|
||||
DEPRECATED_COMPONENT = """
|
||||
The 'qspi_dbi' component is deprecated and no new models will be added to it.
|
||||
New model PRs should target the newer and more performant 'mipi_spi' component.
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import display, spi
|
||||
@@ -29,6 +31,7 @@ from . import CONF_DRAW_FROM_ORIGIN
|
||||
from .models import DriverChip
|
||||
|
||||
DEPENDENCIES = ["spi"]
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
qspi_dbi_ns = cg.esphome_ns.namespace("qspi_dbi")
|
||||
QSPI_DBI = qspi_dbi_ns.class_(
|
||||
@@ -154,11 +157,15 @@ CONFIG_SCHEMA = cv.All(
|
||||
upper=True,
|
||||
key=CONF_MODEL,
|
||||
),
|
||||
_validate,
|
||||
cv.only_on_esp32,
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
LOGGER.warning(
|
||||
"The 'qspi_dbi' component is deprecated, it is recommended to use 'mipi_spi' instead."
|
||||
)
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await display.register_display(var, config)
|
||||
await spi.register_spi_device(var, config, write_only=True)
|
||||
|
||||
@@ -868,7 +868,7 @@ async def keeloq_action(var, config, args):
|
||||
cg.add(var.set_encrypted(template_))
|
||||
template_ = await cg.templatable(config[CONF_COMMAND], args, cg.uint8)
|
||||
cg.add(var.set_command(template_))
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, cg.bool_)
|
||||
cg.add(var.set_vlow(template_))
|
||||
|
||||
|
||||
@@ -1580,7 +1580,7 @@ async def rc_switch_type_a_action(var, config, args):
|
||||
cg.add(
|
||||
var.set_device(await cg.templatable(config[CONF_DEVICE], args, cg.std_string))
|
||||
)
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, bool)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, cg.bool_)))
|
||||
|
||||
|
||||
@register_binary_sensor(
|
||||
@@ -1605,7 +1605,7 @@ async def rc_switch_type_b_action(var, config, args):
|
||||
cg.add(var.set_protocol(proto))
|
||||
cg.add(var.set_address(await cg.templatable(config[CONF_ADDRESS], args, cg.uint8)))
|
||||
cg.add(var.set_channel(await cg.templatable(config[CONF_CHANNEL], args, cg.uint8)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, bool)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, cg.bool_)))
|
||||
|
||||
|
||||
@register_binary_sensor(
|
||||
@@ -1638,7 +1638,7 @@ async def rc_switch_type_c_action(var, config, args):
|
||||
)
|
||||
cg.add(var.set_group(await cg.templatable(config[CONF_GROUP], args, cg.uint8)))
|
||||
cg.add(var.set_device(await cg.templatable(config[CONF_DEVICE], args, cg.uint8)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, bool)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, cg.bool_)))
|
||||
|
||||
|
||||
@register_binary_sensor(
|
||||
@@ -1663,7 +1663,7 @@ async def rc_switch_type_d_action(var, config, args):
|
||||
cg.add(var.set_protocol(proto))
|
||||
cg.add(var.set_group(await cg.templatable(config[CONF_GROUP], args, cg.std_string)))
|
||||
cg.add(var.set_device(await cg.templatable(config[CONF_DEVICE], args, cg.uint8)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, bool)))
|
||||
cg.add(var.set_state(await cg.templatable(config[CONF_STATE], args, cg.bool_)))
|
||||
|
||||
|
||||
@register_trigger("rc_switch", RCSwitchTrigger, RCSwitchData)
|
||||
|
||||
@@ -128,7 +128,7 @@ DIGITAL_WRITE_ACTION_SCHEMA = cv.maybe_simple_value(
|
||||
async def digital_write_action_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_TRANSMITTER_ID])
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], args, cg.bool_)
|
||||
cg.add(var.set_value(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -47,6 +47,6 @@ async def to_code(config):
|
||||
async def rp2040_set_frequency_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, float)
|
||||
template_ = await cg.templatable(config[CONF_FREQUENCY], args, cg.float_)
|
||||
cg.add(var.set_frequency(template_))
|
||||
return var
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
|
||||
DEPRECATED_COMPONENT = """
|
||||
The 'rpi_dpi_rgb' component is deprecated and no new models will be added to it.
|
||||
New model PRs should target the newer and more performant 'mipi_rgb' component.
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import display
|
||||
@@ -38,6 +40,7 @@ from esphome.const import (
|
||||
)
|
||||
|
||||
DEPENDENCIES = ["esp32"]
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
rpi_dpi_rgb_ns = cg.esphome_ns.namespace("rpi_dpi_rgb")
|
||||
RPI_DPI_RGB = rpi_dpi_rgb_ns.class_("RpiDpiRgb", display.Display, cg.Component)
|
||||
@@ -126,6 +129,9 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
LOGGER.warning(
|
||||
"The 'rpi_dpi_rgb' component is deprecated, it is recommended to use 'mipi_rgb' instead."
|
||||
)
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await display.register_display(var, config)
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ async def select_operation_to_code(config, action_id, template_arg, args):
|
||||
op_ = await cg.templatable(operation, args, SelectOperation)
|
||||
cg.add(var.set_operation(op_))
|
||||
if (cycle := config.get(CONF_CYCLE)) is not None:
|
||||
template_ = await cg.templatable(cycle, args, bool)
|
||||
template_ = await cg.templatable(cycle, args, cg.bool_)
|
||||
cg.add(var.set_cycle(template_))
|
||||
if (mode := config.get(CONF_MODE)) is not None:
|
||||
template_ = await cg.templatable(
|
||||
|
||||
@@ -371,13 +371,13 @@ def sensor_schema(
|
||||
|
||||
@FILTER_REGISTRY.register("offset", OffsetFilter, cv.templatable(cv.float_))
|
||||
async def offset_filter_to_code(config, filter_id):
|
||||
template_ = await cg.templatable(config, [], float)
|
||||
template_ = await cg.templatable(config, [], cg.float_)
|
||||
return cg.new_Pvariable(filter_id, template_)
|
||||
|
||||
|
||||
@FILTER_REGISTRY.register("multiply", MultiplyFilter, cv.templatable(cv.float_))
|
||||
async def multiply_filter_to_code(config, filter_id):
|
||||
template_ = await cg.templatable(config, [], float)
|
||||
template_ = await cg.templatable(config, [], cg.float_)
|
||||
return cg.new_Pvariable(filter_id, template_)
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ async def multiply_filter_to_code(config, filter_id):
|
||||
async def filter_out_filter_to_code(config, filter_id):
|
||||
if not isinstance(config, list):
|
||||
config = [config]
|
||||
template_ = [await cg.templatable(x, [], float) for x in config]
|
||||
template_ = [await cg.templatable(x, [], cg.float_) for x in config]
|
||||
return cg.new_Pvariable(filter_id, cg.TemplateArguments(len(template_)), template_)
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ THROTTLE_WITH_PRIORITY_SCHEMA = cv.maybe_simple_value(
|
||||
async def throttle_with_priority_filter_to_code(config, filter_id):
|
||||
if not isinstance(config[CONF_VALUE], list):
|
||||
config[CONF_VALUE] = [config[CONF_VALUE]]
|
||||
template_ = [await cg.templatable(x, [], float) for x in config[CONF_VALUE]]
|
||||
template_ = [await cg.templatable(x, [], cg.float_) for x in config[CONF_VALUE]]
|
||||
return cg.new_Pvariable(
|
||||
filter_id, cg.TemplateArguments(len(template_)), config[CONF_TIMEOUT], template_
|
||||
)
|
||||
@@ -713,7 +713,7 @@ async def timeout_filter_to_code(config, filter_id):
|
||||
else:
|
||||
# Use TimeoutFilterConfigured for configured value mode
|
||||
filter_id.type = TimeoutFilterConfigured
|
||||
template_ = await cg.templatable(config[CONF_VALUE], [], float)
|
||||
template_ = await cg.templatable(config[CONF_VALUE], [], cg.float_)
|
||||
var = cg.new_Pvariable(filter_id, config[CONF_TIMEOUT], template_)
|
||||
await cg.register_component(var, {})
|
||||
return var
|
||||
@@ -909,10 +909,10 @@ async def _build_sensor_automations(var, config):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await cg.register_component(trigger, conf)
|
||||
if (above := conf.get(CONF_ABOVE)) is not None:
|
||||
template_ = await cg.templatable(above, [(float, "x")], float)
|
||||
template_ = await cg.templatable(above, [(float, "x")], cg.float_)
|
||||
cg.add(trigger.set_min(template_))
|
||||
if (below := conf.get(CONF_BELOW)) is not None:
|
||||
template_ = await cg.templatable(below, [(float, "x")], float)
|
||||
template_ = await cg.templatable(below, [(float, "x")], cg.float_)
|
||||
cg.add(trigger.set_max(template_))
|
||||
await automation.build_automation(trigger, [(float, "x")], conf)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ async def to_code(config):
|
||||
async def servo_write_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, float)
|
||||
template_ = await cg.templatable(config[CONF_LEVEL], args, cg.float_)
|
||||
cg.add(var.set_value(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ automation.register_condition(
|
||||
async def speaker_volume_set_action(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
volume = await cg.templatable(config[CONF_VOLUME], args, float)
|
||||
volume = await cg.templatable(config[CONF_VOLUME], args, cg.float_)
|
||||
cg.add(var.set_volume(volume))
|
||||
return var
|
||||
|
||||
|
||||
@@ -246,11 +246,15 @@ def validate_hw_pins(spi, index=-1):
|
||||
return clk_pin_no >= 0
|
||||
|
||||
if target_platform == PLATFORM_RP2040:
|
||||
pin_set = (
|
||||
list(filter(lambda s: clk_pin_no in s[CONF_CLK_PIN], RP_SPI_PINSETS))[0]
|
||||
if index == -1
|
||||
else RP_SPI_PINSETS[index]
|
||||
)
|
||||
if index == -1:
|
||||
matches = list(
|
||||
filter(lambda s: clk_pin_no in s[CONF_CLK_PIN], RP_SPI_PINSETS)
|
||||
)
|
||||
if not matches:
|
||||
return False
|
||||
pin_set = matches[0]
|
||||
else:
|
||||
pin_set = RP_SPI_PINSETS[index]
|
||||
if pin_set is None:
|
||||
return False
|
||||
if sdo_pin_no not in pin_set[CONF_MOSI_PIN]:
|
||||
|
||||
@@ -196,7 +196,7 @@ SWITCH_CONTROL_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
async def switch_control_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.bool_)
|
||||
cg.add(var.set_state(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -64,6 +64,6 @@ async def to_code(config):
|
||||
async def binary_sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.bool_)
|
||||
cg.add(var.set_state(template_))
|
||||
return var
|
||||
|
||||
@@ -130,13 +130,13 @@ async def cover_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
if CONF_STATE in config:
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if CONF_POSITION in config:
|
||||
template_ = await cg.templatable(config[CONF_POSITION], args, float)
|
||||
template_ = await cg.templatable(config[CONF_POSITION], args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if CONF_TILT in config:
|
||||
template_ = await cg.templatable(config[CONF_TILT], args, float)
|
||||
template_ = await cg.templatable(config[CONF_TILT], args, cg.float_)
|
||||
cg.add(var.set_tilt(template_))
|
||||
if CONF_CURRENT_OPERATION in config:
|
||||
template_ = await cg.templatable(
|
||||
|
||||
@@ -49,6 +49,6 @@ async def to_code(config):
|
||||
async def sensor_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, float)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.float_)
|
||||
cg.add(var.set_state(template_))
|
||||
return var
|
||||
|
||||
@@ -85,6 +85,6 @@ async def to_code(config):
|
||||
async def switch_template_publish_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_STATE], args, cg.bool_)
|
||||
cg.add(var.set_state(template_))
|
||||
return var
|
||||
|
||||
@@ -118,10 +118,10 @@ async def valve_template_publish_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
if state_config := config.get(CONF_STATE):
|
||||
template_ = await cg.templatable(state_config, args, float)
|
||||
template_ = await cg.templatable(state_config, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if (position_config := config.get(CONF_POSITION)) is not None:
|
||||
template_ = await cg.templatable(position_config, args, float)
|
||||
template_ = await cg.templatable(position_config, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if current_operation_config := config.get(CONF_CURRENT_OPERATION):
|
||||
template_ = await cg.templatable(
|
||||
|
||||
@@ -146,11 +146,11 @@ async def water_heater_template_publish_to_code(
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
|
||||
if current_temp := config.get(CONF_CURRENT_TEMPERATURE):
|
||||
template_ = await cg.templatable(current_temp, args, float)
|
||||
template_ = await cg.templatable(current_temp, args, cg.float_)
|
||||
cg.add(var.set_current_temperature(template_))
|
||||
|
||||
if target_temp := config.get(CONF_TARGET_TEMPERATURE):
|
||||
template_ = await cg.templatable(target_temp, args, float)
|
||||
template_ = await cg.templatable(target_temp, args, cg.float_)
|
||||
cg.add(var.set_target_temperature(template_))
|
||||
|
||||
if mode := config.get(CONF_MODE):
|
||||
@@ -158,11 +158,11 @@ async def water_heater_template_publish_to_code(
|
||||
cg.add(var.set_mode(template_))
|
||||
|
||||
if CONF_AWAY in config:
|
||||
template_ = await cg.templatable(config[CONF_AWAY], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_AWAY], args, cg.bool_)
|
||||
cg.add(var.set_away(template_))
|
||||
|
||||
if CONF_IS_ON in config:
|
||||
template_ = await cg.templatable(config[CONF_IS_ON], args, bool)
|
||||
template_ = await cg.templatable(config[CONF_IS_ON], args, cg.bool_)
|
||||
cg.add(var.set_is_on(template_))
|
||||
|
||||
return var
|
||||
|
||||
@@ -102,8 +102,8 @@ UFIRE_EC_CALIBRATE_PROBE_SCHEMA = cv.Schema(
|
||||
async def ufire_ec_calibrate_probe_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
solution_ = await cg.templatable(config[CONF_SOLUTION], args, float)
|
||||
temperature_ = await cg.templatable(config[CONF_TEMPERATURE], args, float)
|
||||
solution_ = await cg.templatable(config[CONF_SOLUTION], args, cg.float_)
|
||||
temperature_ = await cg.templatable(config[CONF_TEMPERATURE], args, cg.float_)
|
||||
cg.add(var.set_solution(solution_))
|
||||
cg.add(var.set_temperature(temperature_))
|
||||
return var
|
||||
|
||||
@@ -96,7 +96,7 @@ UFIRE_ISE_CALIBRATE_PROBE_SCHEMA = cv.Schema(
|
||||
async def ufire_ise_calibrate_probe_low_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_SOLUTION], args, float)
|
||||
template_ = await cg.templatable(config[CONF_SOLUTION], args, cg.float_)
|
||||
cg.add(var.set_solution(template_))
|
||||
return var
|
||||
|
||||
@@ -110,7 +110,7 @@ async def ufire_ise_calibrate_probe_low_to_code(config, action_id, template_arg,
|
||||
async def ufire_ise_calibrate_probe_high_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_SOLUTION], args, float)
|
||||
template_ = await cg.templatable(config[CONF_SOLUTION], args, cg.float_)
|
||||
cg.add(var.set_solution(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -229,13 +229,13 @@ async def valve_control_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
if stop_config := config.get(CONF_STOP):
|
||||
template_ = await cg.templatable(stop_config, args, bool)
|
||||
template_ = await cg.templatable(stop_config, args, cg.bool_)
|
||||
cg.add(var.set_stop(template_))
|
||||
if state_config := config.get(CONF_STATE):
|
||||
template_ = await cg.templatable(state_config, args, float)
|
||||
template_ = await cg.templatable(state_config, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
if (position_config := config.get(CONF_POSITION)) is not None:
|
||||
template_ = await cg.templatable(position_config, args, float)
|
||||
template_ = await cg.templatable(position_config, args, cg.float_)
|
||||
cg.add(var.set_position(template_))
|
||||
return var
|
||||
|
||||
|
||||
@@ -199,11 +199,14 @@ def zephyr_add_user(key, value):
|
||||
def copy_files():
|
||||
user = zephyr_data()[KEY_USER]
|
||||
if user:
|
||||
entries = " ".join(
|
||||
f"{key} = {', '.join(value)};" for key, value in user.items()
|
||||
)
|
||||
zephyr_add_overlay(
|
||||
f"""
|
||||
/ {{
|
||||
zephyr,user {{
|
||||
{[f"{key} = {', '.join(value)};" for key, value in user.items()][0]}
|
||||
{entries}
|
||||
}};
|
||||
}};
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user