mirror of
https://github.com/esphome/esphome.git
synced 2025-11-10 20:05:48 +00:00
Compare commits
45 Commits
2023.8.1
...
remove-uni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fd8676151 | ||
|
|
f614655af5 | ||
|
|
cdb67fc90e | ||
|
|
78cb098691 | ||
|
|
45152ad55e | ||
|
|
45879e3100 | ||
|
|
c4adb30ab2 | ||
|
|
b20bae23cc | ||
|
|
11ed2d5f18 | ||
|
|
f814b6d47c | ||
|
|
2a48b810a4 | ||
|
|
0443310385 | ||
|
|
03ab23fec8 | ||
|
|
da8afd36b2 | ||
|
|
fe7893d1b3 | ||
|
|
d19bf5d6ee | ||
|
|
bfdcfa4766 | ||
|
|
c47c1a7867 | ||
|
|
f16a24ddf4 | ||
|
|
c287e529a8 | ||
|
|
164d05fdce | ||
|
|
c11c4dad2f | ||
|
|
0af8d0b7ea | ||
|
|
2b4ed0c273 | ||
|
|
9fc50e8dbc | ||
|
|
c5be5e6d12 | ||
|
|
63fc16d872 | ||
|
|
5f99ed943a | ||
|
|
5cb5594288 | ||
|
|
87629191b3 | ||
|
|
4a518e3e7a | ||
|
|
6089526975 | ||
|
|
b9e9223fdd | ||
|
|
e963eedb64 | ||
|
|
3b2c61e813 | ||
|
|
2dd4aa7bf6 | ||
|
|
4c1af007ca | ||
|
|
08013be6dd | ||
|
|
0daf4545a9 | ||
|
|
1269bf9791 | ||
|
|
5cb21324a1 | ||
|
|
3eef80506b | ||
|
|
283d9a0f5f | ||
|
|
a84365659b | ||
|
|
db9dc11022 |
@@ -54,7 +54,7 @@ esphome/components/bp1658cj/* @Cossid
|
||||
esphome/components/bp5758d/* @Cossid
|
||||
esphome/components/button/* @esphome/core
|
||||
esphome/components/canbus/* @danielschramm @mvturnho
|
||||
esphome/components/cap1188/* @MrEditor97
|
||||
esphome/components/cap1188/* @mreditor97
|
||||
esphome/components/captive_portal/* @OttoWinter
|
||||
esphome/components/ccs811/* @habbie
|
||||
esphome/components/cd74hc4067/* @asoehlke
|
||||
@@ -87,7 +87,7 @@ esphome/components/ens210/* @itn3rd77
|
||||
esphome/components/esp32/* @esphome/core
|
||||
esphome/components/esp32_ble/* @jesserockz
|
||||
esphome/components/esp32_ble_client/* @jesserockz
|
||||
esphome/components/esp32_ble_server/* @jesserockz
|
||||
esphome/components/esp32_ble_server/* @clydebarrow @jesserockz
|
||||
esphome/components/esp32_camera_web_server/* @ayufan
|
||||
esphome/components/esp32_can/* @Sympatron
|
||||
esphome/components/esp32_improv/* @jesserockz
|
||||
@@ -132,7 +132,7 @@ esphome/components/i2s_audio/speaker/* @jesserockz
|
||||
esphome/components/ili9xxx/* @nielsnl68
|
||||
esphome/components/improv_base/* @esphome/core
|
||||
esphome/components/improv_serial/* @esphome/core
|
||||
esphome/components/ina260/* @MrEditor97
|
||||
esphome/components/ina260/* @mreditor97
|
||||
esphome/components/inkbird_ibsth1_mini/* @fkirill
|
||||
esphome/components/inkplate6/* @jesserockz
|
||||
esphome/components/integration/* @OttoWinter
|
||||
@@ -168,7 +168,7 @@ esphome/components/mcp2515/* @danielschramm @mvturnho
|
||||
esphome/components/mcp3204/* @rsumner
|
||||
esphome/components/mcp4728/* @berfenger
|
||||
esphome/components/mcp47a1/* @jesserockz
|
||||
esphome/components/mcp9600/* @MrEditor97
|
||||
esphome/components/mcp9600/* @mreditor97
|
||||
esphome/components/mcp9808/* @k7hpn
|
||||
esphome/components/md5/* @esphome/core
|
||||
esphome/components/mdns/* @esphome/core
|
||||
@@ -212,6 +212,7 @@ esphome/components/pid/* @OttoWinter
|
||||
esphome/components/pipsolar/* @andreashergert1984
|
||||
esphome/components/pm1006/* @habbie
|
||||
esphome/components/pmsa003i/* @sjtrny
|
||||
esphome/components/pmwcs3/* @SeByDocKy
|
||||
esphome/components/pn532/* @OttoWinter @jesserockz
|
||||
esphome/components/pn532_i2c/* @OttoWinter @jesserockz
|
||||
esphome/components/pn532_spi/* @OttoWinter @jesserockz
|
||||
|
||||
@@ -28,14 +28,14 @@ RUN \
|
||||
git=1:2.30.2-1+deb11u2 \
|
||||
curl=7.74.0-1.3+deb11u7 \
|
||||
openssh-client=1:8.4p1-5+deb11u1 \
|
||||
python3-cffi=1.14.5-1; \
|
||||
python3-cffi=1.14.5-1 \
|
||||
libcairo2=1.16.0-5; \
|
||||
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential=12.9 \
|
||||
python3-dev=3.9.2-3 \
|
||||
zlib1g-dev=1:1.2.11.dfsg-2+deb11u2 \
|
||||
libjpeg-dev=1:2.0.6-4 \
|
||||
libcairo2=1.16.0-5 \
|
||||
libfreetype-dev=2.10.4+dfsg-1+deb11u1; \
|
||||
fi; \
|
||||
rm -rf \
|
||||
@@ -61,7 +61,7 @@ RUN \
|
||||
# Ubuntu python3-pip is missing wheel
|
||||
pip3 install --no-cache-dir \
|
||||
wheel==0.37.1 \
|
||||
platformio==6.1.7 \
|
||||
platformio==6.1.10 \
|
||||
# Change some platformio settings
|
||||
&& platformio settings set enable_telemetry No \
|
||||
&& platformio settings set check_platformio_interval 1000000 \
|
||||
|
||||
@@ -7,7 +7,9 @@ from esphome.core import CORE
|
||||
from esphome.components.esp32 import get_esp32_variant
|
||||
from esphome.components.esp32.const import (
|
||||
VARIANT_ESP32,
|
||||
VARIANT_ESP32C2,
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_ESP32C6,
|
||||
VARIANT_ESP32H2,
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32S3,
|
||||
@@ -70,6 +72,22 @@ ESP32_VARIANT_ADC1_PIN_TO_CHANNEL = {
|
||||
3: adc1_channel_t.ADC1_CHANNEL_3,
|
||||
4: adc1_channel_t.ADC1_CHANNEL_4,
|
||||
},
|
||||
VARIANT_ESP32C2: {
|
||||
0: adc1_channel_t.ADC1_CHANNEL_0,
|
||||
1: adc1_channel_t.ADC1_CHANNEL_1,
|
||||
2: adc1_channel_t.ADC1_CHANNEL_2,
|
||||
3: adc1_channel_t.ADC1_CHANNEL_3,
|
||||
4: adc1_channel_t.ADC1_CHANNEL_4,
|
||||
},
|
||||
VARIANT_ESP32C6: {
|
||||
0: adc1_channel_t.ADC1_CHANNEL_0,
|
||||
1: adc1_channel_t.ADC1_CHANNEL_1,
|
||||
2: adc1_channel_t.ADC1_CHANNEL_2,
|
||||
3: adc1_channel_t.ADC1_CHANNEL_3,
|
||||
4: adc1_channel_t.ADC1_CHANNEL_4,
|
||||
5: adc1_channel_t.ADC1_CHANNEL_5,
|
||||
6: adc1_channel_t.ADC1_CHANNEL_6,
|
||||
},
|
||||
VARIANT_ESP32H2: {
|
||||
0: adc1_channel_t.ADC1_CHANNEL_0,
|
||||
1: adc1_channel_t.ADC1_CHANNEL_1,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "adc_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#ifdef USE_ESP8266
|
||||
#ifdef USE_ADC_SENSOR_VCC
|
||||
@@ -254,9 +254,5 @@ float ADCSensor::sample() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_ESP8266
|
||||
std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; }
|
||||
#endif
|
||||
|
||||
} // namespace adc
|
||||
} // namespace esphome
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/voltage_sampler/voltage_sampler.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/hal.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
#include "driver/adc.h"
|
||||
#include <esp_adc_cal.h>
|
||||
#include "driver/adc.h"
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
@@ -41,10 +41,6 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
|
||||
void set_output_raw(bool output_raw) { output_raw_ = output_raw; }
|
||||
float sample() override;
|
||||
|
||||
#ifdef USE_ESP8266
|
||||
std::string unique_id() override;
|
||||
#endif
|
||||
|
||||
#ifdef USE_RP2040
|
||||
void set_is_temperature() { is_temperature_ = true; }
|
||||
#endif
|
||||
|
||||
@@ -161,7 +161,7 @@ void APIConnection::loop() {
|
||||
}
|
||||
|
||||
std::string get_default_unique_id(const std::string &component_type, EntityBase *entity) {
|
||||
return App.get_name() + component_type + entity->get_object_id();
|
||||
return get_mac_address_pretty() + "-" + component_type + "-" + entity->get_object_id();
|
||||
}
|
||||
|
||||
DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
|
||||
@@ -437,9 +437,7 @@ bool APIConnection::send_sensor_info(sensor::Sensor *sensor) {
|
||||
msg.object_id = sensor->get_object_id();
|
||||
if (sensor->has_own_name())
|
||||
msg.name = sensor->get_name();
|
||||
msg.unique_id = sensor->unique_id();
|
||||
if (msg.unique_id.empty())
|
||||
msg.unique_id = get_default_unique_id("sensor", sensor);
|
||||
msg.unique_id = get_default_unique_id("sensor", sensor);
|
||||
msg.icon = sensor->get_icon();
|
||||
msg.unit_of_measurement = sensor->get_unit_of_measurement();
|
||||
msg.accuracy_decimals = sensor->get_accuracy_decimals();
|
||||
@@ -505,9 +503,7 @@ bool APIConnection::send_text_sensor_info(text_sensor::TextSensor *text_sensor)
|
||||
msg.key = text_sensor->get_object_id_hash();
|
||||
msg.object_id = text_sensor->get_object_id();
|
||||
msg.name = text_sensor->get_name();
|
||||
msg.unique_id = text_sensor->unique_id();
|
||||
if (msg.unique_id.empty())
|
||||
msg.unique_id = get_default_unique_id("text_sensor", text_sensor);
|
||||
msg.unique_id = get_default_unique_id("text_sensor", text_sensor);
|
||||
msg.icon = text_sensor->get_icon();
|
||||
msg.disabled_by_default = text_sensor->is_disabled_by_default();
|
||||
msg.entity_category = static_cast<enums::EntityCategory>(text_sensor->get_entity_category());
|
||||
|
||||
@@ -9,7 +9,7 @@ CONF_ALLOW_MULTIPLE_TOUCHES = "allow_multiple_touches"
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
AUTO_LOAD = ["binary_sensor", "output"]
|
||||
CODEOWNERS = ["@MrEditor97"]
|
||||
CODEOWNERS = ["@mreditor97"]
|
||||
|
||||
cap1188_ns = cg.esphome_ns.namespace("cap1188")
|
||||
CONF_CAP1188_ID = "cap1188_id"
|
||||
|
||||
@@ -38,7 +38,7 @@ void CurrentBasedCover::control(const CoverCall &call) {
|
||||
}
|
||||
if (call.get_position().has_value()) {
|
||||
auto pos = *call.get_position();
|
||||
if (pos == this->position) {
|
||||
if (fabsf(this->position - pos) < 0.01) {
|
||||
// already at target
|
||||
} else {
|
||||
auto op = pos < this->position ? COVER_OPERATION_CLOSING : COVER_OPERATION_OPENING;
|
||||
|
||||
@@ -273,7 +273,6 @@ float DallasTemperatureSensor::get_temp_c() {
|
||||
|
||||
return temp / 128.0f;
|
||||
}
|
||||
std::string DallasTemperatureSensor::unique_id() { return "dallas-" + str_lower_case(format_hex(this->address_)); }
|
||||
|
||||
} // namespace dallas
|
||||
} // namespace esphome
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esp_one_wire.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -60,8 +60,6 @@ class DallasTemperatureSensor : public sensor::Sensor {
|
||||
|
||||
float get_temp_c();
|
||||
|
||||
std::string unique_id() override;
|
||||
|
||||
protected:
|
||||
DallasComponent *parent_;
|
||||
uint64_t address_;
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
#include <esp_heap_caps.h>
|
||||
#include <esp_system.h>
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
#include <esp32/rom/rtc.h>
|
||||
#include <esp_chip_info.h>
|
||||
#else
|
||||
#include <rom/rtc.h>
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
#include <esp32/rom/rtc.h>
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3)
|
||||
#include <esp32c3/rom/rtc.h>
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32S2)
|
||||
#include <esp32s2/rom/rtc.h>
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#include <esp32s3/rom/rtc.h>
|
||||
#endif
|
||||
|
||||
#endif // USE_ESP32
|
||||
@@ -109,13 +113,19 @@ void DebugComponent::dump_config() {
|
||||
esp_chip_info_t info;
|
||||
esp_chip_info(&info);
|
||||
const char *model;
|
||||
switch (info.model) {
|
||||
case CHIP_ESP32:
|
||||
model = "ESP32";
|
||||
break;
|
||||
default:
|
||||
model = "UNKNOWN";
|
||||
}
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
model = "ESP32";
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3)
|
||||
model = "ESP32-C3";
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32S2)
|
||||
model = "ESP32-S2";
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
model = "ESP32-S3";
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32H2)
|
||||
model = "ESP32-H2";
|
||||
#else
|
||||
model = "UNKNOWN";
|
||||
#endif
|
||||
std::string features;
|
||||
if (info.features & CHIP_FEATURE_EMB_FLASH) {
|
||||
features += "EMB_FLASH,";
|
||||
@@ -157,18 +167,26 @@ void DebugComponent::dump_config() {
|
||||
case POWERON_RESET:
|
||||
reset_reason = "Power On Reset";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case SW_RESET:
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case RTC_SW_SYS_RESET:
|
||||
#endif
|
||||
reset_reason = "Software Reset Digital Core";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case OWDT_RESET:
|
||||
reset_reason = "Watch Dog Reset Digital Core";
|
||||
break;
|
||||
#endif
|
||||
case DEEPSLEEP_RESET:
|
||||
reset_reason = "Deep Sleep Reset Digital Core";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case SDIO_RESET:
|
||||
reset_reason = "SLC Module Reset Digital Core";
|
||||
break;
|
||||
#endif
|
||||
case TG0WDT_SYS_RESET:
|
||||
reset_reason = "Timer Group 0 Watch Dog Reset Digital Core";
|
||||
break;
|
||||
@@ -181,24 +199,61 @@ void DebugComponent::dump_config() {
|
||||
case INTRUSION_RESET:
|
||||
reset_reason = "Intrusion Reset CPU";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case TGWDT_CPU_RESET:
|
||||
reset_reason = "Timer Group Reset CPU";
|
||||
break;
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case TG0WDT_CPU_RESET:
|
||||
reset_reason = "Timer Group 0 Reset CPU";
|
||||
break;
|
||||
#endif
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case SW_CPU_RESET:
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case RTC_SW_CPU_RESET:
|
||||
#endif
|
||||
reset_reason = "Software Reset CPU";
|
||||
break;
|
||||
case RTCWDT_CPU_RESET:
|
||||
reset_reason = "RTC Watch Dog Reset CPU";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32)
|
||||
case EXT_CPU_RESET:
|
||||
reset_reason = "External CPU Reset";
|
||||
break;
|
||||
#endif
|
||||
case RTCWDT_BROWN_OUT_RESET:
|
||||
reset_reason = "Voltage Unstable Reset";
|
||||
break;
|
||||
case RTCWDT_RTC_RESET:
|
||||
reset_reason = "RTC Watch Dog Reset Digital Core And RTC Module";
|
||||
break;
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case TG1WDT_CPU_RESET:
|
||||
reset_reason = "Timer Group 1 Reset CPU";
|
||||
break;
|
||||
case SUPER_WDT_RESET:
|
||||
reset_reason = "Super Watchdog Reset Digital Core And RTC Module";
|
||||
break;
|
||||
case GLITCH_RTC_RESET:
|
||||
reset_reason = "Glitch Reset Digital Core And RTC Module";
|
||||
break;
|
||||
case EFUSE_RESET:
|
||||
reset_reason = "eFuse Reset Digital Core";
|
||||
break;
|
||||
#endif
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case USB_UART_CHIP_RESET:
|
||||
reset_reason = "USB UART Reset Digital Core";
|
||||
break;
|
||||
case USB_JTAG_CHIP_RESET:
|
||||
reset_reason = "USB JTAG Reset Digital Core";
|
||||
break;
|
||||
case POWER_GLITCH_RESET:
|
||||
reset_reason = "Power Glitch Reset Digital Core And RTC Module";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
reset_reason = "Unknown Reset Reason";
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ from esphome.components.esp32.const import (
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32S3,
|
||||
VARIANT_ESP32C2,
|
||||
VARIANT_ESP32C6,
|
||||
)
|
||||
|
||||
WAKEUP_PINS = {
|
||||
@@ -94,6 +96,8 @@ WAKEUP_PINS = {
|
||||
20,
|
||||
21,
|
||||
],
|
||||
VARIANT_ESP32C2: [0, 1, 2, 3, 4, 5],
|
||||
VARIANT_ESP32C6: [0, 1, 2, 3, 4, 5, 6, 7],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ from .const import ( # noqa
|
||||
KEY_SDKCONFIG_OPTIONS,
|
||||
KEY_SUBMODULES,
|
||||
KEY_VARIANT,
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_FRIENDLY,
|
||||
VARIANTS,
|
||||
)
|
||||
|
||||
@@ -14,13 +14,17 @@ KEY_SUBMODULES = "submodules"
|
||||
VARIANT_ESP32 = "ESP32"
|
||||
VARIANT_ESP32S2 = "ESP32S2"
|
||||
VARIANT_ESP32S3 = "ESP32S3"
|
||||
VARIANT_ESP32C2 = "ESP32C2"
|
||||
VARIANT_ESP32C3 = "ESP32C3"
|
||||
VARIANT_ESP32C6 = "ESP32C6"
|
||||
VARIANT_ESP32H2 = "ESP32H2"
|
||||
VARIANTS = [
|
||||
VARIANT_ESP32,
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32S3,
|
||||
VARIANT_ESP32C2,
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_ESP32C6,
|
||||
VARIANT_ESP32H2,
|
||||
]
|
||||
|
||||
@@ -28,7 +32,9 @@ VARIANT_FRIENDLY = {
|
||||
VARIANT_ESP32: "ESP32",
|
||||
VARIANT_ESP32S2: "ESP32-S2",
|
||||
VARIANT_ESP32S3: "ESP32-S3",
|
||||
VARIANT_ESP32C2: "ESP32-C2",
|
||||
VARIANT_ESP32C3: "ESP32-C3",
|
||||
VARIANT_ESP32C6: "ESP32-C6",
|
||||
VARIANT_ESP32H2: "ESP32-H2",
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
#include <esp_timer.h>
|
||||
#include <soc/rtc.h>
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
#include <hal/cpu_hal.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_ARDUINO
|
||||
#include <esp32-hal.h>
|
||||
@@ -55,15 +53,7 @@ void arch_init() {
|
||||
void IRAM_ATTR HOT arch_feed_wdt() { esp_task_wdt_reset(); }
|
||||
|
||||
uint8_t progmem_read_byte(const uint8_t *addr) { return *addr; }
|
||||
uint32_t arch_get_cpu_cycle_count() {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
return cpu_hal_get_cycle_count();
|
||||
#else
|
||||
uint32_t ccount;
|
||||
__asm__ __volatile__("esync; rsr %0,ccount" : "=a"(ccount));
|
||||
return ccount;
|
||||
#endif
|
||||
}
|
||||
uint32_t arch_get_cpu_cycle_count() { return cpu_hal_get_cycle_count(); }
|
||||
uint32_t arch_get_cpu_freq_hz() { return rtc_clk_apb_freq_get(); }
|
||||
|
||||
#ifdef USE_ESP_IDF
|
||||
|
||||
@@ -26,6 +26,8 @@ from .const import (
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32S3,
|
||||
VARIANT_ESP32C2,
|
||||
VARIANT_ESP32C6,
|
||||
VARIANT_ESP32H2,
|
||||
esp32_ns,
|
||||
)
|
||||
@@ -35,6 +37,8 @@ from .gpio_esp32 import esp32_validate_gpio_pin, esp32_validate_supports
|
||||
from .gpio_esp32_s2 import esp32_s2_validate_gpio_pin, esp32_s2_validate_supports
|
||||
from .gpio_esp32_c3 import esp32_c3_validate_gpio_pin, esp32_c3_validate_supports
|
||||
from .gpio_esp32_s3 import esp32_s3_validate_gpio_pin, esp32_s3_validate_supports
|
||||
from .gpio_esp32_c2 import esp32_c2_validate_gpio_pin, esp32_c2_validate_supports
|
||||
from .gpio_esp32_c6 import esp32_c6_validate_gpio_pin, esp32_c6_validate_supports
|
||||
from .gpio_esp32_h2 import esp32_h2_validate_gpio_pin, esp32_h2_validate_supports
|
||||
|
||||
|
||||
@@ -95,6 +99,14 @@ _esp32_validations = {
|
||||
pin_validation=esp32_s3_validate_gpio_pin,
|
||||
usage_validation=esp32_s3_validate_supports,
|
||||
),
|
||||
VARIANT_ESP32C2: ESP32ValidationFunctions(
|
||||
pin_validation=esp32_c2_validate_gpio_pin,
|
||||
usage_validation=esp32_c2_validate_supports,
|
||||
),
|
||||
VARIANT_ESP32C6: ESP32ValidationFunctions(
|
||||
pin_validation=esp32_c6_validate_gpio_pin,
|
||||
usage_validation=esp32_c6_validate_supports,
|
||||
),
|
||||
VARIANT_ESP32H2: ESP32ValidationFunctions(
|
||||
pin_validation=esp32_h2_validate_gpio_pin,
|
||||
usage_validation=esp32_h2_validate_supports,
|
||||
|
||||
37
esphome/components/esp32/gpio_esp32_c2.py
Normal file
37
esphome/components/esp32/gpio_esp32_c2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import logging
|
||||
|
||||
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
||||
|
||||
import esphome.config_validation as cv
|
||||
|
||||
_ESP32C2_STRAPPING_PINS = {8, 9}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def esp32_c2_validate_gpio_pin(value):
|
||||
if value < 0 or value > 20:
|
||||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-20)")
|
||||
if value in _ESP32C2_STRAPPING_PINS:
|
||||
_LOGGER.warning(
|
||||
"GPIO%d is a Strapping PIN and should be avoided.\n"
|
||||
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n"
|
||||
"See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins",
|
||||
value,
|
||||
)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def esp32_c2_validate_supports(value):
|
||||
num = value[CONF_NUMBER]
|
||||
mode = value[CONF_MODE]
|
||||
is_input = mode[CONF_INPUT]
|
||||
|
||||
if num < 0 or num > 20:
|
||||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-20)")
|
||||
|
||||
if is_input:
|
||||
# All ESP32 pins support input mode
|
||||
pass
|
||||
return value
|
||||
50
esphome/components/esp32/gpio_esp32_c6.py
Normal file
50
esphome/components/esp32/gpio_esp32_c6.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import logging
|
||||
|
||||
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
||||
|
||||
import esphome.config_validation as cv
|
||||
|
||||
_ESP32C6_SPI_PSRAM_PINS = {
|
||||
24: "SPICS0",
|
||||
25: "SPIQ",
|
||||
26: "SPIWP",
|
||||
27: "VDD_SPI",
|
||||
28: "SPIHD",
|
||||
29: "SPICLK",
|
||||
30: "SPID",
|
||||
}
|
||||
|
||||
_ESP32C6_STRAPPING_PINS = {8, 9, 15}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def esp32_c6_validate_gpio_pin(value):
|
||||
if value < 0 or value > 23:
|
||||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-23)")
|
||||
if value in _ESP32C6_SPI_PSRAM_PINS:
|
||||
raise cv.Invalid(
|
||||
f"This pin cannot be used on ESP32-C6s and is already used by the SPI/PSRAM interface (function: {_ESP32C6_SPI_PSRAM_PINS[value]})"
|
||||
)
|
||||
if value in _ESP32C6_STRAPPING_PINS:
|
||||
_LOGGER.warning(
|
||||
"GPIO%d is a Strapping PIN and should be avoided.\n"
|
||||
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n"
|
||||
"See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins",
|
||||
value,
|
||||
)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def esp32_c6_validate_supports(value):
|
||||
num = value[CONF_NUMBER]
|
||||
mode = value[CONF_MODE]
|
||||
is_input = mode[CONF_INPUT]
|
||||
|
||||
if num < 0 or num > 23:
|
||||
raise cv.Invalid(f"Invalid pin number: {value} (must be 0-23)")
|
||||
if is_input:
|
||||
# All ESP32 pins support input mode
|
||||
pass
|
||||
return value
|
||||
@@ -42,9 +42,15 @@ void BLEAdvertising::remove_service_uuid(ESPBTUUID uuid) {
|
||||
this->advertising_uuids_.end());
|
||||
}
|
||||
|
||||
void BLEAdvertising::set_manufacturer_data(uint8_t *data, uint16_t size) {
|
||||
this->advertising_data_.p_manufacturer_data = data;
|
||||
this->advertising_data_.manufacturer_len = size;
|
||||
void BLEAdvertising::set_manufacturer_data(const std::vector<uint8_t> &data) {
|
||||
delete[] this->advertising_data_.p_manufacturer_data;
|
||||
this->advertising_data_.p_manufacturer_data = nullptr;
|
||||
this->advertising_data_.manufacturer_len = data.size();
|
||||
if (!data.empty()) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
this->advertising_data_.p_manufacturer_data = new uint8_t[data.size()];
|
||||
memcpy(this->advertising_data_.p_manufacturer_data, data.data(), data.size());
|
||||
}
|
||||
}
|
||||
|
||||
void BLEAdvertising::start() {
|
||||
@@ -74,16 +80,21 @@ void BLEAdvertising::start() {
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(&this->scan_response_data_, &this->advertising_data_, sizeof(esp_ble_adv_data_t));
|
||||
this->scan_response_data_.set_scan_rsp = true;
|
||||
this->scan_response_data_.include_name = true;
|
||||
this->scan_response_data_.include_txpower = true;
|
||||
this->scan_response_data_.appearance = 0;
|
||||
this->scan_response_data_.flag = 0;
|
||||
err = esp_ble_gap_config_adv_data(&this->scan_response_data_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Scan response): %d", err);
|
||||
return;
|
||||
if (this->scan_response_) {
|
||||
memcpy(&this->scan_response_data_, &this->advertising_data_, sizeof(esp_ble_adv_data_t));
|
||||
this->scan_response_data_.set_scan_rsp = true;
|
||||
this->scan_response_data_.include_name = true;
|
||||
this->scan_response_data_.include_txpower = true;
|
||||
this->scan_response_data_.min_interval = 0;
|
||||
this->scan_response_data_.max_interval = 0;
|
||||
this->scan_response_data_.manufacturer_len = 0;
|
||||
this->scan_response_data_.appearance = 0;
|
||||
this->scan_response_data_.flag = 0;
|
||||
err = esp_ble_gap_config_adv_data(&this->scan_response_data_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Scan response): %d", err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->advertising_data_.service_uuid_len > 0) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class BLEAdvertising {
|
||||
void remove_service_uuid(ESPBTUUID uuid);
|
||||
void set_scan_response(bool scan_response) { this->scan_response_ = scan_response; }
|
||||
void set_min_preferred_interval(uint16_t interval) { this->advertising_data_.min_interval = interval; }
|
||||
void set_manufacturer_data(uint8_t *data, uint16_t size);
|
||||
void set_manufacturer_data(const std::vector<uint8_t> &data);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
@@ -6,11 +6,12 @@ from esphome.core import CORE
|
||||
from esphome.components.esp32 import add_idf_sdkconfig_option
|
||||
|
||||
AUTO_LOAD = ["esp32_ble"]
|
||||
CODEOWNERS = ["@jesserockz"]
|
||||
CODEOWNERS = ["@jesserockz", "@clydebarrow"]
|
||||
CONFLICTS_WITH = ["esp32_ble_beacon"]
|
||||
DEPENDENCIES = ["esp32"]
|
||||
|
||||
CONF_MANUFACTURER = "manufacturer"
|
||||
CONF_MANUFACTURER_DATA = "manufacturer_data"
|
||||
|
||||
esp32_ble_server_ns = cg.esphome_ns.namespace("esp32_ble_server")
|
||||
BLEServer = esp32_ble_server_ns.class_(
|
||||
@@ -27,6 +28,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
cv.GenerateID(): cv.declare_id(BLEServer),
|
||||
cv.GenerateID(esp32_ble.CONF_BLE_ID): cv.use_id(esp32_ble.ESP32BLE),
|
||||
cv.Optional(CONF_MANUFACTURER, default="ESPHome"): cv.string,
|
||||
cv.Optional(CONF_MANUFACTURER_DATA): cv.Schema([cv.hex_uint8_t]),
|
||||
cv.Optional(CONF_MODEL): cv.string,
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
@@ -42,6 +44,8 @@ async def to_code(config):
|
||||
cg.add(var.set_parent(parent))
|
||||
|
||||
cg.add(var.set_manufacturer(config[CONF_MANUFACTURER]))
|
||||
if CONF_MANUFACTURER_DATA in config:
|
||||
cg.add(var.set_manufacturer_data(config[CONF_MANUFACTURER_DATA]))
|
||||
if CONF_MODEL in config:
|
||||
cg.add(var.set_model(config[CONF_MODEL]))
|
||||
cg.add_define("USE_ESP32_BLE_SERVER")
|
||||
|
||||
@@ -68,6 +68,7 @@ void BLEServer::loop() {
|
||||
if (this->device_information_service_->is_running()) {
|
||||
this->state_ = RUNNING;
|
||||
this->can_proceed_ = true;
|
||||
this->restart_advertising_();
|
||||
ESP_LOGD(TAG, "BLE server setup successfully");
|
||||
} else if (!this->device_information_service_->is_starting()) {
|
||||
this->device_information_service_->start();
|
||||
@@ -77,6 +78,13 @@ void BLEServer::loop() {
|
||||
}
|
||||
}
|
||||
|
||||
void BLEServer::restart_advertising_() {
|
||||
if (this->state_ == RUNNING) {
|
||||
esp32_ble::global_ble->get_advertising()->set_manufacturer_data(this->manufacturer_data_);
|
||||
esp32_ble::global_ble->get_advertising()->start();
|
||||
}
|
||||
}
|
||||
|
||||
bool BLEServer::create_device_characteristics_() {
|
||||
if (this->model_.has_value()) {
|
||||
BLECharacteristic *model =
|
||||
|
||||
@@ -45,6 +45,10 @@ class BLEServer : public Component, public GATTsEventHandler, public Parented<ES
|
||||
|
||||
void set_manufacturer(const std::string &manufacturer) { this->manufacturer_ = manufacturer; }
|
||||
void set_model(const std::string &model) { this->model_ = model; }
|
||||
void set_manufacturer_data(const std::vector<uint8_t> &data) {
|
||||
this->manufacturer_data_ = data;
|
||||
this->restart_advertising_();
|
||||
}
|
||||
|
||||
std::shared_ptr<BLEService> create_service(const uint8_t *uuid, bool advertise = false);
|
||||
std::shared_ptr<BLEService> create_service(uint16_t uuid, bool advertise = false);
|
||||
@@ -63,6 +67,7 @@ class BLEServer : public Component, public GATTsEventHandler, public Parented<ES
|
||||
|
||||
protected:
|
||||
bool create_device_characteristics_();
|
||||
void restart_advertising_();
|
||||
|
||||
void add_client_(uint16_t conn_id, void *client) {
|
||||
this->clients_.insert(std::pair<uint16_t, void *>(conn_id, client));
|
||||
@@ -73,6 +78,7 @@ class BLEServer : public Component, public GATTsEventHandler, public Parented<ES
|
||||
|
||||
std::string manufacturer_;
|
||||
optional<std::string> model_;
|
||||
std::vector<uint8_t> manufacturer_data_;
|
||||
esp_gatt_if_t gatts_if_{0};
|
||||
bool registered_{false};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifdef USE_ESP32
|
||||
#include "esp32_hall.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include <driver/adc.h>
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_hall {
|
||||
@@ -16,7 +16,6 @@ void ESP32HallSensor::update() {
|
||||
ESP_LOGD(TAG, "'%s': Got reading %.0f µT", this->name_.c_str(), value);
|
||||
this->publish_state(value);
|
||||
}
|
||||
std::string ESP32HallSensor::unique_id() { return get_mac_address() + "-hall"; }
|
||||
void ESP32HallSensor::dump_config() { LOG_SENSOR("", "ESP32 Hall Sensor", this); }
|
||||
|
||||
} // namespace esp32_hall
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
@@ -13,8 +13,6 @@ class ESP32HallSensor : public sensor::Sensor, public PollingComponent {
|
||||
void dump_config() override;
|
||||
|
||||
void update() override;
|
||||
|
||||
std::string unique_id() override;
|
||||
};
|
||||
|
||||
} // namespace esp32_hall
|
||||
|
||||
@@ -63,6 +63,7 @@ RMT_CHANNELS = {
|
||||
esp32.const.VARIANT_ESP32S2: [0, 1, 2, 3],
|
||||
esp32.const.VARIANT_ESP32S3: [0, 1, 2, 3],
|
||||
esp32.const.VARIANT_ESP32C3: [0, 1],
|
||||
esp32.const.VARIANT_ESP32C6: [0, 1],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,11 +8,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
#include <driver/touch_sensor.h>
|
||||
#else
|
||||
#include <driver/touch_pad.h>
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_touch {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
#include "esphome/components/ethernet/ethernet_component.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
@@ -20,7 +20,6 @@ class IPAddressEthernetInfo : public PollingComponent, public text_sensor::TextS
|
||||
}
|
||||
|
||||
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -33,6 +33,7 @@ PROTOCOLS = {
|
||||
"greeya": Protocol.PROTOCOL_GREEYAA,
|
||||
"greeyan": Protocol.PROTOCOL_GREEYAN,
|
||||
"greeyac": Protocol.PROTOCOL_GREEYAC,
|
||||
"greeyt": Protocol.PROTOCOL_GREEYT,
|
||||
"hisense_aud": Protocol.PROTOCOL_HISENSE_AUD,
|
||||
"hitachi": Protocol.PROTOCOL_HITACHI,
|
||||
"hyundai": Protocol.PROTOCOL_HYUNDAI,
|
||||
@@ -115,7 +116,7 @@ def to_code(config):
|
||||
cg.add(var.set_max_temperature(config[CONF_MAX_TEMPERATURE]))
|
||||
cg.add(var.set_min_temperature(config[CONF_MIN_TEMPERATURE]))
|
||||
|
||||
cg.add_library("tonia/HeatpumpIR", "1.0.20")
|
||||
cg.add_library("tonia/HeatpumpIR", "1.0.23")
|
||||
|
||||
if CORE.is_esp8266 or CORE.is_esp32:
|
||||
cg.add_library("crankyoldgit/IRremoteESP8266", "2.7.12")
|
||||
|
||||
@@ -27,6 +27,7 @@ const std::map<Protocol, std::function<HeatpumpIR *()>> PROTOCOL_CONSTRUCTOR_MAP
|
||||
{PROTOCOL_GREEYAA, []() { return new GreeYAAHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_GREEYAN, []() { return new GreeYANHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_GREEYAC, []() { return new GreeYACHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_GREEYT, []() { return new GreeYTHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_HISENSE_AUD, []() { return new HisenseHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_HITACHI, []() { return new HitachiHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_HYUNDAI, []() { return new HyundaiHeatpumpIR(); }}, // NOLINT
|
||||
|
||||
@@ -27,6 +27,7 @@ enum Protocol {
|
||||
PROTOCOL_GREEYAA,
|
||||
PROTOCOL_GREEYAN,
|
||||
PROTOCOL_GREEYAC,
|
||||
PROTOCOL_GREEYT,
|
||||
PROTOCOL_HISENSE_AUD,
|
||||
PROTOCOL_HITACHI,
|
||||
PROTOCOL_HYUNDAI,
|
||||
|
||||
@@ -23,13 +23,13 @@ CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(HTU21DComponent),
|
||||
cv.Required(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Required(CONF_HUMIDITY): sensor.sensor_schema(
|
||||
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PERCENT,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
|
||||
@@ -16,7 +16,7 @@ from esphome.const import (
|
||||
)
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
CODEOWNERS = ["@MrEditor97"]
|
||||
CODEOWNERS = ["@mreditor97"]
|
||||
|
||||
ina260_ns = cg.esphome_ns.namespace("ina260")
|
||||
INA260Component = ina260_ns.class_(
|
||||
|
||||
@@ -28,6 +28,8 @@ from esphome.components.esp32.const import (
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32C3,
|
||||
VARIANT_ESP32S3,
|
||||
VARIANT_ESP32C2,
|
||||
VARIANT_ESP32C6,
|
||||
)
|
||||
|
||||
CODEOWNERS = ["@esphome/core"]
|
||||
@@ -74,6 +76,8 @@ UART_SELECTION_ESP32 = {
|
||||
VARIANT_ESP32S2: [UART0, UART1, USB_CDC],
|
||||
VARIANT_ESP32S3: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||
VARIANT_ESP32C3: [UART0, UART1, USB_SERIAL_JTAG],
|
||||
VARIANT_ESP32C2: [UART0, UART1],
|
||||
VARIANT_ESP32C6: [UART0, UART1, USB_CDC, USB_SERIAL_JTAG],
|
||||
}
|
||||
|
||||
UART_SELECTION_ESP8266 = [UART0, UART0_SWAP, UART1]
|
||||
|
||||
@@ -120,7 +120,7 @@ void HOT Logger::log_message_(int level, const char *tag, int offset) {
|
||||
if (
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S2)
|
||||
uart_ == UART_SELECTION_USB_CDC
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3)
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6)
|
||||
uart_ == UART_SELECTION_USB_SERIAL_JTAG
|
||||
#elif defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
uart_ == UART_SELECTION_USB_CDC || uart_ == UART_SELECTION_USB_SERIAL_JTAG
|
||||
@@ -191,8 +191,8 @@ void Logger::pre_setup() {
|
||||
Serial1.setDebugOutput(ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE);
|
||||
#endif
|
||||
break;
|
||||
#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2) && \
|
||||
!defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
||||
!defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case UART_SELECTION_UART2:
|
||||
this->hw_serial_ = &Serial2;
|
||||
Serial2.begin(this->baud_rate_);
|
||||
@@ -215,7 +215,8 @@ void Logger::pre_setup() {
|
||||
case UART_SELECTION_UART1:
|
||||
uart_num_ = UART_NUM_1;
|
||||
break;
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
||||
!defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case UART_SELECTION_UART2:
|
||||
uart_num_ = UART_NUM_2;
|
||||
break;
|
||||
@@ -225,11 +226,11 @@ void Logger::pre_setup() {
|
||||
uart_num_ = -1;
|
||||
break;
|
||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
case UART_SELECTION_USB_SERIAL_JTAG:
|
||||
uart_num_ = -1;
|
||||
break;
|
||||
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
|
||||
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C6 || USE_ESP32_VARIANT_ESP32S3
|
||||
}
|
||||
if (uart_num_ >= 0) {
|
||||
uart_config_t uart_config{};
|
||||
@@ -278,7 +279,8 @@ const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DE
|
||||
#ifdef USE_ESP32
|
||||
const char *const UART_SELECTIONS[] = {
|
||||
"UART0", "UART1",
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
||||
!defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
"UART2",
|
||||
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32S2 && !USE_ESP32_VARIANT_ESP32S3
|
||||
#if defined(USE_ESP_IDF)
|
||||
|
||||
@@ -34,14 +34,15 @@ enum UARTSelection {
|
||||
UART_SELECTION_UART0 = 0,
|
||||
UART_SELECTION_UART1,
|
||||
#if defined(USE_ESP32)
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
||||
!defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
UART_SELECTION_UART2,
|
||||
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32S2 && !USE_ESP32_VARIANT_ESP32S3
|
||||
#ifdef USE_ESP_IDF
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
UART_SELECTION_USB_CDC,
|
||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
UART_SELECTION_USB_SERIAL_JTAG,
|
||||
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
|
||||
#endif // USE_ESP_IDF
|
||||
|
||||
@@ -13,7 +13,7 @@ CONF_HOT_JUNCTION = "hot_junction"
|
||||
CONF_COLD_JUNCTION = "cold_junction"
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
CODEOWNERS = ["@MrEditor97"]
|
||||
CODEOWNERS = ["@mreditor97"]
|
||||
|
||||
mcp9600_ns = cg.esphome_ns.namespace("mcp9600")
|
||||
MCP9600Component = mcp9600_ns.class_(
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#ifdef USE_MQTT
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/version.h"
|
||||
|
||||
#include "mqtt_const.h"
|
||||
@@ -111,21 +111,16 @@ bool MQTTComponent::send_discovery_() {
|
||||
root[MQTT_PAYLOAD_NOT_AVAILABLE] = this->availability_->payload_not_available;
|
||||
}
|
||||
|
||||
std::string unique_id = this->unique_id();
|
||||
const MQTTDiscoveryInfo &discovery_info = global_mqtt_client->get_discovery_info();
|
||||
if (!unique_id.empty()) {
|
||||
root[MQTT_UNIQUE_ID] = unique_id;
|
||||
if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) {
|
||||
char friendly_name_hash[9];
|
||||
sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name()));
|
||||
friendly_name_hash[8] = 0; // ensure the hash-string ends with null
|
||||
root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash;
|
||||
} else {
|
||||
if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) {
|
||||
char friendly_name_hash[9];
|
||||
sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name()));
|
||||
friendly_name_hash[8] = 0; // ensure the hash-string ends with null
|
||||
root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash;
|
||||
} else {
|
||||
// default to almost-unique ID. It's a hack but the only way to get that
|
||||
// gorgeous device registry view.
|
||||
root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_();
|
||||
}
|
||||
// default to almost-unique ID. It's a hack but the only way to get that
|
||||
// gorgeous device registry view.
|
||||
root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_();
|
||||
}
|
||||
|
||||
const std::string &node_name = App.get_name();
|
||||
@@ -233,7 +228,6 @@ void MQTTComponent::call_dump_config() {
|
||||
this->dump_config();
|
||||
}
|
||||
void MQTTComponent::schedule_resend_state() { this->resend_state_ = true; }
|
||||
std::string MQTTComponent::unique_id() { return ""; }
|
||||
bool MQTTComponent::is_connected_() const { return global_mqtt_client->is_connected(); }
|
||||
|
||||
// Pull these properties from EntityBase if not overridden
|
||||
|
||||
@@ -156,13 +156,6 @@ class MQTTComponent : public Component {
|
||||
*/
|
||||
virtual const EntityBase *get_entity() const = 0;
|
||||
|
||||
/** A unique ID for this MQTT component, empty for no unique id. See unique ID requirements:
|
||||
* https://developers.home-assistant.io/docs/en/entity_registry_index.html#unique-id-requirements
|
||||
*
|
||||
* @return The unique id as a string.
|
||||
*/
|
||||
virtual std::string unique_id();
|
||||
|
||||
/// Get the friendly name of this MQTT component.
|
||||
virtual std::string friendly_name() const;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <cinttypes>
|
||||
#include "mqtt_sensor.h"
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include "mqtt_const.h"
|
||||
@@ -72,7 +72,6 @@ bool MQTTSensorComponent::publish_state(float value) {
|
||||
int8_t accuracy = this->sensor_->get_accuracy_decimals();
|
||||
return this->publish(this->get_state_topic_(), value_accuracy_to_string(value, accuracy));
|
||||
}
|
||||
std::string MQTTSensorComponent::unique_id() { return this->sensor_->unique_id(); }
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
@@ -46,7 +46,6 @@ class MQTTSensorComponent : public mqtt::MQTTComponent {
|
||||
/// Override for MQTTComponent, returns "sensor".
|
||||
std::string component_type() const override;
|
||||
const EntityBase *get_entity() const override;
|
||||
std::string unique_id() override;
|
||||
|
||||
sensor::Sensor *sensor_;
|
||||
optional<uint32_t> expire_after_; // Override the expire after advertised to Home Assistant
|
||||
|
||||
@@ -34,7 +34,6 @@ bool MQTTTextSensor::send_initial_state() {
|
||||
}
|
||||
std::string MQTTTextSensor::component_type() const { return "sensor"; }
|
||||
const EntityBase *MQTTTextSensor::get_entity() const { return this->sensor_; }
|
||||
std::string MQTTTextSensor::unique_id() { return this->sensor_->unique_id(); }
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
@@ -28,7 +28,6 @@ class MQTTTextSensor : public mqtt::MQTTComponent {
|
||||
protected:
|
||||
std::string component_type() const override;
|
||||
const EntityBase *get_entity() const override;
|
||||
std::string unique_id() override;
|
||||
|
||||
text_sensor::TextSensor *sensor_;
|
||||
};
|
||||
|
||||
1
esphome/components/pmwcs3/__init__.py
Normal file
1
esphome/components/pmwcs3/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
CODEOWNERS = ["@SeByDocKy"]
|
||||
115
esphome/components/pmwcs3/pmwcs3.cpp
Normal file
115
esphome/components/pmwcs3/pmwcs3.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "pmwcs3.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace pmwcs3 {
|
||||
|
||||
static const uint8_t PMWCS3_I2C_ADDRESS = 0x63;
|
||||
static const uint8_t PMWCS3_REG_READ_START = 0x01;
|
||||
static const uint8_t PMWCS3_REG_READ_E25 = 0x02;
|
||||
static const uint8_t PMWCS3_REG_READ_EC = 0x03;
|
||||
static const uint8_t PMWCS3_REG_READ_TEMP = 0x04;
|
||||
static const uint8_t PMWCS3_REG_READ_VWC = 0x05;
|
||||
static const uint8_t PMWCS3_REG_CALIBRATE_AIR = 0x06;
|
||||
static const uint8_t PMWCS3_REG_CALIBRATE_WATER = 0x07;
|
||||
static const uint8_t PMWCS3_SET_I2C_ADDRESS = 0x08;
|
||||
static const uint8_t PMWCS3_REG_GET_DATA = 0x09;
|
||||
static const uint8_t PMWCS3_REG_CALIBRATE_EC = 0x10;
|
||||
static const uint8_t PMWCS3_REG_CAP = 0x0A;
|
||||
static const uint8_t PMWCS3_REG_RES = 0x0B;
|
||||
static const uint8_t PMWCS3_REG_RC = 0x0C;
|
||||
static const uint8_t PMWCS3_REG_RT = 0x0D;
|
||||
|
||||
static const char *const TAG = "pmwcs3";
|
||||
|
||||
void PMWCS3Component::new_i2c_address(uint8_t address) {
|
||||
if (!this->write_byte(PMWCS3_SET_I2C_ADDRESS, address)) {
|
||||
this->status_set_warning();
|
||||
ESP_LOGW(TAG, "couldn't write the new I2C address %d", address);
|
||||
return;
|
||||
}
|
||||
this->set_i2c_address(address); // Allows device to continue working until new firmware is written with new address.
|
||||
ESP_LOGVV(TAG, "changed I2C address to %d", address);
|
||||
this->status_clear_warning();
|
||||
}
|
||||
|
||||
void PMWCS3Component::air_calibration() {
|
||||
if (!this->write_bytes(PMWCS3_REG_CALIBRATE_AIR, nullptr, 0)) {
|
||||
this->status_set_warning();
|
||||
ESP_LOGW(TAG, "couldn't start air calibration");
|
||||
return;
|
||||
}
|
||||
ESP_LOGW(TAG, "Start air calibration during the next 300s");
|
||||
}
|
||||
void PMWCS3Component::water_calibration() {
|
||||
if (!this->write_bytes(PMWCS3_REG_CALIBRATE_WATER, nullptr, 0)) {
|
||||
this->status_set_warning();
|
||||
ESP_LOGW(TAG, "couldn't start water calibration");
|
||||
return;
|
||||
}
|
||||
ESP_LOGW(TAG, "Start water calibration during the next 300s");
|
||||
}
|
||||
|
||||
void PMWCS3Component::setup() { ESP_LOGCONFIG(TAG, "Setting up PMWCS3..."); }
|
||||
|
||||
void PMWCS3Component::update() { this->read_data_(); }
|
||||
|
||||
float PMWCS3Component::get_setup_priority() const { return setup_priority::DATA; }
|
||||
|
||||
void PMWCS3Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "PMWCS3");
|
||||
LOG_I2C_DEVICE(this);
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, "Communication with PMWCS3 failed!");
|
||||
}
|
||||
ESP_LOGI(TAG, "%s", this->is_failed() ? "FAILED" : "OK");
|
||||
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_SENSOR(" ", "e25", this->e25_sensor_);
|
||||
LOG_SENSOR(" ", "ec", this->ec_sensor_);
|
||||
LOG_SENSOR(" ", "temperature", this->temperature_sensor_);
|
||||
LOG_SENSOR(" ", "vwc", this->vwc_sensor_);
|
||||
}
|
||||
void PMWCS3Component::read_data_() {
|
||||
uint8_t data[8];
|
||||
float e25, ec, temperature, vwc;
|
||||
|
||||
/////// Super important !!!! first activate reading PMWCS3_REG_READ_START (if not, return always the same values) ////
|
||||
|
||||
if (!this->write_bytes(PMWCS3_REG_READ_START, nullptr, 0)) {
|
||||
this->status_set_warning();
|
||||
ESP_LOGVV(TAG, "Failed to write into REG_READ_START register !!!");
|
||||
return;
|
||||
}
|
||||
// NOLINT delay(100);
|
||||
|
||||
if (!this->read_bytes(PMWCS3_REG_GET_DATA, (uint8_t *) &data, 8)) {
|
||||
ESP_LOGVV(TAG, "Error reading PMWCS3_REG_GET_DATA registers");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
if (this->e25_sensor_ != nullptr) {
|
||||
e25 = ((data[1] << 8) | data[0]) / 100.0;
|
||||
this->e25_sensor_->publish_state(e25);
|
||||
ESP_LOGVV(TAG, "e25: data[0]=%d, data[1]=%d, result=%f", data[0], data[1], e25);
|
||||
}
|
||||
if (this->ec_sensor_ != nullptr) {
|
||||
ec = ((data[3] << 8) | data[2]) / 10.0;
|
||||
this->ec_sensor_->publish_state(ec);
|
||||
ESP_LOGVV(TAG, "ec: data[2]=%d, data[3]=%d, result=%f", data[2], data[3], ec);
|
||||
}
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
temperature = ((data[5] << 8) | data[4]) / 100.0;
|
||||
this->temperature_sensor_->publish_state(temperature);
|
||||
ESP_LOGVV(TAG, "temp: data[4]=%d, data[5]=%d, result=%f", data[4], data[5], temperature);
|
||||
}
|
||||
if (this->vwc_sensor_ != nullptr) {
|
||||
vwc = ((data[7] << 8) | data[6]) / 10.0;
|
||||
this->vwc_sensor_->publish_state(vwc);
|
||||
ESP_LOGVV(TAG, "vwc: data[6]=%d, data[7]=%d, result=%f", data[6], data[7], vwc);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pmwcs3
|
||||
} // namespace esphome
|
||||
70
esphome/components/pmwcs3/pmwcs3.h
Normal file
70
esphome/components/pmwcs3/pmwcs3.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
|
||||
// ref:
|
||||
// https://github.com/tinovi/i2cArduino/blob/master/i2cArduino.h
|
||||
|
||||
namespace esphome {
|
||||
namespace pmwcs3 {
|
||||
|
||||
class PMWCS3Component : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override;
|
||||
|
||||
void set_e25_sensor(sensor::Sensor *e25_sensor) { e25_sensor_ = e25_sensor; }
|
||||
void set_ec_sensor(sensor::Sensor *ec_sensor) { ec_sensor_ = ec_sensor; }
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
void set_vwc_sensor(sensor::Sensor *vwc_sensor) { vwc_sensor_ = vwc_sensor; }
|
||||
|
||||
void new_i2c_address(uint8_t newaddress);
|
||||
void air_calibration();
|
||||
void water_calibration();
|
||||
|
||||
protected:
|
||||
void read_data_();
|
||||
|
||||
sensor::Sensor *e25_sensor_{nullptr};
|
||||
sensor::Sensor *ec_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
sensor::Sensor *vwc_sensor_{nullptr};
|
||||
};
|
||||
|
||||
template<typename... Ts> class PMWCS3AirCalibrationAction : public Action<Ts...> {
|
||||
public:
|
||||
PMWCS3AirCalibrationAction(PMWCS3Component *parent) : parent_(parent) {}
|
||||
|
||||
void play(Ts... x) override { this->parent_->air_calibration(); }
|
||||
|
||||
protected:
|
||||
PMWCS3Component *parent_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class PMWCS3WaterCalibrationAction : public Action<Ts...> {
|
||||
public:
|
||||
PMWCS3WaterCalibrationAction(PMWCS3Component *parent) : parent_(parent) {}
|
||||
|
||||
void play(Ts... x) override { this->parent_->water_calibration(); }
|
||||
|
||||
protected:
|
||||
PMWCS3Component *parent_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class PMWCS3NewI2cAddressAction : public Action<Ts...> {
|
||||
public:
|
||||
PMWCS3NewI2cAddressAction(PMWCS3Component *parent) : parent_(parent) {}
|
||||
TEMPLATABLE_VALUE(int, new_address)
|
||||
|
||||
void play(Ts... x) override { this->parent_->new_i2c_address(this->new_address_.value(x...)); }
|
||||
|
||||
protected:
|
||||
PMWCS3Component *parent_;
|
||||
};
|
||||
|
||||
} // namespace pmwcs3
|
||||
} // namespace esphome
|
||||
140
esphome/components/pmwcs3/sensor.py
Normal file
140
esphome/components/pmwcs3/sensor.py
Normal file
@@ -0,0 +1,140 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome import automation
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import i2c, sensor
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_ADDRESS,
|
||||
CONF_TEMPERATURE,
|
||||
CONF_EC,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
ICON_THERMOMETER,
|
||||
)
|
||||
|
||||
CODEOWNERS = ["@SeByDocKy"]
|
||||
DEPENDENCIES = ["i2c"]
|
||||
|
||||
CONF_E25 = "e25"
|
||||
CONF_VWC = "vwc"
|
||||
|
||||
ICON_EPSILON = "mdi:epsilon"
|
||||
ICON_SIGMA = "mdi:sigma-lower"
|
||||
ICON_ALPHA = "mdi:alpha-h-circle-outline"
|
||||
|
||||
pmwcs3_ns = cg.esphome_ns.namespace("pmwcs3")
|
||||
PMWCS3Component = pmwcs3_ns.class_(
|
||||
"PMWCS3Component", cg.PollingComponent, i2c.I2CDevice
|
||||
)
|
||||
|
||||
# Actions
|
||||
PMWCS3AirCalibrationAction = pmwcs3_ns.class_(
|
||||
"PMWCS3AirCalibrationAction", automation.Action
|
||||
)
|
||||
PMWCS3WaterCalibrationAction = pmwcs3_ns.class_(
|
||||
"PMWCS3WaterCalibrationAction", automation.Action
|
||||
)
|
||||
PMWCS3NewI2cAddressAction = pmwcs3_ns.class_(
|
||||
"PMWCS3NewI2cAddressAction", automation.Action
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(PMWCS3Component),
|
||||
cv.Optional(CONF_E25): sensor.sensor_schema(
|
||||
icon=ICON_EPSILON,
|
||||
accuracy_decimals=3,
|
||||
unit_of_measurement="dS/m",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(CONF_EC): sensor.sensor_schema(
|
||||
icon=ICON_SIGMA,
|
||||
accuracy_decimals=2,
|
||||
unit_of_measurement="mS/m",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||
icon=ICON_THERMOMETER,
|
||||
accuracy_decimals=3,
|
||||
unit_of_measurement="°C",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(CONF_VWC): sensor.sensor_schema(
|
||||
icon=ICON_ALPHA,
|
||||
accuracy_decimals=3,
|
||||
unit_of_measurement="cm3cm−3",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.polling_component_schema("60s"))
|
||||
.extend(i2c.i2c_device_schema(0x63))
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
if CONF_E25 in config:
|
||||
sens = await sensor.new_sensor(config[CONF_E25])
|
||||
cg.add(var.set_e25_sensor(sens))
|
||||
|
||||
if CONF_EC in config:
|
||||
sens = await sensor.new_sensor(config[CONF_EC])
|
||||
cg.add(var.set_ec_sensor(sens))
|
||||
|
||||
if CONF_TEMPERATURE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
|
||||
if CONF_VWC in config:
|
||||
sens = await sensor.new_sensor(config[CONF_VWC])
|
||||
cg.add(var.set_vwc_sensor(sens))
|
||||
|
||||
|
||||
# Actions
|
||||
PMWCS3_CALIBRATION_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(PMWCS3Component),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"pmwcs3.air_calibration",
|
||||
PMWCS3AirCalibrationAction,
|
||||
PMWCS3_CALIBRATION_SCHEMA,
|
||||
)
|
||||
@automation.register_action(
|
||||
"pmwcs3.water_calibration",
|
||||
PMWCS3WaterCalibrationAction,
|
||||
PMWCS3_CALIBRATION_SCHEMA,
|
||||
)
|
||||
async def pmwcs3_calibration_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)
|
||||
return var
|
||||
|
||||
|
||||
PMWCS3_NEW_I2C_ADDRESS_SCHEMA = cv.maybe_simple_value(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(PMWCS3Component),
|
||||
cv.Required(CONF_ADDRESS): cv.templatable(cv.i2c_address),
|
||||
},
|
||||
key=CONF_ADDRESS,
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"pmwcs3.new_i2c_address",
|
||||
PMWCS3NewI2cAddressAction,
|
||||
PMWCS3_NEW_I2C_ADDRESS_SCHEMA,
|
||||
)
|
||||
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)
|
||||
cg.add(var.set_new_address(address))
|
||||
return var
|
||||
@@ -1,9 +1,11 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components.esp32 import add_idf_sdkconfig_option
|
||||
from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant
|
||||
from esphome.core import CORE
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_MODE,
|
||||
CONF_SPEED,
|
||||
)
|
||||
|
||||
CODEOWNERS = ["@esphome/core"]
|
||||
@@ -11,8 +13,26 @@ CODEOWNERS = ["@esphome/core"]
|
||||
psram_ns = cg.esphome_ns.namespace("psram")
|
||||
PsramComponent = psram_ns.class_("PsramComponent", cg.Component)
|
||||
|
||||
SPIRAM_MODES = {
|
||||
"quad": "CONFIG_SPIRAM_MODE_QUAD",
|
||||
"octal": "CONFIG_SPIRAM_MODE_OCT",
|
||||
}
|
||||
|
||||
SPIRAM_SPEEDS = {
|
||||
40e6: "CONFIG_SPIRAM_SPEED_40M",
|
||||
80e6: "CONFIG_SPIRAM_SPEED_80M",
|
||||
120e6: "CONFIG_SPIRAM_SPEED_120M",
|
||||
}
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema({cv.GenerateID(): cv.declare_id(PsramComponent)}), cv.only_on_esp32
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(PsramComponent),
|
||||
cv.Optional(CONF_MODE): cv.enum(SPIRAM_MODES, lower=True),
|
||||
cv.Optional(CONF_SPEED): cv.All(cv.frequency, cv.one_of(*SPIRAM_SPEEDS)),
|
||||
}
|
||||
),
|
||||
cv.only_on_esp32,
|
||||
)
|
||||
|
||||
|
||||
@@ -21,9 +41,18 @@ async def to_code(config):
|
||||
cg.add_build_flag("-DBOARD_HAS_PSRAM")
|
||||
|
||||
if CORE.using_esp_idf:
|
||||
add_idf_sdkconfig_option("CONFIG_ESP32_SPIRAM_SUPPORT", True)
|
||||
add_idf_sdkconfig_option(
|
||||
f"CONFIG_{get_esp32_variant().upper()}_SPIRAM_SUPPORT", True
|
||||
)
|
||||
add_idf_sdkconfig_option("CONFIG_SPIRAM", True)
|
||||
add_idf_sdkconfig_option("CONFIG_SPIRAM_USE", True)
|
||||
add_idf_sdkconfig_option("CONFIG_SPIRAM_USE_CAPS_ALLOC", True)
|
||||
add_idf_sdkconfig_option("CONFIG_SPIRAM_IGNORE_NOTFOUND", True)
|
||||
|
||||
if CONF_MODE in config:
|
||||
add_idf_sdkconfig_option(f"{SPIRAM_MODES[config[CONF_MODE]]}", True)
|
||||
if CONF_SPEED in config:
|
||||
add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True)
|
||||
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
||||
@@ -96,7 +96,7 @@ std::string AEHAProtocol::format_data_(const std::vector<uint8_t> &data) {
|
||||
|
||||
void AEHAProtocol::dump(const AEHAData &data) {
|
||||
auto data_str = format_data_(data.data);
|
||||
ESP_LOGD(TAG, "Received AEHA: address=0x%04X, data=[%s]", data.address, data_str.c_str());
|
||||
ESP_LOGI(TAG, "Received AEHA: address=0x%04X, data=[%s]", data.address, data_str.c_str());
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -96,10 +96,10 @@ optional<CanalSatData> CanalSatBaseProtocol::decode(RemoteReceiveData src) {
|
||||
|
||||
void CanalSatBaseProtocol::dump(const CanalSatData &data) {
|
||||
if (this->tag_ == CANALSATLD_TAG) {
|
||||
ESP_LOGD(this->tag_, "Received CanalSatLD: device=0x%02X, address=0x%02X, command=0x%02X, repeat=0x%X", data.device,
|
||||
ESP_LOGI(this->tag_, "Received CanalSatLD: device=0x%02X, address=0x%02X, command=0x%02X, repeat=0x%X", data.device,
|
||||
data.address, data.command, data.repeat);
|
||||
} else {
|
||||
ESP_LOGD(this->tag_, "Received CanalSat: device=0x%02X, address=0x%02X, command=0x%02X, repeat=0x%X", data.device,
|
||||
ESP_LOGI(this->tag_, "Received CanalSat: device=0x%02X, address=0x%02X, command=0x%02X, repeat=0x%X", data.device,
|
||||
data.address, data.command, data.repeat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,11 +101,11 @@ optional<CoolixData> CoolixProtocol::decode(RemoteReceiveData data) {
|
||||
|
||||
void CoolixProtocol::dump(const CoolixData &data) {
|
||||
if (data.is_strict()) {
|
||||
ESP_LOGD(TAG, "Received Coolix: 0x%06X", data.first);
|
||||
ESP_LOGI(TAG, "Received Coolix: 0x%06X", data.first);
|
||||
} else if (data.has_second()) {
|
||||
ESP_LOGD(TAG, "Received unstrict Coolix: [0x%06X, 0x%06X]", data.first, data.second);
|
||||
ESP_LOGI(TAG, "Received unstrict Coolix: [0x%06X, 0x%06X]", data.first, data.second);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Received unstrict Coolix: [0x%06X]", data.first);
|
||||
ESP_LOGI(TAG, "Received unstrict Coolix: [0x%06X]", data.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ optional<DishData> DishProtocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
|
||||
void DishProtocol::dump(const DishData &data) {
|
||||
ESP_LOGD(TAG, "Received Dish: address=0x%02X, command=0x%02X", data.address, data.command);
|
||||
ESP_LOGI(TAG, "Received Dish: address=0x%02X, command=0x%02X", data.address, data.command);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -205,7 +205,7 @@ optional<DraytonData> DraytonProtocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void DraytonProtocol::dump(const DraytonData &data) {
|
||||
ESP_LOGD(TAG, "Received Drayton: address=0x%04X (0x%04x), channel=0x%03x command=0x%03X", data.address,
|
||||
ESP_LOGI(TAG, "Received Drayton: address=0x%04X (0x%04x), channel=0x%03x command=0x%03X", data.address,
|
||||
((data.address << 1) & 0xffff), data.channel, data.command);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ optional<JVCData> JVCProtocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
void JVCProtocol::dump(const JVCData &data) { ESP_LOGD(TAG, "Received JVC: data=0x%04X", data.data); }
|
||||
void JVCProtocol::dump(const JVCData &data) { ESP_LOGI(TAG, "Received JVC: data=0x%04X", data.data); }
|
||||
|
||||
} // namespace remote_base
|
||||
} // namespace esphome
|
||||
|
||||
@@ -51,7 +51,7 @@ optional<LGData> LGProtocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void LGProtocol::dump(const LGData &data) {
|
||||
ESP_LOGD(TAG, "Received LG: data=0x%08X, nbits=%d", data.data, data.nbits);
|
||||
ESP_LOGI(TAG, "Received LG: data=0x%08X, nbits=%d", data.data, data.nbits);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -76,7 +76,7 @@ optional<MagiQuestData> MagiQuestProtocol::decode(RemoteReceiveData src) {
|
||||
return data;
|
||||
}
|
||||
void MagiQuestProtocol::dump(const MagiQuestData &data) {
|
||||
ESP_LOGD(TAG, "Received MagiQuest: wand_id=0x%08X, magnitude=0x%04X", data.wand_id, data.magnitude);
|
||||
ESP_LOGI(TAG, "Received MagiQuest: wand_id=0x%08X, magnitude=0x%04X", data.wand_id, data.magnitude);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -70,7 +70,7 @@ optional<MideaData> MideaProtocol::decode(RemoteReceiveData src) {
|
||||
return {};
|
||||
}
|
||||
|
||||
void MideaProtocol::dump(const MideaData &data) { ESP_LOGD(TAG, "Received Midea: %s", data.to_string().c_str()); }
|
||||
void MideaProtocol::dump(const MideaData &data) { ESP_LOGI(TAG, "Received Midea: %s", data.to_string().c_str()); }
|
||||
|
||||
} // namespace remote_base
|
||||
} // namespace esphome
|
||||
|
||||
@@ -67,7 +67,7 @@ optional<NECData> NECProtocol::decode(RemoteReceiveData src) {
|
||||
return data;
|
||||
}
|
||||
void NECProtocol::dump(const NECData &data) {
|
||||
ESP_LOGD(TAG, "Received NEC: address=0x%04X, command=0x%04X", data.address, data.command);
|
||||
ESP_LOGI(TAG, "Received NEC: address=0x%04X, command=0x%04X", data.address, data.command);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -232,7 +232,7 @@ optional<NexaData> NexaProtocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
|
||||
void NexaProtocol::dump(const NexaData &data) {
|
||||
ESP_LOGD(TAG, "Received NEXA: device=0x%04X group=%d state=%d channel=%d level=%d", data.device, data.group,
|
||||
ESP_LOGI(TAG, "Received NEXA: device=0x%04X group=%d state=%d channel=%d level=%d", data.device, data.group,
|
||||
data.state, data.channel, data.level);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ optional<PanasonicData> PanasonicProtocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void PanasonicProtocol::dump(const PanasonicData &data) {
|
||||
ESP_LOGD(TAG, "Received Panasonic: address=0x%04X, command=0x%08X", data.address, data.command);
|
||||
ESP_LOGI(TAG, "Received Panasonic: address=0x%04X, command=0x%08X", data.address, data.command);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -146,9 +146,9 @@ optional<PioneerData> PioneerProtocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
void PioneerProtocol::dump(const PioneerData &data) {
|
||||
if (data.rc_code_2 == 0) {
|
||||
ESP_LOGD(TAG, "Received Pioneer: rc_code_X=0x%04X", data.rc_code_1);
|
||||
ESP_LOGI(TAG, "Received Pioneer: rc_code_X=0x%04X", data.rc_code_1);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Received Pioneer: rc_code_1=0x%04X, rc_code_2=0x%04X", data.rc_code_1, data.rc_code_2);
|
||||
ESP_LOGI(TAG, "Received Pioneer: rc_code_1=0x%04X, rc_code_2=0x%04X", data.rc_code_1, data.rc_code_2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,9 +234,9 @@ void ProntoProtocol::dump(const ProntoData &data) {
|
||||
first = data.data.substr(0, 229);
|
||||
rest = data.data.substr(230);
|
||||
}
|
||||
ESP_LOGD(TAG, "Received Pronto: data=%s", first.c_str());
|
||||
ESP_LOGI(TAG, "Received Pronto: data=%s", first.c_str());
|
||||
if (!rest.empty()) {
|
||||
ESP_LOGD(TAG, "%s", rest.c_str());
|
||||
ESP_LOGI(TAG, "%s", rest.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ bool RawDumper::dump(RemoteReceiveData src) {
|
||||
if (written < 0 || written >= int(remaining_length)) {
|
||||
// write failed, flush...
|
||||
buffer[buffer_offset] = '\0';
|
||||
ESP_LOGD(TAG, "%s", buffer);
|
||||
ESP_LOGI(TAG, "%s", buffer);
|
||||
buffer_offset = 0;
|
||||
written = sprintf(buffer, " ");
|
||||
if (i + 1 < src.size()) {
|
||||
@@ -38,7 +38,7 @@ bool RawDumper::dump(RemoteReceiveData src) {
|
||||
buffer_offset += written;
|
||||
}
|
||||
if (buffer_offset != 0) {
|
||||
ESP_LOGD(TAG, "%s", buffer);
|
||||
ESP_LOGI(TAG, "%s", buffer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ optional<RC5Data> RC5Protocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void RC5Protocol::dump(const RC5Data &data) {
|
||||
ESP_LOGD(TAG, "Received RC5: address=0x%02X, command=0x%02X", data.address, data.command);
|
||||
ESP_LOGI(TAG, "Received RC5: address=0x%02X, command=0x%02X", data.address, data.command);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -173,7 +173,7 @@ optional<RC6Data> RC6Protocol::decode(RemoteReceiveData src) {
|
||||
}
|
||||
|
||||
void RC6Protocol::dump(const RC6Data &data) {
|
||||
ESP_LOGD(RC6_TAG, "Received RC6: mode=0x%X, address=0x%02X, command=0x%02X, toggle=0x%X", data.mode, data.address,
|
||||
ESP_LOGI(RC6_TAG, "Received RC6: mode=0x%X, address=0x%02X, command=0x%02X, toggle=0x%X", data.mode, data.address,
|
||||
data.command, data.toggle);
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ bool RCSwitchDumper::dump(RemoteReceiveData src) {
|
||||
buffer[j] = (out_data & ((uint64_t) 1 << (out_nbits - j - 1))) ? '1' : '0';
|
||||
|
||||
buffer[out_nbits] = '\0';
|
||||
ESP_LOGD(TAG, "Received RCSwitch Raw: protocol=%u data='%s'", i, buffer);
|
||||
ESP_LOGI(TAG, "Received RCSwitch Raw: protocol=%u data='%s'", i, buffer);
|
||||
|
||||
// only send first decoded protocol
|
||||
return true;
|
||||
|
||||
@@ -96,7 +96,7 @@ optional<Samsung36Data> Samsung36Protocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void Samsung36Protocol::dump(const Samsung36Data &data) {
|
||||
ESP_LOGD(TAG, "Received Samsung36: address=0x%04X, command=0x%08X", data.address, data.command);
|
||||
ESP_LOGI(TAG, "Received Samsung36: address=0x%04X, command=0x%08X", data.address, data.command);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -58,7 +58,7 @@ optional<SamsungData> SamsungProtocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void SamsungProtocol::dump(const SamsungData &data) {
|
||||
ESP_LOGD(TAG, "Received Samsung: data=0x%" PRIX64 ", nbits=%d", data.data, data.nbits);
|
||||
ESP_LOGI(TAG, "Received Samsung: data=0x%" PRIX64 ", nbits=%d", data.data, data.nbits);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -62,7 +62,7 @@ optional<SonyData> SonyProtocol::decode(RemoteReceiveData src) {
|
||||
return out;
|
||||
}
|
||||
void SonyProtocol::dump(const SonyData &data) {
|
||||
ESP_LOGD(TAG, "Received Sony: data=0x%08X, nbits=%d", data.data, data.nbits);
|
||||
ESP_LOGI(TAG, "Received Sony: data=0x%08X, nbits=%d", data.data, data.nbits);
|
||||
}
|
||||
|
||||
} // namespace remote_base
|
||||
|
||||
@@ -105,9 +105,9 @@ optional<ToshibaAcData> ToshibaAcProtocol::decode(RemoteReceiveData src) {
|
||||
|
||||
void ToshibaAcProtocol::dump(const ToshibaAcData &data) {
|
||||
if (data.rc_code_2 != 0) {
|
||||
ESP_LOGD(TAG, "Received Toshiba AC: rc_code_1=0x%" PRIX64 ", rc_code_2=0x%" PRIX64, data.rc_code_1, data.rc_code_2);
|
||||
ESP_LOGI(TAG, "Received Toshiba AC: rc_code_1=0x%" PRIX64 ", rc_code_2=0x%" PRIX64, data.rc_code_1, data.rc_code_2);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Received Toshiba AC: rc_code_1=0x%" PRIX64, data.rc_code_1);
|
||||
ESP_LOGI(TAG, "Received Toshiba AC: rc_code_1=0x%" PRIX64, data.rc_code_1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ void Sensor::clear_filters() {
|
||||
}
|
||||
float Sensor::get_state() const { return this->state; }
|
||||
float Sensor::get_raw_state() const { return this->raw_state; }
|
||||
std::string Sensor::unique_id() { return ""; }
|
||||
|
||||
void Sensor::internal_send_state_to_frontend(float state) {
|
||||
this->has_state_ = true;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/components/sensor/filter.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/entity_base.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/components/sensor/filter.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace sensor {
|
||||
if (!(obj)->get_icon().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||
} \
|
||||
if (!(obj)->unique_id().empty()) { \
|
||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \
|
||||
} \
|
||||
if ((obj)->get_force_update()) { \
|
||||
ESP_LOGV(TAG, "%s Force Update: YES", prefix); \
|
||||
} \
|
||||
@@ -139,12 +136,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa
|
||||
/// Return whether this sensor has gotten a full state (that passed through all filters) yet.
|
||||
bool has_state() const;
|
||||
|
||||
/** Override this method to set the unique ID of this sensor.
|
||||
*
|
||||
* @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4).
|
||||
*/
|
||||
virtual std::string unique_id();
|
||||
|
||||
void internal_send_state_to_frontend(float state);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -87,25 +87,7 @@ class BSDSocketImpl : public Socket {
|
||||
int listen(int backlog) override { return ::listen(fd_, backlog); }
|
||||
ssize_t read(void *buf, size_t len) override { return ::read(fd_, buf, len); }
|
||||
ssize_t readv(const struct iovec *iov, int iovcnt) override {
|
||||
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 4
|
||||
// esp-idf v3 doesn't have readv, emulate it
|
||||
ssize_t ret = 0;
|
||||
for (int i = 0; i < iovcnt; i++) {
|
||||
ssize_t err = this->read(reinterpret_cast<uint8_t *>(iov[i].iov_base), iov[i].iov_len);
|
||||
if (err == -1) {
|
||||
if (ret != 0) {
|
||||
// if we already read some don't return an error
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
ret += err;
|
||||
if (err != iov[i].iov_len)
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
#elif defined(USE_ESP32)
|
||||
// ESP-IDF v4 only has symbol lwip_readv
|
||||
#if defined(USE_ESP32)
|
||||
return ::lwip_readv(fd_, iov, iovcnt);
|
||||
#else
|
||||
return ::readv(fd_, iov, iovcnt);
|
||||
@@ -114,26 +96,7 @@ class BSDSocketImpl : public Socket {
|
||||
ssize_t write(const void *buf, size_t len) override { return ::write(fd_, buf, len); }
|
||||
ssize_t send(void *buf, size_t len, int flags) { return ::send(fd_, buf, len, flags); }
|
||||
ssize_t writev(const struct iovec *iov, int iovcnt) override {
|
||||
#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 4
|
||||
// esp-idf v3 doesn't have writev, emulate it
|
||||
ssize_t ret = 0;
|
||||
for (int i = 0; i < iovcnt; i++) {
|
||||
ssize_t err =
|
||||
this->send(reinterpret_cast<uint8_t *>(iov[i].iov_base), iov[i].iov_len, i == iovcnt - 1 ? 0 : MSG_MORE);
|
||||
if (err == -1) {
|
||||
if (ret != 0) {
|
||||
// if we already wrote some don't return an error
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
ret += err;
|
||||
if (err != iov[i].iov_len)
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
#elif defined(USE_ESP32)
|
||||
// ESP-IDF v4 only has symbol lwip_writev
|
||||
#if defined(USE_ESP32)
|
||||
return ::lwip_writev(fd_, iov, iovcnt);
|
||||
#else
|
||||
return ::writev(fd_, iov, iovcnt);
|
||||
|
||||
@@ -23,7 +23,9 @@ SPI_DATA_RATE_OPTIONS = {
|
||||
40e6: SPIDataRate.DATA_RATE_40MHZ,
|
||||
20e6: SPIDataRate.DATA_RATE_20MHZ,
|
||||
10e6: SPIDataRate.DATA_RATE_10MHZ,
|
||||
8e6: SPIDataRate.DATA_RATE_8MHZ,
|
||||
5e6: SPIDataRate.DATA_RATE_5MHZ,
|
||||
4e6: SPIDataRate.DATA_RATE_4MHZ,
|
||||
2e6: SPIDataRate.DATA_RATE_2MHZ,
|
||||
1e6: SPIDataRate.DATA_RATE_1MHZ,
|
||||
2e5: SPIDataRate.DATA_RATE_200KHZ,
|
||||
|
||||
@@ -76,7 +76,8 @@ void SPIComponent::setup() {
|
||||
if (spi_bus_num == 0) {
|
||||
this->hw_spi_ = &SPI;
|
||||
} else {
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32C2) || defined(USE_ESP32_VARIANT_ESP32C6)
|
||||
this->hw_spi_ = new SPIClass(FSPI); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
#else
|
||||
this->hw_spi_ = new SPIClass(HSPI); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
|
||||
@@ -63,6 +63,7 @@ enum SPIDataRate : uint32_t {
|
||||
DATA_RATE_1MHZ = 1000000,
|
||||
DATA_RATE_2MHZ = 2000000,
|
||||
DATA_RATE_4MHZ = 4000000,
|
||||
DATA_RATE_5MHZ = 5000000,
|
||||
DATA_RATE_8MHZ = 8000000,
|
||||
DATA_RATE_10MHZ = 10000000,
|
||||
DATA_RATE_20MHZ = 20000000,
|
||||
|
||||
@@ -132,7 +132,7 @@ void SSD1306::setup() {
|
||||
this->command(SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME);
|
||||
|
||||
// Inverse display mode (0xA6, 0xA7)
|
||||
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
|
||||
this->set_invert(this->invert_);
|
||||
|
||||
// Disable scrolling mode (0x2E)
|
||||
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
||||
@@ -190,6 +190,12 @@ void SSD1306::update() {
|
||||
this->do_update_();
|
||||
this->display();
|
||||
}
|
||||
|
||||
void SSD1306::set_invert(bool invert) {
|
||||
this->invert_ = invert;
|
||||
// Inverse display mode (0xA6, 0xA7)
|
||||
this->command(SSD1306_COMMAND_NORMAL_DISPLAY | this->invert_);
|
||||
}
|
||||
void SSD1306::set_contrast(float contrast) {
|
||||
// validation
|
||||
this->contrast_ = clamp(contrast, 0.0F, 1.0F);
|
||||
|
||||
@@ -43,6 +43,7 @@ class SSD1306 : public PollingComponent, public display::DisplayBuffer {
|
||||
void init_offset_x(uint8_t offset_x) { this->offset_x_ = offset_x; }
|
||||
void init_offset_y(uint8_t offset_y) { this->offset_y_ = offset_y; }
|
||||
void init_invert(bool invert) { this->invert_ = invert; }
|
||||
void set_invert(bool invert);
|
||||
bool is_on();
|
||||
void turn_on();
|
||||
void turn_off();
|
||||
|
||||
@@ -19,6 +19,7 @@ void ST7789V::setup() {
|
||||
|
||||
this->write_command_(ST7789_SLPOUT); // Sleep out
|
||||
delay(120); // NOLINT
|
||||
this->write_command_(ST7789_SLPOUT); //
|
||||
|
||||
this->write_command_(ST7789_NORON); // Normal display mode on
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ void TextSensor::internal_send_state_to_frontend(const std::string &state) {
|
||||
this->callback_.call(state);
|
||||
}
|
||||
|
||||
std::string TextSensor::unique_id() { return ""; }
|
||||
bool TextSensor::has_state() { return this->has_state_; }
|
||||
|
||||
} // namespace text_sensor
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/text_sensor/filter.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/entity_base.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/components/text_sensor/filter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace text_sensor {
|
||||
if (!(obj)->get_icon().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||
} \
|
||||
if (!(obj)->unique_id().empty()) { \
|
||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SUB_TEXT_SENSOR(name) \
|
||||
@@ -58,12 +55,6 @@ class TextSensor : public EntityBase {
|
||||
|
||||
// ========== INTERNAL METHODS ==========
|
||||
// (In most use cases you won't need these)
|
||||
/** Override this method to set the unique ID of this sensor.
|
||||
*
|
||||
* @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4).
|
||||
*/
|
||||
virtual std::string unique_id();
|
||||
|
||||
bool has_state();
|
||||
|
||||
void internal_send_state_to_frontend(const std::string &state);
|
||||
|
||||
@@ -591,11 +591,11 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature,
|
||||
cv.Optional(
|
||||
CONF_SET_POINT_MINIMUM_DIFFERENTIAL, default=0.5
|
||||
): cv.temperature,
|
||||
cv.Optional(CONF_COOL_DEADBAND, default=0.5): cv.temperature,
|
||||
cv.Optional(CONF_COOL_OVERRUN, default=0.5): cv.temperature,
|
||||
cv.Optional(CONF_HEAT_DEADBAND, default=0.5): cv.temperature,
|
||||
cv.Optional(CONF_HEAT_OVERRUN, default=0.5): cv.temperature,
|
||||
): cv.temperature_delta,
|
||||
cv.Optional(CONF_COOL_DEADBAND, default=0.5): cv.temperature_delta,
|
||||
cv.Optional(CONF_COOL_OVERRUN, default=0.5): cv.temperature_delta,
|
||||
cv.Optional(CONF_HEAT_DEADBAND, default=0.5): cv.temperature_delta,
|
||||
cv.Optional(CONF_HEAT_OVERRUN, default=0.5): cv.temperature_delta,
|
||||
cv.Optional(CONF_MAX_COOLING_RUN_TIME): cv.positive_time_period_seconds,
|
||||
cv.Optional(CONF_MAX_HEATING_RUN_TIME): cv.positive_time_period_seconds,
|
||||
cv.Optional(CONF_MIN_COOLING_OFF_TIME): cv.positive_time_period_seconds,
|
||||
@@ -608,8 +608,8 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(CONF_MIN_HEATING_OFF_TIME): cv.positive_time_period_seconds,
|
||||
cv.Optional(CONF_MIN_HEATING_RUN_TIME): cv.positive_time_period_seconds,
|
||||
cv.Required(CONF_MIN_IDLE_TIME): cv.positive_time_period_seconds,
|
||||
cv.Optional(CONF_SUPPLEMENTAL_COOLING_DELTA): cv.temperature,
|
||||
cv.Optional(CONF_SUPPLEMENTAL_HEATING_DELTA): cv.temperature,
|
||||
cv.Optional(CONF_SUPPLEMENTAL_COOLING_DELTA): cv.temperature_delta,
|
||||
cv.Optional(CONF_SUPPLEMENTAL_HEATING_DELTA): cv.temperature_delta,
|
||||
cv.Optional(
|
||||
CONF_FAN_ONLY_ACTION_USES_FAN_MODE_TIMER, default=False
|
||||
): cv.boolean,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "uptime_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace uptime {
|
||||
@@ -26,7 +26,6 @@ void UptimeSensor::update() {
|
||||
const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f;
|
||||
this->publish_state(seconds);
|
||||
}
|
||||
std::string UptimeSensor::unique_id() { return get_mac_address() + "-uptime"; }
|
||||
float UptimeSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
|
||||
void UptimeSensor::dump_config() { LOG_SENSOR("", "Uptime Sensor", this); }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace uptime {
|
||||
@@ -13,8 +13,6 @@ class UptimeSensor : public sensor::Sensor, public PollingComponent {
|
||||
|
||||
float get_setup_priority() const override;
|
||||
|
||||
std::string unique_id() override;
|
||||
|
||||
protected:
|
||||
uint64_t uptime_{0};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "version_text_sensor.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/version.h"
|
||||
|
||||
namespace esphome {
|
||||
@@ -17,7 +17,6 @@ void VersionTextSensor::setup() {
|
||||
}
|
||||
float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }
|
||||
void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; }
|
||||
std::string VersionTextSensor::unique_id() { return get_mac_address() + "-version"; }
|
||||
void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); }
|
||||
|
||||
} // namespace version
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace version {
|
||||
@@ -12,7 +12,6 @@ class VersionTextSensor : public text_sensor::TextSensor, public Component {
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override;
|
||||
std::string unique_id() override;
|
||||
|
||||
protected:
|
||||
bool hide_timestamp_{false};
|
||||
|
||||
@@ -324,11 +324,7 @@ class WiFiComponent : public Component {
|
||||
#endif
|
||||
|
||||
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
|
||||
#else
|
||||
void wifi_event_callback_(system_event_id_t event, system_event_info_t info);
|
||||
#endif
|
||||
void wifi_scan_done_callback_();
|
||||
#endif
|
||||
#ifdef USE_ESP_IDF
|
||||
|
||||
@@ -203,12 +203,10 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
// Units: AP beacon intervals. Defaults to 3 if set to 0.
|
||||
conf.sta.listen_interval = 0;
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
// Protected Management Frame
|
||||
// Device will prefer to connect in PMF mode if other device also advertises PMF capability.
|
||||
conf.sta.pmf_cfg.capable = true;
|
||||
conf.sta.pmf_cfg.required = false;
|
||||
#endif
|
||||
|
||||
// note, we do our own filtering
|
||||
// The minimum rssi to accept in the fast scan mode
|
||||
@@ -314,11 +312,7 @@ const char *get_auth_mode_str(uint8_t mode) {
|
||||
}
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
using esphome_ip4_addr_t = esp_ip4_addr_t;
|
||||
#else
|
||||
using esphome_ip4_addr_t = ip4_addr_t;
|
||||
#endif
|
||||
|
||||
std::string format_ip4_addr(const esphome_ip4_addr_t &ip) {
|
||||
char buf[20];
|
||||
@@ -404,8 +398,6 @@ const char *get_disconnect_reason_str(uint8_t reason) {
|
||||
}
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
|
||||
#define ESPHOME_EVENT_ID_WIFI_READY ARDUINO_EVENT_WIFI_READY
|
||||
#define ESPHOME_EVENT_ID_WIFI_SCAN_DONE ARDUINO_EVENT_WIFI_SCAN_DONE
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_START ARDUINO_EVENT_WIFI_STA_START
|
||||
@@ -426,28 +418,6 @@ const char *get_disconnect_reason_str(uint8_t reason) {
|
||||
using esphome_wifi_event_id_t = arduino_event_id_t;
|
||||
using esphome_wifi_event_info_t = arduino_event_info_t;
|
||||
|
||||
#else // ESP_IDF_VERSION_MAJOR >= 4
|
||||
|
||||
#define ESPHOME_EVENT_ID_WIFI_READY SYSTEM_EVENT_WIFI_READY
|
||||
#define ESPHOME_EVENT_ID_WIFI_SCAN_DONE SYSTEM_EVENT_SCAN_DONE
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_START SYSTEM_EVENT_STA_START
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_STOP SYSTEM_EVENT_STA_STOP
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_CONNECTED SYSTEM_EVENT_STA_CONNECTED
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED SYSTEM_EVENT_STA_DISCONNECTED
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE SYSTEM_EVENT_STA_AUTHMODE_CHANGE
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_GOT_IP SYSTEM_EVENT_STA_GOT_IP
|
||||
#define ESPHOME_EVENT_ID_WIFI_STA_LOST_IP SYSTEM_EVENT_STA_LOST_IP
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_START SYSTEM_EVENT_AP_START
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_STOP SYSTEM_EVENT_AP_STOP
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED SYSTEM_EVENT_AP_STACONNECTED
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED SYSTEM_EVENT_AP_STADISCONNECTED
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_STAIPASSIGNED SYSTEM_EVENT_AP_STAIPASSIGNED
|
||||
#define ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED SYSTEM_EVENT_AP_PROBEREQRECVED
|
||||
using esphome_wifi_event_id_t = system_event_id_t;
|
||||
using esphome_wifi_event_info_t = system_event_info_t;
|
||||
|
||||
#endif // !(ESP_IDF_VERSION_MAJOR >= 4)
|
||||
|
||||
void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_wifi_event_info_t info) {
|
||||
switch (event) {
|
||||
case ESPHOME_EVENT_ID_WIFI_READY: {
|
||||
@@ -455,11 +425,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_SCAN_DONE: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_scan_done;
|
||||
#else
|
||||
auto it = info.scan_done;
|
||||
#endif
|
||||
ESP_LOGV(TAG, "Event: WiFi Scan Done status=%u number=%u scan_id=%u", it.status, it.number, it.scan_id);
|
||||
|
||||
this->wifi_scan_done_callback_();
|
||||
@@ -475,11 +441,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_STA_CONNECTED: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_sta_connected;
|
||||
#else
|
||||
auto it = info.connected;
|
||||
#endif
|
||||
char buf[33];
|
||||
memcpy(buf, it.ssid, it.ssid_len);
|
||||
buf[it.ssid_len] = '\0';
|
||||
@@ -492,11 +454,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_sta_disconnected;
|
||||
#else
|
||||
auto it = info.disconnected;
|
||||
#endif
|
||||
char buf[33];
|
||||
memcpy(buf, it.ssid, it.ssid_len);
|
||||
buf[it.ssid_len] = '\0';
|
||||
@@ -522,11 +480,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_sta_authmode_change;
|
||||
#else
|
||||
auto it = info.auth_change;
|
||||
#endif
|
||||
ESP_LOGV(TAG, "Event: Authmode Change old=%s new=%s", get_auth_mode_str(it.old_mode),
|
||||
get_auth_mode_str(it.new_mode));
|
||||
// Mitigate CVE-2020-12638
|
||||
@@ -570,24 +524,14 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_sta_connected;
|
||||
auto &mac = it.bssid;
|
||||
#else
|
||||
auto it = info.sta_connected;
|
||||
auto &mac = it.mac;
|
||||
#endif
|
||||
ESP_LOGV(TAG, "Event: AP client connected MAC=%s", format_mac_addr(mac).c_str());
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_sta_disconnected;
|
||||
auto &mac = it.bssid;
|
||||
#else
|
||||
auto it = info.sta_disconnected;
|
||||
auto &mac = it.mac;
|
||||
#endif
|
||||
ESP_LOGV(TAG, "Event: AP client disconnected MAC=%s", format_mac_addr(mac).c_str());
|
||||
break;
|
||||
}
|
||||
@@ -596,11 +540,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
|
||||
break;
|
||||
}
|
||||
case ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED: {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
auto it = info.wifi_ap_probereqrecved;
|
||||
#else
|
||||
auto it = info.ap_probereqrecved;
|
||||
#endif
|
||||
ESP_LOGVV(TAG, "Event: AP receive Probe Request MAC=%s RSSI=%d", format_mac_addr(it.mac).c_str(), it.rssi);
|
||||
break;
|
||||
}
|
||||
@@ -742,10 +682,7 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||
strncpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), sizeof(conf.ap.ssid));
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
||||
conf.ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
|
||||
#endif
|
||||
|
||||
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
|
||||
if (err != ESP_OK) {
|
||||
|
||||
@@ -312,12 +312,10 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||
// Units: AP beacon intervals. Defaults to 3 if set to 0.
|
||||
conf.sta.listen_interval = 0;
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
// Protected Management Frame
|
||||
// Device will prefer to connect in PMF mode if other device also advertises PMF capability.
|
||||
conf.sta.pmf_cfg.capable = true;
|
||||
conf.sta.pmf_cfg.required = false;
|
||||
#endif
|
||||
|
||||
// note, we do our own filtering
|
||||
// The minimum rssi to accept in the fast scan mode
|
||||
@@ -838,10 +836,8 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||
strncpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), sizeof(conf.ap.password));
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4
|
||||
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
||||
conf.ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
|
||||
#endif
|
||||
|
||||
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
|
||||
if (err != ESP_OK) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/text_sensor/text_sensor.h"
|
||||
#include "esphome/components/wifi/wifi_component.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace wifi_info {
|
||||
@@ -17,7 +17,6 @@ class IPAddressWiFiInfo : public PollingComponent, public text_sensor::TextSenso
|
||||
}
|
||||
}
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-ip"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
@@ -43,7 +42,6 @@ class DNSAddressWifiInfo : public PollingComponent, public text_sensor::TextSens
|
||||
}
|
||||
}
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-dns"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
@@ -72,7 +70,6 @@ class ScanResultsWiFiInfo : public PollingComponent, public text_sensor::TextSen
|
||||
}
|
||||
}
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-scanresults"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
@@ -89,7 +86,6 @@ class SSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
||||
}
|
||||
}
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-ssid"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
@@ -108,7 +104,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
||||
}
|
||||
}
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-bssid"; }
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
@@ -118,7 +113,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
||||
class MacAddressWifiInfo : public Component, public text_sensor::TextSensor {
|
||||
public:
|
||||
void setup() override { this->publish_state(get_mac_address_pretty()); }
|
||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-macadr"; }
|
||||
void dump_config() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/wifi/wifi_component.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace wifi_signal {
|
||||
@@ -12,8 +12,6 @@ class WiFiSignalSensor : public sensor::Sensor, public PollingComponent {
|
||||
public:
|
||||
void update() override { this->publish_state(wifi::global_wifi_component->wifi_rssi()); }
|
||||
void dump_config() override;
|
||||
|
||||
std::string unique_id() override { return get_mac_address() + "-wifisignal"; }
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
};
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ RESERVED_IDS = [
|
||||
"char16_t",
|
||||
"char32_t",
|
||||
"class",
|
||||
"clock",
|
||||
"compl",
|
||||
"concept",
|
||||
"const",
|
||||
@@ -928,6 +929,27 @@ def temperature(value):
|
||||
raise err
|
||||
|
||||
|
||||
def temperature_delta(value):
|
||||
err = None
|
||||
try:
|
||||
return _temperature_c(value)
|
||||
except Invalid as orig_err:
|
||||
err = orig_err
|
||||
|
||||
try:
|
||||
return _temperature_k(value)
|
||||
except Invalid:
|
||||
pass
|
||||
|
||||
try:
|
||||
fahrenheit = _temperature_f(value)
|
||||
return fahrenheit * (5 / 9)
|
||||
except Invalid:
|
||||
pass
|
||||
|
||||
raise err
|
||||
|
||||
|
||||
_color_temperature_mireds = float_with_unit("Color Temperature", r"(mireds|Mireds)")
|
||||
_color_temperature_kelvin = float_with_unit("Color Temperature", r"(K|Kelvin)")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2023.8.1"
|
||||
__version__ = "2023.9.0-dev"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
||||
@@ -868,9 +868,6 @@ class PingStatusThread(threading.Thread):
|
||||
entries = _list_dashboard_entries()
|
||||
queue = collections.deque()
|
||||
for entry in entries:
|
||||
if entry.no_mdns is True:
|
||||
continue
|
||||
|
||||
if entry.address is None:
|
||||
PING_RESULT[entry.filename] = None
|
||||
continue
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import logging
|
||||
import socket
|
||||
import threading
|
||||
import time
|
||||
from typing import Optional
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
from zeroconf import (
|
||||
DNSAddress,
|
||||
DNSOutgoing,
|
||||
DNSRecord,
|
||||
DNSQuestion,
|
||||
RecordUpdate,
|
||||
RecordUpdateListener,
|
||||
Zeroconf,
|
||||
ServiceBrowser,
|
||||
ServiceStateChange,
|
||||
Zeroconf,
|
||||
current_time_millis,
|
||||
)
|
||||
|
||||
@@ -24,17 +24,28 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HostResolver(RecordUpdateListener):
|
||||
"""Resolve a host name to an IP address."""
|
||||
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
self.address: Optional[bytes] = None
|
||||
|
||||
def update_record(self, zc: Zeroconf, now: float, record: DNSRecord) -> None:
|
||||
if record is None:
|
||||
return
|
||||
if record.type == _TYPE_A:
|
||||
assert isinstance(record, DNSAddress)
|
||||
if record.name == self.name:
|
||||
self.address = record.address
|
||||
def async_update_records(
|
||||
self, zc: Zeroconf, now: float, records: list[RecordUpdate]
|
||||
) -> None:
|
||||
"""Update multiple records in one shot.
|
||||
|
||||
This will run in zeroconf's event loop thread so it
|
||||
must be thread-safe.
|
||||
"""
|
||||
for record_update in records:
|
||||
record, _ = record_update
|
||||
if record is None:
|
||||
continue
|
||||
if record.type == _TYPE_A:
|
||||
assert isinstance(record, DNSAddress)
|
||||
if record.name == self.name:
|
||||
self.address = record.address
|
||||
|
||||
def request(self, zc: Zeroconf, timeout: float) -> bool:
|
||||
now = time.time()
|
||||
|
||||
@@ -64,7 +64,7 @@ lib_deps =
|
||||
glmnet/Dsmr@0.7 ; dsmr
|
||||
rweather/Crypto@0.4.0 ; dsmr
|
||||
dudanov/MideaUART@1.1.8 ; midea
|
||||
tonia/HeatpumpIR@1.0.20 ; heatpumpir
|
||||
tonia/HeatpumpIR@1.0.23 ; heatpumpir
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
-DUSE_ARDUINO
|
||||
|
||||
@@ -6,12 +6,12 @@ tornado==6.3.2
|
||||
tzlocal==5.0.1 # from time
|
||||
tzdata>=2021.1 # from time
|
||||
pyserial==3.5
|
||||
platformio==6.1.9 # When updating platformio, also update Dockerfile
|
||||
platformio==6.1.10 # When updating platformio, also update Dockerfile
|
||||
esptool==4.6.2
|
||||
click==8.1.6
|
||||
click==8.1.7
|
||||
esphome-dashboard==20230711.0
|
||||
aioesphomeapi==15.0.0
|
||||
zeroconf==0.80.0
|
||||
zeroconf==0.86.0
|
||||
|
||||
# esp-idf requires this, but doesn't bundle it by default
|
||||
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24
|
||||
|
||||
@@ -348,6 +348,16 @@ mcp23s17:
|
||||
deviceaddress: 1
|
||||
|
||||
sensor:
|
||||
- platform: pmwcs3
|
||||
i2c_id: i2c_bus
|
||||
e25:
|
||||
name: pmwcs3_e25
|
||||
ec:
|
||||
name: pmwcs3_ec
|
||||
temperature:
|
||||
name: pmwcs3_temperature
|
||||
vwc:
|
||||
name: pmwcs3_vwc
|
||||
- platform: gcja5
|
||||
pm_1_0:
|
||||
name: "Particulate Matter <1.0µm Concentration"
|
||||
@@ -2289,6 +2299,13 @@ climate:
|
||||
name: HeatpumpIR Climate
|
||||
min_temperature: 18
|
||||
max_temperature: 30
|
||||
- platform: heatpumpir
|
||||
protocol: greeyt
|
||||
horizontal_default: left
|
||||
vertical_default: up
|
||||
name: HeatpumpIR Climate
|
||||
min_temperature: 18
|
||||
max_temperature: 30
|
||||
- platform: midea_ir
|
||||
name: Midea IR
|
||||
use_fahrenheit: true
|
||||
|
||||
@@ -768,3 +768,8 @@ switch:
|
||||
characteristic_uuid: 6490FAFE-0734-732C-8705-91B653A081FC
|
||||
value: !lambda |-
|
||||
return {0x13, 0x37};
|
||||
|
||||
|
||||
esp32_ble_server:
|
||||
id: ble
|
||||
manufacturer_data: [0x72, 0x4, 0x00, 0x23]
|
||||
|
||||
Reference in New Issue
Block a user