Merge branch 'dev' into optolink

This commit is contained in:
j0ta29 2023-03-22 08:09:02 +01:00 committed by GitHub
commit d523d5da44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 1213 additions and 791 deletions

View file

@ -51,6 +51,6 @@
"files.associations": {
"**/.vscode/*.json": "jsonc"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format-11",
"C_Cpp.clang_format_path": "/usr/bin/clang-format-13",
}
}

View file

@ -41,6 +41,10 @@ jobs:
file: tests/test3.yaml
name: Test tests/test3.yaml
pio_cache_key: test3
- id: test
file: tests/test3.1.yaml
name: Test tests/test3.1.yaml
pio_cache_key: test3.1
- id: test
file: tests/test4.yaml
name: Test tests/test4.yaml
@ -129,7 +133,7 @@ jobs:
- name: Install clang tools
run: |
sudo apt-get install \
clang-format-11 \
clang-format-13 \
clang-tidy-11
if: matrix.id == 'clang-tidy' || matrix.id == 'clang-format'

View file

@ -135,7 +135,7 @@ RUN \
apt-get update \
# Use pinned versions so that we get updates with build caching
&& apt-get install -y --no-install-recommends \
clang-format-11=1:11.0.1-2 \
clang-format-13=1:13.0.1-6~deb11u1 \
clang-tidy-11=1:11.0.1-2 \
patch=2.7.6-7 \
software-properties-common=0.96.20.2-2.1 \

View file

