1
0
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:
NP v/d Spek 2024-11-25 10:38:49 +01:00 committed by GitHub
commit 241644d464
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 112 additions and 14 deletions

View File

@ -409,6 +409,7 @@ esphome/components/substitutions/* @esphome/core
esphome/components/sun/* @OttoWinter esphome/components/sun/* @OttoWinter
esphome/components/sun_gtil2/* @Mat931 esphome/components/sun_gtil2/* @Mat931
esphome/components/switch/* @esphome/core esphome/components/switch/* @esphome/core
esphome/components/switch/binary_sensor/* @ssieb
esphome/components/t6615/* @tylermenezes esphome/components/t6615/* @tylermenezes
esphome/components/tc74/* @sethgirvan esphome/components/tc74/* @sethgirvan
esphome/components/tca9548a/* @andreashergert1984 esphome/components/tca9548a/* @andreashergert1984

View File

@ -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_LOGV(TAG, "Requesting range: %s", range_header);
esp_http_client_set_header(http_client, "Range", range_header); esp_http_client_set_header(http_client, "Range", range_header);
ESP_LOGV(TAG, "Opening HTTP connetion"); ESP_LOGV(TAG, "Opening HTTP connetion");
esp_err_t err; esp_err_t err = esp_http_client_open(http_client, 0);
if ((err = esp_http_client_open(http_client, 0)) != ESP_OK) { if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err)); ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
return -1; return -1;
} }

View File

@ -12,7 +12,7 @@ class OTAStateChangeTrigger : public Trigger<OTAState> {
explicit OTAStateChangeTrigger(OTAComponent *parent) { explicit OTAStateChangeTrigger(OTAComponent *parent) {
parent->add_on_state_callback([this, parent](OTAState state, float progress, uint8_t error) { parent->add_on_state_callback([this, parent](OTAState state, float progress, uint8_t error) {
if (!parent->is_failed()) { if (!parent->is_failed()) {
return trigger(state); trigger(state);
} }
}); });
} }

View File

@ -9,7 +9,7 @@ namespace safe_mode {
class SafeModeTrigger : public Trigger<> { class SafeModeTrigger : public Trigger<> {
public: public:
explicit SafeModeTrigger(SafeModeComponent *parent) { explicit SafeModeTrigger(SafeModeComponent *parent) {
parent->add_on_safe_mode_callback([this, parent]() { trigger(); }); parent->add_on_safe_mode_callback([this]() { trigger(); });
} }
}; };

View File

@ -2,7 +2,6 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/automation.h" #include "esphome/core/automation.h"
#include "esphome/components/stepper/stepper.h"
namespace esphome { namespace esphome {
namespace stepper { namespace stepper {

View 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))

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,6 @@
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "sx1509.h"
#include "sx1509_gpio_pin.h" #include "sx1509_gpio_pin.h"
namespace esphome { 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_); } void SX1509GPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
std::string SX1509GPIOPin::dump_summary() const { std::string SX1509GPIOPin::dump_summary() const {
char buffer[32]; char buffer[32];
snprintf(buffer, sizeof(buffer), "%u via sx1509", pin_); snprintf(buffer, sizeof(buffer), "%u via sx1509", this->pin_);
return buffer; return buffer;
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "sx1509.h" #include "esphome/core/gpio.h"
namespace esphome { namespace esphome {
namespace sx1509 { namespace sx1509 {
@ -15,10 +15,10 @@ class SX1509GPIOPin : public GPIOPin {
void digital_write(bool value) override; void digital_write(bool value) override;
std::string dump_summary() const override; std::string dump_summary() const override;
void set_parent(SX1509Component *parent) { parent_ = parent; } void set_parent(SX1509Component *parent) { this->parent_ = parent; }
void set_pin(uint8_t pin) { pin_ = pin; } void set_pin(uint8_t pin) { this->pin_ = pin; }
void set_inverted(bool inverted) { inverted_ = inverted; } void set_inverted(bool inverted) { this->inverted_ = inverted; }
void set_flags(gpio::Flags flags) { flags_ = flags; } void set_flags(gpio::Flags flags) { this->flags_ = flags; }
protected: protected:
SX1509Component *parent_; SX1509Component *parent_;

View File

@ -40,7 +40,7 @@ class UARTDevice {
int available() { return this->parent_->available(); } int available() { return this->parent_->available(); }
void flush() { return this->parent_->flush(); } void flush() { this->parent_->flush(); }
// Compat APIs // Compat APIs
int read() { int read() {

View File

@ -528,6 +528,7 @@ CONF_MULTIPLE = "multiple"
CONF_MULTIPLEXER = "multiplexer" CONF_MULTIPLEXER = "multiplexer"
CONF_MULTIPLY = "multiply" CONF_MULTIPLY = "multiply"
CONF_NAME = "name" CONF_NAME = "name"
CONF_NAME_ADD_MAC_SUFFIX = "name_add_mac_suffix"
CONF_NAME_FONT = "name_font" CONF_NAME_FONT = "name_font"
CONF_NBITS = "nbits" CONF_NBITS = "nbits"
CONF_NEC = "nec" CONF_NEC = "nec"

View File

@ -21,6 +21,7 @@ from esphome.const import (
CONF_LIBRARIES, CONF_LIBRARIES,
CONF_MIN_VERSION, CONF_MIN_VERSION,
CONF_NAME, CONF_NAME,
CONF_NAME_ADD_MAC_SUFFIX,
CONF_ON_BOOT, CONF_ON_BOOT,
CONF_ON_LOOP, CONF_ON_LOOP,
CONF_ON_SHUTDOWN, 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+)?$") 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"} VALID_INCLUDE_EXTS = {".h", ".hpp", ".tcc", ".ino", ".cpp", ".c"}

View 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

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml

View File

@ -0,0 +1,2 @@
packages:
common: !include common.yaml