mirror of
https://github.com/esphome/esphome.git
synced 2026-08-17 10:52:56 +08:00
[midea] Add ESP-IDF framework support (#12646)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jonathan Swoboda
Claude Opus 4.6
parent
66db4fdd61
commit
0b34c97742
@@ -1,4 +1,4 @@
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
#include "ac_adapter.h"
|
||||
@@ -172,4 +172,4 @@ void Converters::to_climate_traits(ClimateTraits &traits, const dudanov::midea::
|
||||
|
||||
} // namespace esphome::midea::ac
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
// MideaUART
|
||||
#include <Appliance/AirConditioner/AirConditioner.h>
|
||||
@@ -44,4 +44,4 @@ class Converters {
|
||||
|
||||
} // namespace esphome::midea::ac
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
#include "esphome/core/automation.h"
|
||||
#include "air_conditioner.h"
|
||||
@@ -63,4 +63,4 @@ template<typename... Ts> class PowerToggleAction : public MideaActionBase<Ts...>
|
||||
|
||||
} // namespace esphome::midea::ac
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
@@ -197,4 +197,4 @@ void AirConditioner::do_display_toggle() {
|
||||
|
||||
} // namespace esphome::midea::ac
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
// MideaUART
|
||||
#include <Appliance/AirConditioner/AirConditioner.h>
|
||||
@@ -61,4 +61,4 @@ class AirConditioner final : public ApplianceBase<dudanov::midea::ac::AirConditi
|
||||
|
||||
} // namespace esphome::midea::ac
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
|
||||
// MideaUART
|
||||
#include <Appliance/ApplianceBase.h>
|
||||
#include <Helpers/Logger.h>
|
||||
#include <Helpers/Platform.h>
|
||||
|
||||
// Include global defines
|
||||
#include "esphome/core/defines.h"
|
||||
@@ -99,4 +100,4 @@ template<typename T> class ApplianceBase : public Component {
|
||||
|
||||
} // namespace esphome::midea
|
||||
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
@@ -153,7 +153,6 @@ CONFIG_SCHEMA = cv.All(
|
||||
)
|
||||
.extend(uart.UART_DEVICE_SCHEMA)
|
||||
.extend(cv.COMPONENT_SCHEMA),
|
||||
cv.only_with_arduino,
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
@@ -305,7 +304,14 @@ async def to_code(config):
|
||||
if CONF_HUMIDITY_SETPOINT in config:
|
||||
sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT])
|
||||
cg.add(var.set_humidity_setpoint_sensor(sens))
|
||||
# MideaUART library requires WiFi (WiFi auto-enables Network via dependency mapping)
|
||||
if CORE.is_esp32:
|
||||
# MideaUART uses the Arduino WiFi API for the network-notify frame
|
||||
# (WiFi auto-enables Network via dependency mapping). On ESP-IDF the
|
||||
# library talks to esp_wifi directly, so no library entry is needed.
|
||||
if CORE.is_esp32 and CORE.using_arduino:
|
||||
cg.add_library("WiFi", None)
|
||||
cg.add_library("dudanov/MideaUART", "1.1.9")
|
||||
# Using the repository until a release containing ESP-IDF support is published
|
||||
cg.add_library(
|
||||
name="MideaUART",
|
||||
version=None,
|
||||
repository="https://github.com/dudanov/MideaUART.git#7a4d1e9a4b6f07a3464c2453ee828c0c7b7e1bcf",
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)
|
||||
#if (defined(USE_ARDUINO) && !defined(USE_RP2) && !defined(USE_LIBRETINY)) || defined(USE_ESP_IDF)
|
||||
#ifdef USE_REMOTE_TRANSMITTER
|
||||
#include "esphome/components/remote_base/midea_protocol.h"
|
||||
|
||||
@@ -85,5 +85,5 @@ class IrTransmitter {
|
||||
|
||||
} // namespace esphome::midea
|
||||
|
||||
#endif
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_REMOTE_TRANSMITTER
|
||||
#endif // USE_ARDUINO || USE_ESP_IDF
|
||||
|
||||
+1
-1
@@ -44,6 +44,7 @@ lib_deps_base =
|
||||
|
||||
lib_deps =
|
||||
${common.lib_deps_base}
|
||||
https://github.com/dudanov/MideaUART.git#7a4d1e9a4b6f07a3464c2453ee828c0c7b7e1bcf ; midea
|
||||
esphome/noise-c@0.1.11 ; api
|
||||
improv/Improv@1.2.6 ; improv_serial / esp32_improv
|
||||
kikuchan98/pngle@1.1.0 ; online_image
|
||||
@@ -80,7 +81,6 @@ lib_deps =
|
||||
Wire ; i2c (Arduino built-int)
|
||||
heman/AsyncMqttClient-esphome@1.0.0 ; mqtt
|
||||
freekode/TM1651@1.0.1 ; tm1651
|
||||
dudanov/MideaUART@1.1.9 ; midea
|
||||
tonia/HeatpumpIR@1.0.42 ; heatpumpir
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
climate:
|
||||
- platform: midea
|
||||
id: midea_unit
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-ard.yaml
|
||||
uart: !include ../../test_build_components/common/uart/esp32-ard.yaml
|
||||
midea: !include common.yaml
|
||||
|
||||
<<: !include common.yaml
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# ESP32-H2 has no WiFi PHY; this verifies the component builds without wifi
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
uart: !include ../../test_build_components/common/uart/esp32-h2-idf.yaml
|
||||
midea: !include common.yaml
|
||||
@@ -0,0 +1,8 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
uart: !include ../../test_build_components/common/uart/esp32-idf.yaml
|
||||
midea: !include common.yaml
|
||||
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
@@ -1,5 +1,8 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||
uart: !include ../../test_build_components/common/uart/esp8266-ard.yaml
|
||||
midea: !include common.yaml
|
||||
|
||||
<<: !include common.yaml
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Common UART configuration for ESP32-H2 IDF tests
|
||||
# Provides a shared UART bus that components can use
|
||||
# Components will auto-use this bus if they don't specify uart_id
|
||||
|
||||
substitutions:
|
||||
tx_pin: GPIO12
|
||||
rx_pin: GPIO13
|
||||
|
||||
uart:
|
||||
- id: uart_bus
|
||||
tx_pin: ${tx_pin}
|
||||
rx_pin: ${rx_pin}
|
||||
baud_rate: 9600
|
||||
Reference in New Issue
Block a user