@ -45,7 +45,7 @@ void APIServer::setup() {
struct sockaddr_storage server;
socklen_t sl = socket::set_sockaddr_any((struct sockaddr *) &server, sizeof(server), htons(this->port_));
socklen_t sl = socket::set_sockaddr_any((struct sockaddr *) &server, sizeof(server), this->port_);
if (sl == 0) {
ESP_LOGW(TAG, "Socket unable to set sockaddr: errno %d", errno);
this->mark_failed();

View file

@ -1,6 +1,6 @@
#include "bme680.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h"
#include "esphome/core/log.h"
namespace esphome {
namespace bme680 {

View file

@ -324,6 +324,10 @@ async def setup_climate_core_(var, config):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)
for conf in config.get(CONF_ON_CONTROL, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)
async def register_climate(var, config):
if not CORE.has_id(config[CONF_ID]):

View file

@ -33,7 +33,10 @@ void CTClampSensor::update() {
const float rms_ac_dc_squared = this->sample_squared_sum_ / this->num_samples_;
const float rms_dc = this->sample_sum_ / this->num_samples_;
const float rms_ac = std::sqrt(rms_ac_dc_squared - rms_dc * rms_dc);
const float rms_ac_squared = rms_ac_dc_squared - rms_dc * rms_dc;
float rms_ac = 0;
if (rms_ac_squared > 0)
rms_ac = std::sqrt(rms_ac_squared);
ESP_LOGD(TAG, "'%s' - Raw AC Value: %.3fA after %d different samples (%d SPS)", this->name_.c_str(), rms_ac,
this->num_samples_, 1000 * this->num_samples_ / this->sample_duration_);
this->publish_state(rms_ac);

View file

@ -45,7 +45,8 @@ class BLEClientBase : public espbt::ESPBTClient, public Component {
memset(this->remote_bda_, 0, sizeof(this->remote_bda_));
this->address_str_ = "";
} else {
this->address_str_ = str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, (uint8_t)(this->address_ >> 40) & 0xff,
this->address_str_ =
str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, (uint8_t) (this->address_ >> 40) & 0xff,
(uint8_t) (this->address_ >> 32) & 0xff, (uint8_t) (this->address_ >> 24) & 0xff,
(uint8_t) (this->address_ >> 16) & 0xff, (uint8_t) (this->address_ >> 8) & 0xff,
(uint8_t) (this->address_ >> 0) & 0xff);

View file

@ -55,6 +55,22 @@ FRAME_SIZES = {
"SXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1280X1024,
"1600X1200": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
"UXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1600X1200,
"1920X1080": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1920X1080,
"FHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1920X1080,
"720X1280": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_720X1280,
"PHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_720X1280,
"864X1536": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_864X1536,
"P3MP": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_864X1536,
"2048X1536": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2048X1536,
"QXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2048X1536,
"2560X1440": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1440,
"QHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1440,
"2560X1600": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1600,
"WQXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1600,
"1080X1920": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1080X1920,
"PFHD": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_1080X1920,
"2560X1920": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1920,
"QSXGA": ESP32CameraFrameSize.ESP32_CAMERA_SIZE_2560X1920,
}
ESP32GainControlMode = esp32_camera_ns.enum("ESP32GainControlMode")
ENUM_GAIN_CONTROL_MODE = {
@ -140,7 +156,7 @@ CONFIG_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
{
cv.Required(CONF_PIN): pins.internal_gpio_input_pin_number,
cv.Optional(CONF_FREQUENCY, default="20MHz"): cv.All(
cv.frequency, cv.one_of(20e6, 10e6)
cv.frequency, cv.Range(min=10e6, max=20e6)
),
}
),

View file

@ -91,6 +91,30 @@ void ESP32Camera::dump_config() {
case FRAMESIZE_UXGA:
ESP_LOGCONFIG(TAG, " Resolution: 1600x1200 (UXGA)");
break;
case FRAMESIZE_FHD:
ESP_LOGCONFIG(TAG, " Resolution: 1920x1080 (FHD)");
break;
case FRAMESIZE_P_HD:
ESP_LOGCONFIG(TAG, " Resolution: 720x1280 (P_HD)");
break;
case FRAMESIZE_P_3MP:
ESP_LOGCONFIG(TAG, " Resolution: 864x1536 (P_3MP)");
break;
case FRAMESIZE_QXGA:
ESP_LOGCONFIG(TAG, " Resolution: 2048x1536 (QXGA)");
break;
case FRAMESIZE_QHD:
ESP_LOGCONFIG(TAG, " Resolution: 2560x1440 (QHD)");
break;
case FRAMESIZE_WQXGA:
ESP_LOGCONFIG(TAG, " Resolution: 2560x1600 (WQXGA)");
break;
case FRAMESIZE_P_FHD:
ESP_LOGCONFIG(TAG, " Resolution: 1080x1920 (P_FHD)");
break;
case FRAMESIZE_QSXGA:
ESP_LOGCONFIG(TAG, " Resolution: 2560x1920 (QSXGA)");
break;
default:
break;
}
@ -257,6 +281,30 @@ void ESP32Camera::set_frame_size(ESP32CameraFrameSize size) {
case ESP32_CAMERA_SIZE_1600X1200:
this->config_.frame_size = FRAMESIZE_UXGA;
break;
case ESP32_CAMERA_SIZE_1920X1080:
this->config_.frame_size = FRAMESIZE_FHD;
break;
case ESP32_CAMERA_SIZE_720X1280:
this->config_.frame_size = FRAMESIZE_P_HD;
break;
case ESP32_CAMERA_SIZE_864X1536:
this->config_.frame_size = FRAMESIZE_P_3MP;
break;
case ESP32_CAMERA_SIZE_2048X1536:
this->config_.frame_size = FRAMESIZE_QXGA;
break;
case ESP32_CAMERA_SIZE_2560X1440:
this->config_.frame_size = FRAMESIZE_QHD;
break;
case ESP32_CAMERA_SIZE_2560X1600:
this->config_.frame_size = FRAMESIZE_WQXGA;
break;
case ESP32_CAMERA_SIZE_1080X1920:
this->config_.frame_size = FRAMESIZE_P_FHD;
break;
case ESP32_CAMERA_SIZE_2560X1920:
this->config_.frame_size = FRAMESIZE_QSXGA;
break;
}
}
void ESP32Camera::set_jpeg_quality(uint8_t quality) { this->config_.jpeg_quality = quality; }

View file

@ -29,6 +29,14 @@ enum ESP32CameraFrameSize {
ESP32_CAMERA_SIZE_1024X768, // XGA
ESP32_CAMERA_SIZE_1280X1024, // SXGA
ESP32_CAMERA_SIZE_1600X1200, // UXGA
ESP32_CAMERA_SIZE_1920X1080, // FHD
ESP32_CAMERA_SIZE_720X1280, // PHD
ESP32_CAMERA_SIZE_864X1536, // P3MP
ESP32_CAMERA_SIZE_2048X1536, // QXGA
ESP32_CAMERA_SIZE_2560X1440, // QHD
ESP32_CAMERA_SIZE_2560X1600, // WQXGA
ESP32_CAMERA_SIZE_1080X1920, // PFHD
ESP32_CAMERA_SIZE_2560X1920, // QSXGA
};
enum ESP32AgcGainCeiling {

View file

@ -255,14 +255,22 @@ void EthernetComponent::start_connect_() {
if (this->manual_ip_.has_value()) {
if (uint32_t(this->manual_ip_->dns1) != 0) {
ip_addr_t d;
#if LWIP_IPV6
d.type = IPADDR_TYPE_V4;
d.u_addr.ip4.addr = static_cast<uint32_t>(this->manual_ip_->dns1);
#else
d.addr = static_cast<uint32_t>(this->manual_ip_->dns1);
#endif
dns_setserver(0, &d);
}
if (uint32_t(this->manual_ip_->dns1) != 0) {
ip_addr_t d;
#if LWIP_IPV6
d.type = IPADDR_TYPE_V4;
d.u_addr.ip4.addr = static_cast<uint32_t>(this->manual_ip_->dns2);
#else
d.addr = static_cast<uint32_t>(this->manual_ip_->dns2);
#endif
dns_setserver(1, &d);
}
} else {
@ -289,8 +297,13 @@ void EthernetComponent::dump_connect_params_() {
const ip_addr_t *dns_ip1 = dns_getserver(0);
const ip_addr_t *dns_ip2 = dns_getserver(1);
#if LWIP_IPV6
ESP_LOGCONFIG(TAG, " DNS1: %s", network::IPAddress(dns_ip1->u_addr.ip4.addr).str().c_str());
ESP_LOGCONFIG(TAG, " DNS2: %s", network::IPAddress(dns_ip2->u_addr.ip4.addr).str().c_str());
#else
ESP_LOGCONFIG(TAG, " DNS1: %s", network::IPAddress(dns_ip1->addr).str().c_str());
ESP_LOGCONFIG(TAG, " DNS2: %s", network::IPAddress(dns_ip2->addr).str().c_str());
#endif
esp_err_t err;

View file

@ -1,8 +1,8 @@
#include "ili9xxx_display.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ili9xxx {

View file

@ -59,7 +59,8 @@ enum class ColorMode : uint8_t {
COLOR_TEMPERATURE =
(uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::COLOR_TEMPERATURE),
/// Cold and warm white output with individually controllable brightness.
COLD_WARM_WHITE = (uint8_t)(ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::COLD_WARM_WHITE),
COLD_WARM_WHITE =
(uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::COLD_WARM_WHITE),
/// RGB color output.
RGB = (uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::RGB),
/// RGB color output and a separate white output.

View file

@ -123,7 +123,8 @@ uint32_t MopekaProCheck::parse_distance_(const std::vector<uint8_t> &message) {
double raw_level = raw & 0x3FFF;
double raw_t = (message[2] & 0x7F);
return (uint32_t)(raw_level * (MOPEKA_LPG_COEF[0] + MOPEKA_LPG_COEF[1] * raw_t + MOPEKA_LPG_COEF[2] * raw_t * raw_t));
return (uint32_t) (raw_level *
(MOPEKA_LPG_COEF[0] + MOPEKA_LPG_COEF[1] * raw_t + MOPEKA_LPG_COEF[2] * raw_t * raw_t));
}
uint8_t MopekaProCheck::parse_temperature_(const std::vector<uint8_t> &message) { return (message[2] & 0x7F) - 40; }

View file

@ -2,16 +2,16 @@
#ifdef USE_MQTT
#include <utility>
#include "esphome/components/network/util.h"
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/components/network/util.h"
#include <utility>
#ifdef USE_LOGGER
#include "esphome/components/logger/logger.h"
#endif
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/err.h"
#include "mqtt_component.h"
namespace esphome {
@ -104,7 +104,11 @@ void MQTTClientComponent::start_dnslookup_() {
// Got IP immediately
this->dns_resolved_ = true;
#ifdef USE_ESP32
#if LWIP_IPV6
this->ip_ = addr.u_addr.ip4.addr;
#else
this->ip_ = addr.addr;
#endif
#endif
#ifdef USE_ESP8266
this->ip_ = addr.addr;
@ -160,8 +164,12 @@ void MQTTClientComponent::dns_found_callback(const char *name, const ip_addr_t *
a_this->dns_resolve_error_ = true;
} else {
#ifdef USE_ESP32
#if LWIP_IPV6
a_this->ip_ = ipaddr->u_addr.ip4.addr;
#else
a_this->ip_ = ipaddr->addr;
#endif
#endif // USE_ESP32
#ifdef USE_ESP8266
a_this->ip_ = ipaddr->addr;
#endif

View file

@ -22,6 +22,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
if CONF_ENABLE_IPV6 in config and config[CONF_ENABLE_IPV6]:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", True)
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", True)
if CONF_ENABLE_IPV6 in config:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", config[CONF_ENABLE_IPV6])
add_idf_sdkconfig_option(
"CONFIG_LWIP_IPV6_AUTOCONFIG", config[CONF_ENABLE_IPV6]
)

View file

@ -65,7 +65,7 @@ void OTAComponent::setup() {
struct sockaddr_storage server;
socklen_t sl = socket::set_sockaddr_any((struct sockaddr *) &server, sizeof(server), htons(this->port_));
socklen_t sl = socket::set_sockaddr_any((struct sockaddr *) &server, sizeof(server), this->port_);
if (sl == 0) {
ESP_LOGW(TAG, "Socket unable to set sockaddr: errno %d", errno);
this->mark_failed();

View file

@ -1,5 +1,6 @@
#pragma once
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/modbus/modbus.h"

View file

@ -194,6 +194,7 @@ SensorPublishAction = sensor_ns.class_("SensorPublishAction", automation.Action)
Filter = sensor_ns.class_("Filter")
QuantileFilter = sensor_ns.class_("QuantileFilter", Filter)
MedianFilter = sensor_ns.class_("MedianFilter", Filter)
SkipInitialFilter = sensor_ns.class_("SkipInitialFilter", Filter)
MinFilter = sensor_ns.class_("MinFilter", Filter)
MaxFilter = sensor_ns.class_("MaxFilter", Filter)
SlidingWindowMovingAverageFilter = sensor_ns.class_(
@ -365,6 +366,11 @@ MIN_SCHEMA = cv.All(
)
@FILTER_REGISTRY.register("skip_initial", SkipInitialFilter, cv.positive_not_null_int)
async def skip_initial_filter_to_code(config, filter_id):
return cg.new_Pvariable(filter_id, config)
@FILTER_REGISTRY.register("min", MinFilter, MIN_SCHEMA)
async def min_filter_to_code(config, filter_id):
return cg.new_Pvariable(

View file

@ -74,6 +74,19 @@ optional<float> MedianFilter::new_value(float value) {
return {};
}
// SkipInitialFilter
SkipInitialFilter::SkipInitialFilter(size_t num_to_ignore) : num_to_ignore_(num_to_ignore) {}
optional<float> SkipInitialFilter::new_value(float value) {
if (num_to_ignore_ > 0) {
num_to_ignore_--;
ESP_LOGV(TAG, "SkipInitialFilter(%p)::new_value(%f) SKIPPING, %u left", this, value, num_to_ignore_);
return {};
}
ESP_LOGV(TAG, "SkipInitialFilter(%p)::new_value(%f) SENDING", this, value);
return value;
}
// QuantileFilter
QuantileFilter::QuantileFilter(size_t window_size, size_t send_every, size_t send_first_at, float quantile)
: send_every_(send_every), send_at_(send_every - send_first_at), window_size_(window_size), quantile_(quantile) {}

View file

@ -102,6 +102,24 @@ class MedianFilter : public Filter {
size_t window_size_;
};
/** Simple skip filter.
*
* Skips the first N values, then passes everything else.
*/
class SkipInitialFilter : public Filter {
public:
/** Construct a SkipInitialFilter.
*
* @param num_to_ignore How many values to ignore before the filter becomes a no-op.
*/
explicit SkipInitialFilter(size_t num_to_ignore);
optional<float> new_value(float value) override;
protected:
size_t num_to_ignore_;
};
/** Simple min filter.
*
* Takes the min of the last <send_every> values and pushes it out every <send_every>.

View file

@ -20,7 +20,9 @@ std::string format_sockaddr(const struct sockaddr_storage &storage) {
char buf[INET_ADDRSTRLEN];
if (inet_ntop(AF_INET, &addr->sin_addr, buf, sizeof(buf)) != nullptr)
return std::string{buf};
} else if (storage.ss_family == AF_INET6) {
}
#if LWIP_IPV6
else if (storage.ss_family == AF_INET6) {
const struct sockaddr_in6 *addr = reinterpret_cast<const struct sockaddr_in6 *>(&storage);
char buf[INET6_ADDRSTRLEN];
// Format IPv4-mapped IPv6 addresses as regular IPv4 addresses
@ -32,6 +34,7 @@ std::string format_sockaddr(const struct sockaddr_storage &storage) {
if (inet_ntop(AF_INET6, &addr->sin6_addr, buf, sizeof(buf)) != nullptr)
return std::string{buf};
}
#endif
return {};
}

View file

@ -15,19 +15,28 @@
/* Address families. */
#define AF_UNSPEC 0
#define AF_INET 2
#define AF_INET6 10
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
#define PF_UNSPEC AF_UNSPEC
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#if LWIP_IPV6
#define AF_INET6 10
#define PF_INET6 AF_INET6
#define IPPROTO_IPV6 41
#define IPPROTO_ICMPV6 58
#endif
#define TCP_NODELAY 0x01
#define F_GETFL 3
#define F_SETFL 4
#ifdef O_NONBLOCK
#undef O_NONBLOCK
#endif
#define O_NONBLOCK 1
#define SHUT_RD 0
@ -58,6 +67,7 @@ struct sockaddr_in {
char sin_zero[SIN_ZERO_LEN];
};
#if LWIP_IPV6
// NOLINTNEXTLINE(readability-identifier-naming)
struct sockaddr_in6 {
uint8_t sin6_len; /* length of this structure */
@ -67,6 +77,7 @@ struct sockaddr_in6 {
struct in6_addr sin6_addr; /* IPv6 address */
uint32_t sin6_scope_id; /* Set of interfaces for scope */
};
#endif
// NOLINTNEXTLINE(readability-identifier-naming)
struct sockaddr {

View file

@ -14,6 +14,34 @@ std::unique_ptr<Socket> socket_ip(int type, int protocol) {
#endif
}
socklen_t set_sockaddr(struct sockaddr *addr, socklen_t addrlen, const char *ip_address, uint16_t port) {
#if LWIP_IPV6
if (addrlen < sizeof(sockaddr_in6)) {
errno = EINVAL;
return 0;
}
auto *server = reinterpret_cast<sockaddr_in6 *>(addr);
memset(server, 0, sizeof(sockaddr_in6));
server->sin6_family = AF_INET6;
server->sin6_port = htons(port);
ip6_addr_t ip6;
inet6_aton(ip_address, &ip6);
memcpy(server->sin6_addr.un.u32_addr, ip6.addr, sizeof(ip6.addr));
return sizeof(sockaddr_in6);
#else
if (addrlen < sizeof(sockaddr_in)) {
errno = EINVAL;
return 0;
}
auto *server = reinterpret_cast<sockaddr_in *>(addr);
memset(server, 0, sizeof(sockaddr_in));
server->sin_family = AF_INET;
server->sin_addr.s_addr = inet_addr(ip_address);
server->sin_port = htons(port);
return sizeof(sockaddr_in);
#endif
}
socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t port) {
#if LWIP_IPV6
if (addrlen < sizeof(sockaddr_in6)) {
@ -23,7 +51,7 @@ socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t po
auto *server = reinterpret_cast<sockaddr_in6 *>(addr);
memset(server, 0, sizeof(sockaddr_in6));
server->sin6_family = AF_INET6;
server->sin6_port = port;
server->sin6_port = htons(port);
server->sin6_addr = in6addr_any;
return sizeof(sockaddr_in6);
#else
@ -35,7 +63,7 @@ socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t po
memset(server, 0, sizeof(sockaddr_in));
server->sin_family = AF_INET;
server->sin_addr.s_addr = ESPHOME_INADDR_ANY;
server->sin_port = port;
server->sin_port = htons(port);
return sizeof(sockaddr_in);
#endif
}

View file

@ -44,7 +44,10 @@ std::unique_ptr<Socket> socket(int domain, int type, int protocol);
/// Create a socket in the newest available IP domain (IPv6 or IPv4) of the given type and protocol.
std::unique_ptr<Socket> socket_ip(int type, int protocol);
/// Set a sockaddr to the any address for the IP version used by socket_ip().
/// Set a sockaddr to the specified address and port for the IP version used by socket_ip().
socklen_t set_sockaddr(struct sockaddr *addr, socklen_t addrlen, const char *ip_address, uint16_t port);
/// Set a sockaddr to the any address and specified port for the IP version used by socket_ip().
socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t port);
} // namespace socket

View file

@ -29,6 +29,7 @@ WaveshareEPaper2P7In = waveshare_epaper_ns.class_(
WaveshareEPaper2P9InB = waveshare_epaper_ns.class_(
"WaveshareEPaper2P9InB", WaveshareEPaper
)
GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper)
WaveshareEPaper4P2In = waveshare_epaper_ns.class_(
"WaveshareEPaper4P2In", WaveshareEPaper
)
@ -73,6 +74,7 @@ MODELS = {
"2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74),
"2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
"2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2),
"gdey029t94": ("c", GDEY029T94),
"2.70in": ("b", WaveshareEPaper2P7In),
"2.90in-b": ("b", WaveshareEPaper2P9InB),
"4.20in": ("b", WaveshareEPaper4P2In),

View file

@ -663,6 +663,90 @@ void WaveshareEPaper2P9InB::dump_config() {
LOG_UPDATE_INTERVAL(this);
}
// ========================================================
// Good Display 2.9in black/white/grey
// Datasheet:
// - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1680.pdf
// - https://github.com/adafruit/Adafruit_EPD/blob/master/src/panels/ThinkInk_290_Grayscale4_T5.h
// ========================================================
void GDEY029T94::initialize() {
// from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37
// EPD hardware init start
this->reset_();
// COMMAND POWER SETTINGS
this->command(0x00);
this->data(0x03);
this->data(0x00);
this->data(0x2b);
this->data(0x2b);
this->data(0x03); /* for b/w */
// COMMAND BOOSTER SOFT START
this->command(0x06);
this->data(0x17);
this->data(0x17);
this->data(0x17);
// COMMAND POWER ON
this->command(0x04);
this->wait_until_idle_();
// Not sure what this does but it's in the Adafruit EPD library
this->command(0xFF);
this->wait_until_idle_();
// COMMAND PANEL SETTING
this->command(0x00);
// 128x296 resolution: 10
// LUT from OTP: 0
// B/W mode (doesn't work): 1
// scan-up: 1
// shift-right: 1
// booster ON: 1
// no soft reset: 1
this->data(0b10011111);
// COMMAND RESOLUTION SETTING
// set to 128x296 by COMMAND PANEL SETTING
// COMMAND VCOM AND DATA INTERVAL SETTING
// use defaults for white border and ESPHome image polarity
// EPD hardware init end
}
void HOT GDEY029T94::display() {
// COMMAND DATA START TRANSMISSION 2 (B/W only)
this->command(0x13);
delay(2);
this->start_data_();
for (size_t i = 0; i < this->get_buffer_length_(); i++) {
this->write_byte(this->buffer_[i]);
}
this->end_data_();
delay(2);
// COMMAND DISPLAY REFRESH
this->command(0x12);
delay(2);
this->wait_until_idle_();
// COMMAND POWER OFF
// NOTE: power off < deep sleep
this->command(0x02);
}
int GDEY029T94::get_width_internal() { return 128; }
int GDEY029T94::get_height_internal() { return 296; }
void GDEY029T94::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper (Good Display)", this);
ESP_LOGCONFIG(TAG, " Model: 2.9in Greyscale GDEY029T94");
LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_PIN(" DC Pin: ", this->dc_pin_);
LOG_PIN(" Busy Pin: ", this->busy_pin_);
LOG_UPDATE_INTERVAL(this);
}
static const uint8_t LUT_VCOM_DC_4_2[] = {
0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, 0x00, 0x0A, 0x01,
0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -146,6 +146,26 @@ class WaveshareEPaper2P7In : public WaveshareEPaper {
int get_height_internal() override;
};
class GDEY029T94 : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper2P9InB : public WaveshareEPaper {
public:
void initialize() override;

View file

@ -4,19 +4,19 @@
#include <esp_wifi.h>
#include <utility>
#include <algorithm>
#include <utility>
#ifdef USE_WIFI_WPA2_EAP
#include <esp_wpa2.h>
#endif
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/apps/sntp.h"
#include "lwip/dns.h"
#include "lwip/err.h"
#include "esphome/core/application.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/core/hal.h"
#include "esphome/core/application.h"
#include "esphome/core/util.h"
namespace esphome {
@ -128,13 +128,23 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
}
ip_addr_t dns;
#if LWIP_IPV6
dns.type = IPADDR_TYPE_V4;
#endif
if (uint32_t(manual_ip->dns1) != 0) {
#if LWIP_IPV6
dns.u_addr.ip4.addr = static_cast<uint32_t>(manual_ip->dns1);
#else
dns.addr = static_cast<uint32_t>(manual_ip->dns1);
#endif
dns_setserver(0, &dns);
}
if (uint32_t(manual_ip->dns2) != 0) {
#if LWIP_IPV6
dns.u_addr.ip4.addr = static_cast<uint32_t>(manual_ip->dns2);
#else
dns.addr = static_cast<uint32_t>(manual_ip->dns2);
#endif
dns_setserver(1, &dns);
}

View file

@ -451,13 +451,23 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
}
ip_addr_t dns;
#if LWIP_IPV6
dns.type = IPADDR_TYPE_V4;
#endif
if (uint32_t(manual_ip->dns1) != 0) {
#if LWIP_IPV6
dns.u_addr.ip4.addr = static_cast<uint32_t>(manual_ip->dns1);
#else
dns.addr = static_cast<uint32_t>(manual_ip->dns1);
#endif
dns_setserver(0, &dns);
}
if (uint32_t(manual_ip->dns2) != 0) {
#if LWIP_IPV6
dns.u_addr.ip4.addr = static_cast<uint32_t>(manual_ip->dns2);
#else
dns.addr = static_cast<uint32_t>(manual_ip->dns2);
#endif
dns_setserver(1, &dns);
}
@ -639,7 +649,7 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_STA_GOT_IP) {
const auto &it = data->data.ip_got_ip;
#ifdef LWIP_IPV6_AUTOCONFIG
#if LWIP_IPV6_AUTOCONFIG
tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA);
#endif
ESP_LOGV(TAG, "Event: Got IP static_ip=%s gateway=%s", format_ip4_addr(it.ip_info.ip).c_str(),
@ -912,7 +922,11 @@ network::IPAddress WiFiComponent::wifi_gateway_ip_() {
}
network::IPAddress WiFiComponent::wifi_dns_ip_(int num) {
const ip_addr_t *dns_ip = dns_getserver(num);
#if LWIP_IPV6
return {dns_ip->u_addr.ip4.addr};
#else
return {dns_ip->addr};
#endif
}
} // namespace wifi

View file

@ -211,6 +211,9 @@ RESERVED_IDS = [
"open",
"setup",
"loop",
"uart0",
"uart1",
"uart2",
]

View file

@ -409,6 +409,9 @@ class Define:
return self.as_tuple == other.as_tuple
return NotImplemented
def __str__(self):
return f"{self.name}={self.value}"
class Library:
def __init__(self, name, version, repository=None):

View file

@ -393,13 +393,13 @@ void hsv_to_rgb(int hue, float saturation, float value, float &red, float &green
}
// System APIs
#if defined(USE_ESP8266)
#if defined(USE_ESP8266) || defined(USE_RP2040)
// ESP8266 doesn't have mutexes, but that shouldn't be an issue as it's single-core and non-preemptive OS.
Mutex::Mutex() {}
void Mutex::lock() {}
bool Mutex::try_lock() { return true; }
void Mutex::unlock() {}
#elif defined(USE_ESP32) || defined(USE_RP2040)
#elif defined(USE_ESP32)
Mutex::Mutex() { handle_ = xSemaphoreCreateMutex(); }
void Mutex::lock() { xSemaphoreTake(this->handle_, portMAX_DELAY); }
bool Mutex::try_lock() { return xSemaphoreTake(this->handle_, 0) == pdTRUE; }

View file

@ -17,9 +17,6 @@
#if defined(USE_ESP32)
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#elif defined(USE_RP2040)
#include <FreeRTOS.h>
#include <semphr.h>
#endif
#define HOT __attribute__((hot))
@ -539,7 +536,7 @@ class Mutex {
Mutex &operator=(const Mutex &) = delete;
private:
#if defined(USE_ESP32) || defined(USE_RP2040)
#if defined(USE_ESP32)
SemaphoreHandle_t handle_;
#endif
};

View file

@ -47,7 +47,7 @@ FILTER_PLATFORMIO_LINES = [
r"CONFIGURATION: https://docs.platformio.org/.*",
r"DEBUG: Current.*",
r"LDF Modes:.*",
r"LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf.*",
r"LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf.*",
f"Looking for {IGNORE_LIB_WARNINGS} library in registry",
f"Warning! Library `.*'{IGNORE_LIB_WARNINGS}.*` has not been found in PlatformIO Registry.",
f"You can ignore this message, if `.*{IGNORE_LIB_WARNINGS}.*` is a built-in library.*",

View file

@ -10,7 +10,7 @@ platformio==6.1.6 # When updating platformio, also update Dockerfile
esptool==4.5.1
click==8.1.3
esphome-dashboard==20230214.0
aioesphomeapi==13.5.0
aioesphomeapi==13.5.1
zeroconf==0.47.3
# esp-idf requires this, but doesn't bundle it by default

View file

@ -17,7 +17,7 @@ def run_format(args, queue, lock, failed_files):
"""Takes filenames out of queue and runs clang-format on them."""
while True:
path = queue.get()
invocation = ["clang-format-11"]
invocation = ["clang-format-13"]
if args.inplace:
invocation.append("-i")
else:
@ -59,14 +59,14 @@ def main():
args = parser.parse_args()
try:
get_output("clang-format-11", "-version")
get_output("clang-format-13", "-version")
except:
print(
"""
Oops. It looks like clang-format is not installed.
Please check you can run "clang-format-11 -version" in your terminal and install
clang-format (v11) if necessary.
Please check you can run "clang-format-13 -version" in your terminal and install
clang-format (v13) if necessary.
Note you can also upload your code as a pull request on GitHub and see the CI check
output to apply clang-format.

View file

@ -161,13 +161,13 @@ mqtt:
id: ${roomname}_lights
relative_brightness: 5%
- uart.write:
id: uart0
id: uart_0
data: Hello World
- uart.write:
id: uart0
id: uart_0
data: [0x00, 0x20, 0x30]
- uart.write:
id: uart0
id: uart_0
data: !lambda |-
return {};
on_connect:
@ -199,7 +199,7 @@ uart:
number: GPIO23
inverted: true
baud_rate: 115200
id: uart0
id: uart_0
parity: NONE
data_bits: 8
stop_bits: 1
@ -798,7 +798,7 @@ sensor:
reference_resistance: 430 Ω
rtd_nominal_resistance: 100 Ω
- platform: mhz19
uart_id: uart0
uart_id: uart_0
co2:
name: MH-Z19 CO2 Value
temperature:
@ -938,7 +938,7 @@ sensor:
name: Pulse Width
pin: GPIO12
- platform: sm300d2
uart_id: uart0
uart_id: uart_0
co2:
name: SM300D2 CO2 Value
formaldehyde:
@ -1130,7 +1130,7 @@ sensor:
root["key"] = id(the_sensor).state;
root["greeting"] = "Hello World";
- platform: sds011
uart_id: uart0
uart_id: uart_0
pm_2_5:
name: SDS011 PM2.5
pm_10_0:
@ -2112,7 +2112,7 @@ climate:
on_state:
logger.log: State changed!
id: midea_unit
uart_id: uart0
uart_id: uart_0
name: Midea Climate
transmitter_id:
period: 1s
@ -2437,15 +2437,15 @@ switch:
id: my_switch
state: !lambda "return false;"
- platform: uart
uart_id: uart0
uart_id: uart_0
name: UART String Output
data: DataToSend
- platform: uart
uart_id: uart0
uart_id: uart_0
name: UART Bytes Output
data: [0xDE, 0xAD, 0xBE, 0xEF]
- platform: uart
uart_id: uart0
uart_id: uart_0
name: UART Recurring Output
data: [0xDE, 0xAD, 0xBE, 0xEF]
send_every: 1s
@ -2797,7 +2797,7 @@ pn532_i2c:
i2c_id: i2c_bus
rdm6300:
uart_id: uart0
uart_id: uart_0
rc522_spi:
cs_pin: GPIO23
@ -2826,7 +2826,7 @@ mcp4728:
i2c_id: i2c_bus
gps:
uart_id: uart0
uart_id: uart_0
time:
- platform: sntp
@ -3151,7 +3151,7 @@ canbus:
teleinfo:
id: myteleinfo
uart_id: uart0
uart_id: uart_0
update_interval: 60s
historical_mode: true

600
tests/test3.1.yaml Normal file
View file

@ -0,0 +1,600 @@
---
esphome:
name: $device_name
comment: $device_comment
build_path: build/test3.1
includes:
- custom.h
esp8266:
board: d1_mini
substitutions:
device_name: test3-1
device_comment: test3-1 device
min_sub: "0.03"
max_sub: "12.0%"
api:
wifi:
ssid: "MySSID"
password: "password1"
i2c:
sda: 4
scl: 5
scan: false
spi:
clk_pin: GPIO12
mosi_pin: GPIO13
miso_pin: GPIO14
ota:
logger:
sensor:
- platform: apds9960
type: proximity
name: APDS9960 Proximity
- platform: vl53l0x
name: VL53L0x Distance
address: 0x29
update_interval: 60s
enable_pin: GPIO13
timeout: 200us
- platform: apds9960
type: clear
name: APDS9960 Clear
- platform: apds9960
type: red
name: APDS9960 Red
- platform: apds9960
type: green
name: APDS9960 Green
- platform: apds9960
type: blue
name: APDS9960 Blue
- platform: aht10
temperature:
name: Temperature
humidity:
name: Humidity
- platform: am2320
temperature:
name: Temperature
humidity:
name: Humidity
- platform: adc
pin: VCC
id: my_sensor
filters:
- offset: 5.0
- multiply: 2.0
- filter_out: NAN
- sliding_window_moving_average:
- exponential_moving_average:
- quantile:
window_size: 5
send_every: 5
send_first_at: 3
quantile: .8
- lambda: "return 0;"
- delta: 100
- throttle: 100ms
- debounce: 500s
- calibrate_linear:
- 0 -> 0
- 100 -> 100
- calibrate_polynomial:
degree: 3
datapoints:
- 0 -> 0
- 100 -> 200
- 400 -> 500
- -50 -> -1000
- -100 -> -10000
- platform: cd74hc4067
id: cd74hc4067_0
number: 0
sensor: my_sensor
- platform: resistance
sensor: my_sensor
configuration: DOWNSTREAM
resistor: 10kΩ
reference_voltage: 3.3V
name: Resistance
id: resist
- platform: ntc
sensor: resist
name: NTC Sensor
calibration:
b_constant: 3950
reference_resistance: 10k
reference_temperature: 25°C
- platform: ntc
sensor: resist
name: NTC Sensor2
calibration:
- 10.0kOhm -> 25°C
- 27.219kOhm -> 0°C
- 14.674kOhm -> 15°C
- platform: ct_clamp
sensor: my_sensor
name: CT Clamp
sample_duration: 500ms
update_interval: 5s
- platform: tcs34725
red_channel:
name: Red Channel
green_channel:
name: Green Channel
blue_channel:
name: Blue Channel
clear_channel:
name: Clear Channel
illuminance:
name: Illuminance
color_temperature:
name: Color Temperature
integration_time: 614ms
gain: 60x
- platform: custom
lambda: |-
auto s = new CustomSensor();
App.register_component(s);
return {s};
sensors:
- id: custom_sensor
name: Custom Sensor
- platform: ade7953
irq_pin: GPIO16
voltage:
name: ADE7953 Voltage
id: ade7953_voltage
current_a:
name: ADE7953 Current A
id: ade7953_current_a
current_b:
name: ADE7953 Current B
id: ade7953_current_b
active_power_a:
name: ADE7953 Active Power A
id: ade7953_active_power_a
active_power_b:
name: ADE7953 Active Power B
id: ade7953_active_power_b
- platform: tmp102
name: TMP102 Temperature
- platform: hm3301
pm_1_0:
name: PM1.0
pm_2_5:
name: PM2.5
pm_10_0:
name: PM10.0
aqi:
name: AQI
calculation_type: AQI
- platform: ezo
id: ph_ezo
address: 99
unit_of_measurement: pH
- platform: tof10120
name: Distance sensor
update_interval: 5s
- platform: mlx90393
oversampling: 1
filter: 0
gain: 3X
x_axis:
name: mlxxaxis
y_axis:
name: mlxyaxis
z_axis:
name: mlxzaxis
resolution: 17BIT
temperature:
name: mlxtemp
oversampling: 2
- platform: adc128s102
id: adc128s102_channel_0
channel: 0
apds9960:
address: 0x20
update_interval: 60s
mpr121:
id: mpr121_first
address: 0x5A
binary_sensor:
- platform: apds9960
direction: up
name: APDS9960 Up
device_class: motion
filters:
- invert
- delayed_on: 20ms
- delayed_off: 20ms
- lambda: "return false;"
on_state:
- logger.log: New state
id: my_binary_sensor
- platform: apds9960
direction: down
name: APDS9960 Down
- platform: apds9960
direction: left
name: APDS9960 Left
- platform: apds9960
direction: right
name: APDS9960 Right
- platform: mpr121
id: touchkey0
channel: 0
name: touchkey0
- platform: mpr121
channel: 1
name: touchkey1
id: bin1
- platform: mpr121
channel: 2
name: touchkey2
id: bin2
- platform: mpr121
channel: 3
name: touchkey3
id: bin3
on_press:
then:
- switch.toggle: mpr121_toggle
- platform: ttp229_lsf
channel: 1
name: TTP229 LSF Test
- platform: ttp229_bsf
channel: 1
name: TTP229 BSF Test
- platform: custom
lambda: |-
auto s = new CustomBinarySensor();
App.register_component(s);
return {s};
binary_sensors:
- id: custom_binary_sensor
name: Custom Binary Sensor
- platform: template
id: cover_toggle
on_press:
then:
- cover.toggle: time_based_cover
- cover.toggle: endstop_cover
- cover.toggle: current_based_cover
globals:
- id: my_global_string
type: std::string
initial_value: '""'
text_sensor:
- platform: custom
lambda: |-
auto s = new CustomTextSensor();
App.register_component(s);
return {s};
text_sensors:
- id: custom_text_sensor
name: Custom Text Sensor
sm2135:
data_pin: GPIO12
clock_pin: GPIO14
switch:
- platform: template
name: mpr121_toggle
id: mpr121_toggle
optimistic: true
- platform: gpio
id: gpio_switch1
pin:
mcp23xxx: mcp23017_hub
number: 0
mode: OUTPUT
interlock: &interlock [gpio_switch1, gpio_switch2, gpio_switch3]
- platform: gpio
id: gpio_switch2
pin:
mcp23xxx: mcp23008_hub
number: 0
mode: OUTPUT
interlock: *interlock
- platform: gpio
id: gpio_switch3
pin: GPIO1
interlock: *interlock
- platform: custom
lambda: |-
auto s = new CustomSwitch();
return {s};
switches:
- id: custom_switch
name: Custom Switch
on_turn_on:
- http_request.get:
url: https://esphome.io
headers:
Content-Type: application/json
verify_ssl: false
- http_request.post:
url: https://esphome.io
verify_ssl: false
json:
key: !lambda |-
return id(custom_text_sensor).state;
greeting: Hello World
- http_request.send:
method: PUT
url: https://esphome.io
headers:
Content-Type: application/json
body: Some data
verify_ssl: false
custom_component:
lambda: |-
auto s = new CustomComponent();
s->set_update_interval(15000);
return {s};
stepper:
- platform: uln2003
id: my_stepper
pin_a: GPIO12
pin_b: GPIO13
pin_c: GPIO14
pin_d: GPIO15
sleep_when_done: false
step_mode: HALF_STEP
max_speed: 250 steps/s
acceleration: inf
deceleration: inf
- platform: a4988
id: my_stepper2
step_pin: GPIO1
dir_pin: GPIO2
max_speed: 0.1 steps/s
acceleration: 10 steps/s^2
deceleration: 10 steps/s^2
interval:
interval: 5s
then:
- logger.log: Interval Run
- stepper.set_target:
id: my_stepper2
target: 500
- stepper.set_target:
id: my_stepper
target: !lambda "return 0;"
- stepper.report_position:
id: my_stepper2
position: 0
- stepper.report_position:
id: my_stepper
position: !lambda "return 50/100.0;"
cover:
- platform: endstop
name: Endstop Cover
id: endstop_cover
stop_action:
- switch.turn_on: gpio_switch1
open_endstop: my_binary_sensor
open_action:
- switch.turn_on: gpio_switch1
open_duration: 5min
close_endstop: my_binary_sensor
close_action:
- switch.turn_on: gpio_switch2
- output.set_level:
id: out
level: 50%
- output.esp8266_pwm.set_frequency:
id: out
frequency: 500.0Hz
- output.esp8266_pwm.set_frequency:
id: out
frequency: !lambda "return 500.0;"
- servo.write:
id: my_servo
level: -100%
- servo.write:
id: my_servo
level: !lambda "return -1.0;"
- delay: 2s
- servo.detach: my_servo
close_duration: 4.5min
max_duration: 10min
- platform: time_based
name: Time Based Cover
id: time_based_cover
stop_action:
- switch.turn_on: gpio_switch1
open_action:
- switch.turn_on: gpio_switch1
open_duration: 5min
close_action:
- switch.turn_on: gpio_switch2
close_duration: 4.5min
- platform: current_based
name: Current Based Cover
id: current_based_cover
open_sensor: ade7953_current_a
open_moving_current_threshold: 0.5
open_obstacle_current_threshold: 0.8
open_duration: 12s
open_action:
- switch.turn_on: gpio_switch1
close_sensor: ade7953_current_b
close_moving_current_threshold: 0.5
close_obstacle_current_threshold: 0.8
close_duration: 10s
close_action:
- switch.turn_on: gpio_switch2
stop_action:
- switch.turn_off: gpio_switch1
- switch.turn_off: gpio_switch2
obstacle_rollback: 30%
start_sensing_delay: 0.8s
malfunction_detection: true
malfunction_action:
then:
- logger.log: Malfunction Detected
- platform: template
name: Template Cover with Tilt
tilt_lambda: "return 0.5;"
tilt_action:
- output.set_level:
id: out
level: !lambda "return tilt;"
position_action:
- output.set_level:
id: out
level: !lambda "return pos;"
output:
- platform: esp8266_pwm
id: out
pin: D3
frequency: 50Hz
- platform: esp8266_pwm
id: out2
pin: D4
- platform: custom
type: binary
lambda: |-
auto s = new CustomBinaryOutput();
App.register_component(s);
return {s};
outputs:
- id: custom_binary
- platform: sigma_delta_output
id: sddac
update_interval: 60s
pin: D4
turn_on_action:
then:
- logger.log: "Turned on"
turn_off_action:
then:
- logger.log: "Turned off"
state_change_action:
then:
- logger.log:
format: "Changed state: %d"
args: ["state"]
- platform: custom
type: float
lambda: |-
auto s = new CustomFloatOutput();
App.register_component(s);
return {s};
outputs:
- id: custom_float
- platform: slow_pwm
pin: GPIO5
id: my_slow_pwm
period: 15s
restart_cycle_on_state_change: false
- platform: sm2135
id: sm2135_0
channel: 0
- platform: sm2135
id: sm2135_1
channel: 1
- platform: sm2135
id: sm2135_2
channel: 2
- platform: sm2135
id: sm2135_3
channel: 3
- platform: sm2135
id: sm2135_4
channel: 4
mcp23017:
id: mcp23017_hub
mcp23008:
id: mcp23008_hub
light:
- platform: hbridge
name: Icicle Lights
pin_a: out
pin_b: out2
servo:
id: my_servo
output: out
restore: true
min_level: $min_sub
max_level: $max_sub
ttp229_lsf:
ttp229_bsf:
sdo_pin: D2
scl_pin: D1
display:
- platform: max7219digit
cs_pin: GPIO15
num_chips: 4
rotate_chip: 0
intensity: 10
scroll_mode: STOP
id: my_matrix
lambda: |-
it.printdigit("hello");
http_request:
useragent: esphome/device
timeout: 10s
button:
- platform: output
id: output_button
output: out
duration: 100ms
- platform: wake_on_lan
target_mac_address: 12:34:56:78:90:ab
name: wol_test_1
id: wol_1
- platform: factory_reset
name: Restart Button (Factory Default Settings)
cd74hc4067:
pin_s0: GPIO12
pin_s1: GPIO13
pin_s2: GPIO14
pin_s3: GPIO15
adc128s102:
cs_pin: GPIO12

View file

@ -3,8 +3,6 @@ esphome:
name: $device_name
comment: $device_comment
build_path: build/test3
platformio_options:
board_build.partitions: huge_app.csv
on_boot:
- if:
condition:
@ -13,8 +11,6 @@ esphome:
- time.has_time
then:
- logger.log: Have time
includes:
- custom.h
esp8266:
board: d1_mini
@ -23,8 +19,6 @@ esp8266:
substitutions:
device_name: test3
device_comment: test3 device
min_sub: "0.03"
max_sub: "12.0%"
api:
port: 8000
@ -52,9 +46,6 @@ api:
string_: string
then:
- logger.log: Something happened
- stepper.set_target:
id: my_stepper2
target: !lambda "return int_;"
- service: array_types
variables:
bool_arr: bool[]
@ -224,48 +215,38 @@ wifi:
ssid: "MySSID"
password: "password1"
i2c:
sda: 4
scl: 5
scan: false
spi:
clk_pin: GPIO12
mosi_pin: GPIO13
miso_pin: GPIO14
uart:
- id: uart1
- id: uart_1
tx_pin:
number: GPIO1
inverted: true
rx_pin: GPIO3
baud_rate: 115200
- id: uart2
- id: uart_2
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart3
- id: uart_3
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 4800
- id: uart4
- id: uart_4
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart5
- id: uart_5
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart6
- id: uart_6
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart7
- id: uart_7
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 38400
- id: uart8
- id: uart_8
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 4800
@ -273,28 +254,28 @@ uart:
stop_bits: 2
# Specifically added for testing debug with no options at all.
debug:
- id: uart9
- id: uart_9
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart10
- id: uart_10
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart11
- id: uart_11
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
- id: uart12
- id: uart_12
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 9600
modbus:
uart_id: uart1
uart_id: uart_1
vbus:
uart_id: uart4
uart_id: uart_4
ota:
safe_mode: true
@ -349,50 +330,21 @@ sensor:
name: Temperature 1
temperature_2:
name: Temperature 2
- platform: apds9960
type: proximity
name: APDS9960 Proximity
- platform: vl53l0x
name: VL53L0x Distance
address: 0x29
update_interval: 60s
enable_pin: GPIO13
timeout: 200us
- platform: apds9960
type: clear
name: APDS9960 Clear
- platform: apds9960
type: red
name: APDS9960 Red
- platform: apds9960
type: green
name: APDS9960 Green
- platform: apds9960
type: blue
name: APDS9960 Blue
- platform: homeassistant
entity_id: sensor.hello_world
id: ha_hello_world
- platform: aht10
temperature:
name: Temperature
humidity:
name: Humidity
- platform: am2320
temperature:
name: Temperature
humidity:
name: Humidity
- platform: hydreon_rgxx
model: RG 9
uart_id: uart6
uart_id: uart_6
id: hydreon_rg9
moisture:
name: hydreon_rain
id: hydreon_rain
- platform: hydreon_rgxx
model: RG_15
uart_id: uart6
uart_id: uart_6
acc:
name: hydreon_acc
event_acc:
@ -404,86 +356,7 @@ sensor:
- platform: adc
pin: VCC
id: my_sensor
filters:
- offset: 5.0
- multiply: 2.0
- filter_out: NAN
- sliding_window_moving_average:
- exponential_moving_average:
- quantile:
window_size: 5
send_every: 5
send_first_at: 3
quantile: .8
- lambda: "return 0;"
- delta: 100
- throttle: 100ms
- debounce: 500s
- calibrate_linear:
- 0 -> 0
- 100 -> 100
- calibrate_polynomial:
degree: 3
datapoints:
- 0 -> 0
- 100 -> 200
- 400 -> 500
- -50 -> -1000
- -100 -> -10000
- platform: cd74hc4067
id: cd74hc4067_0
number: 0
sensor: my_sensor
- platform: resistance
sensor: my_sensor
configuration: DOWNSTREAM
resistor: 10kΩ
reference_voltage: 3.3V
name: Resistance
id: resist
- platform: ntc
sensor: resist
name: NTC Sensor
calibration:
b_constant: 3950
reference_resistance: 10k
reference_temperature: 25°C
- platform: ntc
sensor: resist
name: NTC Sensor2
calibration:
- 10.0kOhm -> 25°C
- 27.219kOhm -> 0°C
- 14.674kOhm -> 15°C
- platform: ct_clamp
sensor: my_sensor
name: CT Clamp
sample_duration: 500ms
update_interval: 5s
- platform: tcs34725
red_channel:
name: Red Channel
green_channel:
name: Green Channel
blue_channel:
name: Blue Channel
clear_channel:
name: Clear Channel
illuminance:
name: Illuminance
color_temperature:
name: Color Temperature
integration_time: 614ms
gain: 60x
- platform: custom
lambda: |-
auto s = new CustomSensor();
App.register_component(s);
return {s};
sensors:
- id: custom_sensor
name: Custom Sensor
- platform: binary_sensor_map
name: Binary Sensor Map
type: group
@ -494,25 +367,9 @@ sensor:
value: 15.0
- binary_sensor: bin3
value: 100.0
- platform: ade7953
irq_pin: GPIO16
voltage:
name: ADE7953 Voltage
id: ade7953_voltage
current_a:
name: ADE7953 Current A
id: ade7953_current_a
current_b:
name: ADE7953 Current B
id: ade7953_current_b
active_power_a:
name: ADE7953 Active Power A
id: ade7953_active_power_a
active_power_b:
name: ADE7953 Active Power B
id: ade7953_active_power_b
- platform: bl0939
uart_id: uart8
uart_id: uart_8
voltage:
name: BL0939 Voltage
current_1:
@ -530,7 +387,7 @@ sensor:
energy_total:
name: BL0939 Total energy
- platform: bl0940
uart_id: uart3
uart_id: uart_3
voltage:
name: BL0940 Voltage
current:
@ -544,7 +401,7 @@ sensor:
external_temperature:
name: BL0940 External temperature
- platform: bl0942
uart_id: uart3
uart_id: uart_3
voltage:
name: BL0942 Voltage
current:
@ -556,7 +413,7 @@ sensor:
frequency:
name: BL0942 Frequency
- platform: pzem004t
uart_id: uart3
uart_id: uart_3
voltage:
name: PZEM004T Voltage
current:
@ -587,20 +444,9 @@ sensor:
name: PZEMDC Power
energy:
name: PZEMDC Energy
- platform: tmp102
name: TMP102 Temperature
- platform: hm3301
pm_1_0:
name: PM1.0
pm_2_5:
name: PM2.5
pm_10_0:
name: PM10.0
aqi:
name: AQI
calculation_type: AQI
- platform: pmsx003
uart_id: uart9
uart_id: uart_9
type: PMSX003
pm_1_0:
name: PM 1.0 Concentration
@ -628,7 +474,7 @@ sensor:
name: Particulate Count >10.0um
update_interval: 30s
- platform: pmsx003
uart_id: uart5
uart_id: uart_5
type: PMS5003T
pm_1_0:
name: PM 1.0 Concentration
@ -655,7 +501,7 @@ sensor:
humidity:
name: PMS Humidity
- platform: pmsx003
uart_id: uart6
uart_id: uart_6
type: PMS5003ST
pm_1_0:
name: PM 1.0 Concentration
@ -688,7 +534,7 @@ sensor:
formaldehyde:
name: PMS Formaldehyde Concentration
- platform: cse7761
uart_id: uart7
uart_id: uart_7
voltage:
name: CSE7761 Voltage
current_1:
@ -700,20 +546,14 @@ sensor:
active_power_2:
name: CSE7761 Active Power 2
- platform: cse7766
uart_id: uart3
uart_id: uart_3
voltage:
name: CSE7766 Voltage
current:
name: CSE7766 Current
power:
name: CSE776 Power
- platform: ezo
id: ph_ezo
address: 99
unit_of_measurement: pH
- platform: tof10120
name: Distance sensor
update_interval: 5s
- platform: fingerprint_grow
fingerprint_count:
name: Fingerprint Count
@ -796,22 +636,8 @@ sensor:
name: testwave
component_id: 2
wave_channel_id: 1
- platform: mlx90393
oversampling: 1
filter: 0
gain: 3X
x_axis:
name: mlxxaxis
y_axis:
name: mlxyaxis
z_axis:
name: mlxzaxis
resolution: 17BIT
temperature:
name: mlxtemp
oversampling: 2
- platform: smt100
uart_id: uart10
uart_id: uart_10
counts:
name: Counts
dielectric_constant:
@ -824,10 +650,6 @@ sensor:
name: Voltage
update_interval: 60s
- platform: adc128s102
id: adc128s102_channel_0
channel: 0
- platform: vbus
model: deltasol c
temperature_1:
@ -842,79 +664,19 @@ sensor:
time:
- platform: homeassistant
apds9960:
address: 0x20
update_interval: 60s
mpr121:
id: mpr121_first
address: 0x5A
binary_sensor:
- platform: daly_bms
charging_mos_enabled:
name: Charging MOS
discharging_mos_enabled:
name: Discharging MOS
- platform: apds9960
direction: up
name: APDS9960 Up
device_class: motion
filters:
- invert
- delayed_on: 20ms
- delayed_off: 20ms
- lambda: "return false;"
on_state:
- logger.log: New state
id: my_binary_sensor
- platform: apds9960
direction: down
name: APDS9960 Down
- platform: apds9960
direction: left
name: APDS9960 Left
- platform: apds9960
direction: right
name: APDS9960 Right
- platform: homeassistant
entity_id: binary_sensor.hello_world
id: ha_hello_world_binary
- platform: mpr121
id: touchkey0
channel: 0
name: touchkey0
- platform: mpr121
channel: 1
name: touchkey1
id: bin1
- platform: mpr121
channel: 2
name: touchkey2
id: bin2
- platform: mpr121
channel: 3
name: touchkey3
id: bin3
on_press:
then:
- switch.toggle: mpr121_toggle
- platform: ttp229_lsf
channel: 1
name: TTP229 LSF Test
- platform: ttp229_bsf
channel: 1
name: TTP229 BSF Test
- platform: fingerprint_grow
name: Fingerprint Enrolling
- platform: custom
lambda: |-
auto s = new CustomBinarySensor();
App.register_component(s);
return {s};
binary_sensors:
- id: custom_binary_sensor
name: Custom Binary Sensor
- platform: nextion
page_id: 0
component_id: 2
@ -923,13 +685,7 @@ binary_sensor:
id: r0_sensor
name: R0 Sensor
component_name: page0.r0
- platform: template
id: cover_toggle
on_press:
then:
- cover.toggle: time_based_cover
- cover.toggle: endstop_cover
- cover.toggle: current_based_cover
- platform: hydreon_rgxx
hydreon_rgxx_id: hydreon_rg9
too_cold:
@ -954,6 +710,16 @@ binary_sensor:
relay1:
name: Relay 1 On
- platform: gpio
id: bin1
pin: 1
- platform: gpio
id: bin2
pin: 2
- platform: gpio
id: bin3
pin: 3
globals:
- id: my_global_string
type: std::string
@ -998,14 +764,6 @@ text_sensor:
- platform: homeassistant
entity_id: sensor.hello_world2
id: ha_hello_world2
- platform: custom
lambda: |-
auto s = new CustomTextSensor();
App.register_component(s);
return {s};
text_sensors:
- id: custom_text_sensor
name: Custom Text Sensor
- platform: nextion
name: text0
id: text0
@ -1022,87 +780,22 @@ script:
then:
- lambda: 'ESP_LOGD("main", "Hello World!");'
sm2135:
data_pin: GPIO12
clock_pin: GPIO14
switch:
- platform: template
name: mpr121_toggle
id: mpr121_toggle
optimistic: true
- platform: gpio
id: gpio_switch1
pin:
mcp23xxx: mcp23017_hub
number: 0
mode: OUTPUT
interlock: &interlock [gpio_switch1, gpio_switch2, gpio_switch3]
pin: 1
- platform: gpio
id: gpio_switch2
pin:
mcp23xxx: mcp23008_hub
number: 0
mode: OUTPUT
interlock: *interlock
pin: 2
- platform: gpio
id: gpio_switch3
pin: GPIO1
interlock: *interlock
- platform: custom
lambda: |-
auto s = new CustomSwitch();
return {s};
switches:
- id: custom_switch
name: Custom Switch
pin: 3
- platform: nextion
id: r0
name: R0 Switch
component_name: page0.r0
custom_component:
lambda: |-
auto s = new CustomComponent();
s->set_update_interval(15000);
return {s};
stepper:
- platform: uln2003
id: my_stepper
pin_a: GPIO12
pin_b: GPIO13
pin_c: GPIO14
pin_d: GPIO15
sleep_when_done: false
step_mode: HALF_STEP
max_speed: 250 steps/s
acceleration: inf
deceleration: inf
- platform: a4988
id: my_stepper2
step_pin: GPIO1
dir_pin: GPIO2
max_speed: 0.1 steps/s
acceleration: 10 steps/s^2
deceleration: 10 steps/s^2
interval:
interval: 5s
then:
- logger.log: Interval Run
- stepper.set_target:
id: my_stepper2
target: 500
- stepper.set_target:
id: my_stepper
target: !lambda "return 0;"
- stepper.report_position:
id: my_stepper2
position: 0
- stepper.report_position:
id: my_stepper
position: !lambda "return 50/100.0;"
climate:
- platform: bang_bang
@ -1232,7 +925,7 @@ climate:
- horizontal
- both
update_interval: 10s
uart_id: uart12
uart_id: uart_12
sprinkler:
- id: yard_sprinkler_ctrlr
@ -1276,85 +969,6 @@ sprinkler:
run_duration: 10s
valve_switch_id: gpio_switch2
cover:
- platform: endstop
name: Endstop Cover
id: endstop_cover
stop_action:
- switch.turn_on: gpio_switch1
open_endstop: my_binary_sensor
open_action:
- switch.turn_on: gpio_switch1
open_duration: 5min
close_endstop: my_binary_sensor
close_action:
- switch.turn_on: gpio_switch2
- output.set_level:
id: out
level: 50%
- output.esp8266_pwm.set_frequency:
id: out
frequency: 500.0Hz
- output.esp8266_pwm.set_frequency:
id: out
frequency: !lambda "return 500.0;"
- servo.write:
id: my_servo
level: -100%
- servo.write:
id: my_servo
level: !lambda "return -1.0;"
- delay: 2s
- servo.detach: my_servo
close_duration: 4.5min
max_duration: 10min
- platform: time_based
name: Time Based Cover
id: time_based_cover
stop_action:
- switch.turn_on: gpio_switch1
open_action:
- switch.turn_on: gpio_switch1
open_duration: 5min
close_action:
- switch.turn_on: gpio_switch2
close_duration: 4.5min
- platform: current_based
name: Current Based Cover
id: current_based_cover
open_sensor: ade7953_current_a
open_moving_current_threshold: 0.5
open_obstacle_current_threshold: 0.8
open_duration: 12s
open_action:
- switch.turn_on: gpio_switch1
close_sensor: ade7953_current_b
close_moving_current_threshold: 0.5
close_obstacle_current_threshold: 0.8
close_duration: 10s
close_action:
- switch.turn_on: gpio_switch2
stop_action:
- switch.turn_off: gpio_switch1
- switch.turn_off: gpio_switch2
obstacle_rollback: 30%
start_sensing_delay: 0.8s
malfunction_detection: true
malfunction_action:
then:
- logger.log: Malfunction Detected
- platform: template
name: Template Cover with Tilt
tilt_lambda: "return 0.5;"
tilt_action:
- output.set_level:
id: out
level: !lambda "return tilt;"
position_action:
- output.set_level:
id: out
level: !lambda "return pos;"
output:
- platform: esp8266_pwm
id: out
@ -1363,63 +977,11 @@ output:
- platform: esp8266_pwm
id: out2
pin: D4
- platform: custom
type: binary
lambda: |-
auto s = new CustomBinaryOutput();
App.register_component(s);
return {s};
outputs:
- id: custom_binary
- platform: sigma_delta_output
id: sddac
update_interval: 60s
pin: D4
turn_on_action:
then:
- logger.log: "Turned on"
turn_off_action:
then:
- logger.log: "Turned off"
state_change_action:
then:
- logger.log:
format: "Changed state: %d"
args: ["state"]
- platform: custom
type: float
lambda: |-
auto s = new CustomFloatOutput();
App.register_component(s);
return {s};
outputs:
- id: custom_float
- platform: slow_pwm
pin: GPIO5
id: my_slow_pwm
period: 15s
restart_cycle_on_state_change: false
- platform: sm2135
id: sm2135_0
channel: 0
- platform: sm2135
id: sm2135_1
channel: 1
- platform: sm2135
id: sm2135_2
channel: 2
- platform: sm2135
id: sm2135_3
channel: 3
- platform: sm2135
id: sm2135_4
channel: 4
mcp23017:
id: mcp23017_hub
mcp23008:
id: mcp23008_hub
e131:
@ -1434,7 +996,7 @@ light:
effects:
- wled:
- adalight:
uart_id: uart3
uart_id: uart_3
- e131:
universe: 1
- platform: hbridge
@ -1442,7 +1004,7 @@ light:
pin_a: out
pin_b: out2
- platform: sonoff_d1
uart_id: uart2
uart_id: uart_2
use_rm433_remote: false
name: Sonoff D1 Dimmer
id: d1_light
@ -1457,23 +1019,10 @@ light:
name: "Shelly Dimmer Current"
max_brightness: 500
firmware: "51.6"
uart_id: uart11
servo:
id: my_servo
output: out
restore: true
min_level: $min_sub
max_level: $max_sub
ttp229_lsf:
ttp229_bsf:
sdo_pin: D2
scl_pin: D1
uart_id: uart_11
sim800l:
uart_id: uart4
uart_id: uart_4
on_sms_received:
- lambda: |-
std::string str;
@ -1486,7 +1035,7 @@ sim800l:
recipient: "+1234"
dfplayer:
uart_id: uart5
uart_id: uart_5
on_finished_playback:
then:
if:
@ -1500,7 +1049,7 @@ tm1651:
dio_pin: D5
rf_bridge:
uart_id: uart5
uart_id: uart_5
on_code_received:
- lambda: |-
uint32_t test;
@ -1530,38 +1079,11 @@ rf_bridge:
code: "ABC123"
- rf_bridge.send_raw:
raw: "AAA5070008001000ABC12355"
- http_request.get:
url: https://esphome.io
headers:
Content-Type: application/json
verify_ssl: false
- http_request.post:
url: https://esphome.io
verify_ssl: false
json:
key: !lambda |-
return id(version_sensor).state;
greeting: Hello World
- http_request.send:
method: PUT
url: https://esphome.io
headers:
Content-Type: application/json
body: Some data
verify_ssl: false
display:
- platform: max7219digit
cs_pin: GPIO15
num_chips: 4
rotate_chip: 0
intensity: 10
scroll_mode: STOP
id: my_matrix
lambda: |-
it.printdigit("hello");
- platform: nextion
uart_id: uart1
uart_id: uart_1
tft_url: http://esphome.io/default35.tft
update_interval: 5s
on_sleep:
@ -1577,10 +1099,6 @@ display:
then:
lambda: 'ESP_LOGD("display","Display shows new page %u", x);'
http_request:
useragent: esphome/device
timeout: 10s
fingerprint_grow:
sensing_pin: 4
password: 0x12FE37DC
@ -1610,11 +1128,11 @@ fingerprint_grow:
event: esphome.${device_name}_fingerprint_grow_enrollment_failed
data:
finger_id: !lambda "return finger_id;"
uart_id: uart6
uart_id: uart_6
dsmr:
decryption_key: 00112233445566778899aabbccddeeff
uart_id: uart6
uart_id: uart_6
max_telegram_length: 1000
request_pin: D5
request_interval: 20s
@ -1622,29 +1140,8 @@ dsmr:
daly_bms:
update_interval: 20s
uart_id: uart1
uart_id: uart_1
qr_code:
- id: homepage_qr
value: https://esphome.io/index.html
button:
- platform: output
id: output_button
output: out
duration: 100ms
- platform: wake_on_lan
target_mac_address: 12:34:56:78:90:ab
name: wol_test_1
id: wol_1
- platform: factory_reset
name: Restart Button (Factory Default Settings)
cd74hc4067:
pin_s0: GPIO12
pin_s1: GPIO13
pin_s2: GPIO14
pin_s3: GPIO15
adc128s102:
cs_pin: GPIO12

View file

@ -29,11 +29,11 @@ ota:
logger:
uart:
- id: uart1
- id: uart_1
tx_pin: 1
rx_pin: 3
baud_rate: 9600
- id: uart2
- id: uart_2
tx_pin: 17
rx_pin: 16
baud_rate: 19200
@ -42,7 +42,7 @@ i2c:
frequency: 100khz
modbus:
uart_id: uart1
uart_id: uart_1
flow_control_pin: 5
id: mod_bus1
@ -67,7 +67,7 @@ mqtt:
# yamllint enable rule:line-length
vbus:
- uart_id: uart2
- uart_id: uart_2
binary_sensor:
- platform: gpio
@ -422,7 +422,7 @@ sensor:
value_type: U_WORD
- platform: t6615
uart_id: uart2
uart_id: uart_2
co2:
name: CO2 Sensor