mirror of
https://github.com/esphome/esphome.git
synced 2025-03-03 17:28:16 +00:00
Merge branch 'dev' into nvds-new-espnow
This commit is contained in:
commit
241644d464
@ -409,6 +409,7 @@ esphome/components/substitutions/* @esphome/core
|
||||
esphome/components/sun/* @OttoWinter
|
||||
esphome/components/sun_gtil2/* @Mat931
|
||||
esphome/components/switch/* @esphome/core
|
||||
esphome/components/switch/binary_sensor/* @ssieb
|
||||
esphome/components/t6615/* @tylermenezes
|
||||
esphome/components/tc74/* @sethgirvan
|
||||
esphome/components/tca9548a/* @andreashergert1984
|
||||
|
@ -36,8 +36,8 @@ int Nextion::upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &r
|
||||
ESP_LOGV(TAG, "Requesting range: %s", range_header);
|
||||
esp_http_client_set_header(http_client, "Range", range_header);
|
||||
ESP_LOGV(TAG, "Opening HTTP connetion");
|
||||
esp_err_t err;
|
||||
if ((err = esp_http_client_open(http_client, 0)) != ESP_OK) {
|
||||
esp_err_t err = esp_http_client_open(http_client, 0);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
|
||||
return -1;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class OTAStateChangeTrigger : public Trigger<OTAState> {
|
||||
explicit OTAStateChangeTrigger(OTAComponent *parent) {
|
||||
parent->add_on_state_callback([this, parent](OTAState state, float progress, uint8_t error) {
|
||||
if (!parent->is_failed()) {
|
||||
return trigger(state);
|
||||
trigger(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace safe_mode {
|
||||
class SafeModeTrigger : public Trigger<> {
|
||||
public:
|
||||
explicit SafeModeTrigger(SafeModeComponent *parent) {
|
||||
parent->add_on_safe_mode_callback([this, parent]() { trigger(); });
|
||||
parent->add_on_safe_mode_callback([this]() { trigger(); });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/components/stepper/stepper.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace stepper {
|
||||
|
31
esphome/components/switch/binary_sensor/__init__.py
Normal file
31
esphome/components/switch/binary_sensor/__init__.py
Normal file
@ -0,0 +1,31 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_SOURCE_ID
|
||||
|
||||
from .. import Switch, switch_ns
|
||||
|
||||
CODEOWNERS = ["@ssieb"]
|
||||
|
||||
SwitchBinarySensor = switch_ns.class_(
|
||||
"SwitchBinarySensor", binary_sensor.BinarySensor, cg.Component
|
||||
)
|
||||
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
binary_sensor.binary_sensor_schema(SwitchBinarySensor)
|
||||
.extend(
|
||||
{
|
||||
cv.Required(CONF_SOURCE_ID): cv.use_id(Switch),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = await binary_sensor.new_binary_sensor(config)
|
||||
await cg.register_component(var, config)
|
||||
|
||||
source = await cg.get_variable(config[CONF_SOURCE_ID])
|
||||
cg.add(var.set_source(source))
|
@ -0,0 +1,17 @@
|
||||
#include "switch_binary_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace switch_ {
|
||||
|
||||
static const char *const TAG = "switch.binary_sensor";
|
||||
|
||||
void SwitchBinarySensor::setup() {
|
||||
source_->add_on_state_callback([this](bool value) { this->publish_state(value); });
|
||||
this->publish_state(source_->state);
|
||||
}
|
||||
|
||||
void SwitchBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Switch Binary Sensor", this); }
|
||||
|
||||
} // namespace switch_
|
||||
} // namespace esphome
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "../switch.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace switch_ {
|
||||
|
||||
class SwitchBinarySensor : public binary_sensor::BinarySensor, public Component {
|
||||
public:
|
||||
void set_source(Switch *source) { source_ = source; }
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
|
||||
protected:
|
||||
Switch *source_;
|
||||
};
|
||||
|
||||
} // namespace switch_
|
||||
} // namespace esphome
|
@ -1,5 +1,6 @@
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "sx1509.h"
|
||||
#include "sx1509_gpio_pin.h"
|
||||
|
||||
namespace esphome {
|
||||
@ -13,7 +14,7 @@ bool SX1509GPIOPin::digital_read() { return this->parent_->digital_read(this->pi
|
||||
void SX1509GPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
|
||||
std::string SX1509GPIOPin::dump_summary() const {
|
||||
char buffer[32];
|
||||
snprintf(buffer, sizeof(buffer), "%u via sx1509", pin_);
|
||||
snprintf(buffer, sizeof(buffer), "%u via sx1509", this->pin_);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "sx1509.h"
|
||||
#include "esphome/core/gpio.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace sx1509 {
|
||||
@ -15,10 +15,10 @@ class SX1509GPIOPin : public GPIOPin {
|
||||
void digital_write(bool value) override;
|
||||
std::string dump_summary() const override;
|
||||
|
||||
void set_parent(SX1509Component *parent) { parent_ = parent; }
|
||||
void set_pin(uint8_t pin) { pin_ = pin; }
|
||||
void set_inverted(bool inverted) { inverted_ = inverted; }
|
||||
void set_flags(gpio::Flags flags) { flags_ = flags; }
|
||||
void set_parent(SX1509Component *parent) { this->parent_ = parent; }
|
||||
void set_pin(uint8_t pin) { this->pin_ = pin; }
|
||||
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
||||
void set_flags(gpio::Flags flags) { this->flags_ = flags; }
|
||||
|
||||
protected:
|
||||
SX1509Component *parent_;
|
||||
|
@ -40,7 +40,7 @@ class UARTDevice {
|
||||
|
||||
int available() { return this->parent_->available(); }
|
||||
|
||||
void flush() { return this->parent_->flush(); }
|
||||
void flush() { this->parent_->flush(); }
|
||||
|
||||
// Compat APIs
|
||||
int read() {
|
||||
|
@ -528,6 +528,7 @@ CONF_MULTIPLE = "multiple"
|
||||
CONF_MULTIPLEXER = "multiplexer"
|
||||
CONF_MULTIPLY = "multiply"
|
||||
CONF_NAME = "name"
|
||||
CONF_NAME_ADD_MAC_SUFFIX = "name_add_mac_suffix"
|
||||
CONF_NAME_FONT = "name_font"
|
||||
CONF_NBITS = "nbits"
|
||||
CONF_NEC = "nec"
|
||||
|
@ -21,6 +21,7 @@ from esphome.const import (
|
||||
CONF_LIBRARIES,
|
||||
CONF_MIN_VERSION,
|
||||
CONF_NAME,
|
||||
CONF_NAME_ADD_MAC_SUFFIX,
|
||||
CONF_ON_BOOT,
|
||||
CONF_ON_LOOP,
|
||||
CONF_ON_SHUTDOWN,
|
||||
@ -59,8 +60,6 @@ ProjectUpdateTrigger = cg.esphome_ns.class_(
|
||||
|
||||
VERSION_REGEX = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+(?:[ab]\d+)?$")
|
||||
|
||||
CONF_NAME_ADD_MAC_SUFFIX = "name_add_mac_suffix"
|
||||
|
||||
|
||||
VALID_INCLUDE_EXTS = {".h", ".hpp", ".tcc", ".ino", ".cpp", ".c"}
|
||||
|
||||
|
11
tests/components/switch/common.yaml
Normal file
11
tests/components/switch/common.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
binary_sensor:
|
||||
- platform: switch
|
||||
id: some_binary_sensor
|
||||
name: "Template Switch State"
|
||||
source_id: the_switch
|
||||
|
||||
switch:
|
||||
- platform: template
|
||||
name: "Template Switch"
|
||||
id: the_switch
|
||||
optimistic: true
|
2
tests/components/switch/test.bk72xx-ard.yaml
Normal file
2
tests/components/switch/test.bk72xx-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp32-ard.yaml
Normal file
2
tests/components/switch/test.esp32-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp32-c3-ard.yaml
Normal file
2
tests/components/switch/test.esp32-c3-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp32-c3-idf.yaml
Normal file
2
tests/components/switch/test.esp32-c3-idf.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp32-idf.yaml
Normal file
2
tests/components/switch/test.esp32-idf.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp32-s3-idf.yaml
Normal file
2
tests/components/switch/test.esp32-s3-idf.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.esp8266-ard.yaml
Normal file
2
tests/components/switch/test.esp8266-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
2
tests/components/switch/test.rp2040-ard.yaml
Normal file
2
tests/components/switch/test.rp2040-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
Loading…
x
Reference in New Issue
Block a user