mirror of
https://github.com/esphome/esphome.git
synced 2025-10-23 12:13:49 +01:00
Merge remote-tracking branch 'upstream/unbound_queued_script_fix' into unbound_queued_script_fix
This commit is contained in:
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
@@ -58,7 +58,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
|
uses: github/codeql-action/init@16140ae1a102900babc80a33c44059580f687047 # v4.30.9
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
build-mode: ${{ matrix.build-mode }}
|
build-mode: ${{ matrix.build-mode }}
|
||||||
@@ -86,6 +86,6 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
|
uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 # v4.30.9
|
||||||
with:
|
with:
|
||||||
category: "/language:${{matrix.language}}"
|
category: "/language:${{matrix.language}}"
|
||||||
|
@@ -62,6 +62,7 @@ esphome/components/bedjet/fan/* @jhansche
|
|||||||
esphome/components/bedjet/sensor/* @javawizard @jhansche
|
esphome/components/bedjet/sensor/* @javawizard @jhansche
|
||||||
esphome/components/beken_spi_led_strip/* @Mat931
|
esphome/components/beken_spi_led_strip/* @Mat931
|
||||||
esphome/components/bh1750/* @OttoWinter
|
esphome/components/bh1750/* @OttoWinter
|
||||||
|
esphome/components/bh1900nux/* @B48D81EFCC
|
||||||
esphome/components/binary_sensor/* @esphome/core
|
esphome/components/binary_sensor/* @esphome/core
|
||||||
esphome/components/bk72xx/* @kuba2k2
|
esphome/components/bk72xx/* @kuba2k2
|
||||||
esphome/components/bl0906/* @athom-tech @jesserockz @tarontop
|
esphome/components/bl0906/* @athom-tech @jesserockz @tarontop
|
||||||
|
@@ -661,11 +661,12 @@ uint16_t APIConnection::try_send_climate_info(EntityBase *entity, APIConnection
|
|||||||
ListEntitiesClimateResponse msg;
|
ListEntitiesClimateResponse msg;
|
||||||
auto traits = climate->get_traits();
|
auto traits = climate->get_traits();
|
||||||
// Flags set for backward compatibility, deprecated in 2025.11.0
|
// Flags set for backward compatibility, deprecated in 2025.11.0
|
||||||
msg.supports_current_temperature = traits.get_supports_current_temperature();
|
msg.supports_current_temperature = traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE);
|
||||||
msg.supports_current_humidity = traits.get_supports_current_humidity();
|
msg.supports_current_humidity = traits.has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY);
|
||||||
msg.supports_two_point_target_temperature = traits.get_supports_two_point_target_temperature();
|
msg.supports_two_point_target_temperature = traits.has_feature_flags(
|
||||||
msg.supports_target_humidity = traits.get_supports_target_humidity();
|
climate::CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE | climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE);
|
||||||
msg.supports_action = traits.get_supports_action();
|
msg.supports_target_humidity = traits.has_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY);
|
||||||
|
msg.supports_action = traits.has_feature_flags(climate::CLIMATE_SUPPORTS_ACTION);
|
||||||
// Current feature flags and other supported parameters
|
// Current feature flags and other supported parameters
|
||||||
msg.feature_flags = traits.get_feature_flags();
|
msg.feature_flags = traits.get_feature_flags();
|
||||||
msg.supported_modes = &traits.get_supported_modes_for_api_();
|
msg.supported_modes = &traits.get_supported_modes_for_api_();
|
||||||
|
0
esphome/components/bh1900nux/__init__.py
Normal file
0
esphome/components/bh1900nux/__init__.py
Normal file
54
esphome/components/bh1900nux/bh1900nux.cpp
Normal file
54
esphome/components/bh1900nux/bh1900nux.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include "esphome/core/log.h"
|
||||||
|
#include "bh1900nux.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace bh1900nux {
|
||||||
|
|
||||||
|
static const char *const TAG = "bh1900nux.sensor";
|
||||||
|
|
||||||
|
// I2C Registers
|
||||||
|
static const uint8_t TEMPERATURE_REG = 0x00;
|
||||||
|
static const uint8_t CONFIG_REG = 0x01; // Not used and supported yet
|
||||||
|
static const uint8_t TEMPERATURE_LOW_REG = 0x02; // Not used and supported yet
|
||||||
|
static const uint8_t TEMPERATURE_HIGH_REG = 0x03; // Not used and supported yet
|
||||||
|
static const uint8_t SOFT_RESET_REG = 0x04;
|
||||||
|
|
||||||
|
// I2C Command payloads
|
||||||
|
static const uint8_t SOFT_RESET_PAYLOAD = 0x01; // Soft Reset value
|
||||||
|
|
||||||
|
static const float SENSOR_RESOLUTION = 0.0625f; // Sensor resolution per bit in degrees celsius
|
||||||
|
|
||||||
|
void BH1900NUXSensor::setup() {
|
||||||
|
// Initialize I2C device
|
||||||
|
i2c::ErrorCode result_code =
|
||||||
|
this->write_register(SOFT_RESET_REG, &SOFT_RESET_PAYLOAD, 1); // Software Reset to check communication
|
||||||
|
if (result_code != i2c::ERROR_OK) {
|
||||||
|
this->mark_failed(ESP_LOG_MSG_COMM_FAIL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BH1900NUXSensor::update() {
|
||||||
|
uint8_t temperature_raw[2];
|
||||||
|
if (this->read_register(TEMPERATURE_REG, temperature_raw, 2) != i2c::ERROR_OK) {
|
||||||
|
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combined raw value, unsigned and unaligned 16 bit
|
||||||
|
// Temperature is represented in just 12 bits, shift needed
|
||||||
|
int16_t raw_temperature_register_value = encode_uint16(temperature_raw[0], temperature_raw[1]);
|
||||||
|
raw_temperature_register_value >>= 4;
|
||||||
|
float temperature_value = raw_temperature_register_value * SENSOR_RESOLUTION; // Apply sensor resolution
|
||||||
|
|
||||||
|
this->publish_state(temperature_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BH1900NUXSensor::dump_config() {
|
||||||
|
LOG_SENSOR("", "BH1900NUX", this);
|
||||||
|
LOG_I2C_DEVICE(this);
|
||||||
|
LOG_UPDATE_INTERVAL(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace bh1900nux
|
||||||
|
} // namespace esphome
|
18
esphome/components/bh1900nux/bh1900nux.h
Normal file
18
esphome/components/bh1900nux/bh1900nux.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/components/sensor/sensor.h"
|
||||||
|
#include "esphome/components/i2c/i2c.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace bh1900nux {
|
||||||
|
|
||||||
|
class BH1900NUXSensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
||||||
|
public:
|
||||||
|
void setup() override;
|
||||||
|
void update() override;
|
||||||
|
void dump_config() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace bh1900nux
|
||||||
|
} // namespace esphome
|
34
esphome/components/bh1900nux/sensor.py
Normal file
34
esphome/components/bh1900nux/sensor.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import esphome.codegen as cg
|
||||||
|
from esphome.components import i2c, sensor
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.const import (
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
UNIT_CELSIUS,
|
||||||
|
)
|
||||||
|
|
||||||
|
DEPENDENCIES = ["i2c"]
|
||||||
|
CODEOWNERS = ["@B48D81EFCC"]
|
||||||
|
|
||||||
|
sensor_ns = cg.esphome_ns.namespace("bh1900nux")
|
||||||
|
BH1900NUXSensor = sensor_ns.class_(
|
||||||
|
"BH1900NUXSensor", cg.PollingComponent, i2c.I2CDevice
|
||||||
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = (
|
||||||
|
sensor.sensor_schema(
|
||||||
|
BH1900NUXSensor,
|
||||||
|
accuracy_decimals=1,
|
||||||
|
unit_of_measurement=UNIT_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
)
|
||||||
|
.extend(cv.polling_component_schema("60s"))
|
||||||
|
.extend(i2c.i2c_device_schema(0x48))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def to_code(config):
|
||||||
|
var = await sensor.new_sensor(config)
|
||||||
|
await cg.register_component(var, config)
|
||||||
|
await i2c.register_i2c_device(var, config)
|
@@ -41,7 +41,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Schema(
|
cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(BME680BSECComponent),
|
cv.GenerateID(): cv.declare_id(BME680BSECComponent),
|
||||||
cv.Optional(CONF_TEMPERATURE_OFFSET, default=0): cv.temperature,
|
cv.Optional(CONF_TEMPERATURE_OFFSET, default=0): cv.temperature_delta,
|
||||||
cv.Optional(CONF_IAQ_MODE, default="STATIC"): cv.enum(
|
cv.Optional(CONF_IAQ_MODE, default="STATIC"): cv.enum(
|
||||||
IAQ_MODE_OPTIONS, upper=True
|
IAQ_MODE_OPTIONS, upper=True
|
||||||
),
|
),
|
||||||
|
@@ -139,7 +139,7 @@ CONFIG_SCHEMA_BASE = (
|
|||||||
cv.Optional(CONF_SUPPLY_VOLTAGE, default="3.3V"): cv.enum(
|
cv.Optional(CONF_SUPPLY_VOLTAGE, default="3.3V"): cv.enum(
|
||||||
VOLTAGE_OPTIONS, upper=True
|
VOLTAGE_OPTIONS, upper=True
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TEMPERATURE_OFFSET, default=0): cv.temperature,
|
cv.Optional(CONF_TEMPERATURE_OFFSET, default=0): cv.temperature_delta,
|
||||||
cv.Optional(
|
cv.Optional(
|
||||||
CONF_STATE_SAVE_INTERVAL, default="6hours"
|
CONF_STATE_SAVE_INTERVAL, default="6hours"
|
||||||
): cv.positive_time_period_minutes,
|
): cv.positive_time_period_minutes,
|
||||||
|
@@ -8,17 +8,30 @@ namespace cap1188 {
|
|||||||
static const char *const TAG = "cap1188";
|
static const char *const TAG = "cap1188";
|
||||||
|
|
||||||
void CAP1188Component::setup() {
|
void CAP1188Component::setup() {
|
||||||
// Reset device using the reset pin
|
this->disable_loop();
|
||||||
if (this->reset_pin_ != nullptr) {
|
|
||||||
this->reset_pin_->setup();
|
// no reset pin
|
||||||
this->reset_pin_->digital_write(false);
|
if (this->reset_pin_ == nullptr) {
|
||||||
delay(100); // NOLINT
|
this->finish_setup_();
|
||||||
this->reset_pin_->digital_write(true);
|
return;
|
||||||
delay(100); // NOLINT
|
|
||||||
this->reset_pin_->digital_write(false);
|
|
||||||
delay(100); // NOLINT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset pin configured so reset before finishing setup
|
||||||
|
this->reset_pin_->setup();
|
||||||
|
this->reset_pin_->digital_write(false);
|
||||||
|
// delay after reset pin write
|
||||||
|
this->set_timeout(100, [this]() {
|
||||||
|
this->reset_pin_->digital_write(true);
|
||||||
|
// delay after reset pin write
|
||||||
|
this->set_timeout(100, [this]() {
|
||||||
|
this->reset_pin_->digital_write(false);
|
||||||
|
// delay after reset pin write
|
||||||
|
this->set_timeout(100, [this]() { this->finish_setup_(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAP1188Component::finish_setup_() {
|
||||||
// Check if CAP1188 is actually connected
|
// Check if CAP1188 is actually connected
|
||||||
this->read_byte(CAP1188_PRODUCT_ID, &this->cap1188_product_id_);
|
this->read_byte(CAP1188_PRODUCT_ID, &this->cap1188_product_id_);
|
||||||
this->read_byte(CAP1188_MANUFACTURE_ID, &this->cap1188_manufacture_id_);
|
this->read_byte(CAP1188_MANUFACTURE_ID, &this->cap1188_manufacture_id_);
|
||||||
@@ -44,6 +57,9 @@ void CAP1188Component::setup() {
|
|||||||
|
|
||||||
// Speed up a bit
|
// Speed up a bit
|
||||||
this->write_byte(CAP1188_STAND_BY_CONFIGURATION, 0x30);
|
this->write_byte(CAP1188_STAND_BY_CONFIGURATION, 0x30);
|
||||||
|
|
||||||
|
// Setup successful, so enable loop
|
||||||
|
this->enable_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAP1188Component::dump_config() {
|
void CAP1188Component::dump_config() {
|
||||||
|
@@ -49,6 +49,8 @@ class CAP1188Component : public Component, public i2c::I2CDevice {
|
|||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void finish_setup_();
|
||||||
|
|
||||||
std::vector<CAP1188Channel *> channels_{};
|
std::vector<CAP1188Channel *> channels_{};
|
||||||
uint8_t touch_threshold_{0x20};
|
uint8_t touch_threshold_{0x20};
|
||||||
uint8_t allow_multiple_touches_{0x80};
|
uint8_t allow_multiple_touches_{0x80};
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
#include <esp_chip_info.h>
|
#include <esp_chip_info.h>
|
||||||
#include <esp_partition.h>
|
#include <esp_partition.h>
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
#include <Esp.h>
|
#include <Esp.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -125,7 +123,12 @@ void DebugComponent::log_partition_info_() {
|
|||||||
|
|
||||||
uint32_t DebugComponent::get_free_heap_() { return heap_caps_get_free_size(MALLOC_CAP_INTERNAL); }
|
uint32_t DebugComponent::get_free_heap_() { return heap_caps_get_free_size(MALLOC_CAP_INTERNAL); }
|
||||||
|
|
||||||
static const std::map<int, const char *> CHIP_FEATURES = {
|
struct ChipFeature {
|
||||||
|
int bit;
|
||||||
|
const char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr ChipFeature CHIP_FEATURES[] = {
|
||||||
{CHIP_FEATURE_BLE, "BLE"},
|
{CHIP_FEATURE_BLE, "BLE"},
|
||||||
{CHIP_FEATURE_BT, "BT"},
|
{CHIP_FEATURE_BT, "BT"},
|
||||||
{CHIP_FEATURE_EMB_FLASH, "EMB Flash"},
|
{CHIP_FEATURE_EMB_FLASH, "EMB Flash"},
|
||||||
@@ -170,11 +173,13 @@ void DebugComponent::get_device_info_(std::string &device_info) {
|
|||||||
esp_chip_info(&info);
|
esp_chip_info(&info);
|
||||||
const char *model = ESPHOME_VARIANT;
|
const char *model = ESPHOME_VARIANT;
|
||||||
std::string features;
|
std::string features;
|
||||||
for (auto feature : CHIP_FEATURES) {
|
|
||||||
if (info.features & feature.first) {
|
// Check each known feature bit
|
||||||
features += feature.second;
|
for (const auto &feature : CHIP_FEATURES) {
|
||||||
|
if (info.features & feature.bit) {
|
||||||
|
features += feature.name;
|
||||||
features += ", ";
|
features += ", ";
|
||||||
info.features &= ~feature.first;
|
info.features &= ~feature.bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.features != 0)
|
if (info.features != 0)
|
||||||
|
@@ -25,10 +25,37 @@ static void show_reset_reason(std::string &reset_reason, bool set, const char *r
|
|||||||
reset_reason += reason;
|
reset_reason += reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t read_mem_u32(uintptr_t addr) {
|
static inline uint32_t read_mem_u32(uintptr_t addr) {
|
||||||
return *reinterpret_cast<volatile uint32_t *>(addr); // NOLINT(performance-no-int-to-ptr)
|
return *reinterpret_cast<volatile uint32_t *>(addr); // NOLINT(performance-no-int-to-ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint8_t read_mem_u8(uintptr_t addr) {
|
||||||
|
return *reinterpret_cast<volatile uint8_t *>(addr); // NOLINT(performance-no-int-to-ptr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// defines from https://github.com/adafruit/Adafruit_nRF52_Bootloader which prints those information
|
||||||
|
constexpr uint32_t SD_MAGIC_NUMBER = 0x51B1E5DB;
|
||||||
|
constexpr uintptr_t MBR_SIZE = 0x1000;
|
||||||
|
constexpr uintptr_t SOFTDEVICE_INFO_STRUCT_OFFSET = 0x2000;
|
||||||
|
constexpr uintptr_t SD_ID_OFFSET = SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10;
|
||||||
|
constexpr uintptr_t SD_VERSION_OFFSET = SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14;
|
||||||
|
|
||||||
|
static inline bool is_sd_present() {
|
||||||
|
return read_mem_u32(SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE + 4) == SD_MAGIC_NUMBER;
|
||||||
|
}
|
||||||
|
static inline uint32_t sd_id_get() {
|
||||||
|
if (read_mem_u8(MBR_SIZE + SOFTDEVICE_INFO_STRUCT_OFFSET) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) {
|
||||||
|
return read_mem_u32(MBR_SIZE + SD_ID_OFFSET);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static inline uint32_t sd_version_get() {
|
||||||
|
if (read_mem_u8(MBR_SIZE + SOFTDEVICE_INFO_STRUCT_OFFSET) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) {
|
||||||
|
return read_mem_u32(MBR_SIZE + SD_VERSION_OFFSET);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::string DebugComponent::get_reset_reason_() {
|
std::string DebugComponent::get_reset_reason_() {
|
||||||
uint32_t cause;
|
uint32_t cause;
|
||||||
auto ret = hwinfo_get_reset_cause(&cause);
|
auto ret = hwinfo_get_reset_cause(&cause);
|
||||||
@@ -271,6 +298,29 @@ void DebugComponent::get_device_info_(std::string &device_info) {
|
|||||||
NRF_UICR->NRFFW[0]);
|
NRF_UICR->NRFFW[0]);
|
||||||
ESP_LOGD(TAG, "MBR param page addr 0x%08x, UICR param page addr 0x%08x", read_mem_u32(MBR_PARAM_PAGE_ADDR),
|
ESP_LOGD(TAG, "MBR param page addr 0x%08x, UICR param page addr 0x%08x", read_mem_u32(MBR_PARAM_PAGE_ADDR),
|
||||||
NRF_UICR->NRFFW[1]);
|
NRF_UICR->NRFFW[1]);
|
||||||
|
if (is_sd_present()) {
|
||||||
|
uint32_t const sd_id = sd_id_get();
|
||||||
|
uint32_t const sd_version = sd_version_get();
|
||||||
|
|
||||||
|
uint32_t ver[3];
|
||||||
|
ver[0] = sd_version / 1000000;
|
||||||
|
ver[1] = (sd_version - ver[0] * 1000000) / 1000;
|
||||||
|
ver[2] = (sd_version - ver[0] * 1000000 - ver[1] * 1000);
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "SoftDevice: S%u %u.%u.%u", sd_id, ver[0], ver[1], ver[2]);
|
||||||
|
#ifdef USE_SOFTDEVICE_ID
|
||||||
|
#ifdef USE_SOFTDEVICE_VERSION
|
||||||
|
if (USE_SOFTDEVICE_ID != sd_id || USE_SOFTDEVICE_VERSION != ver[0]) {
|
||||||
|
ESP_LOGE(TAG, "Built for SoftDevice S%u %u.x.y. It may crash due to mismatch of bootloader version.",
|
||||||
|
USE_SOFTDEVICE_ID, USE_SOFTDEVICE_VERSION);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (USE_SOFTDEVICE_ID != sd_id) {
|
||||||
|
ESP_LOGE(TAG, "Built for SoftDevice S%u. It may crash due to mismatch of bootloader version.", USE_SOFTDEVICE_ID);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ CONF_CHARGE = "charge"
|
|||||||
CONF_CHARGE_COULOMBS = "charge_coulombs"
|
CONF_CHARGE_COULOMBS = "charge_coulombs"
|
||||||
CONF_ENERGY_JOULES = "energy_joules"
|
CONF_ENERGY_JOULES = "energy_joules"
|
||||||
CONF_TEMPERATURE_COEFFICIENT = "temperature_coefficient"
|
CONF_TEMPERATURE_COEFFICIENT = "temperature_coefficient"
|
||||||
|
CONF_RESET_ON_BOOT = "reset_on_boot"
|
||||||
UNIT_AMPERE_HOURS = "Ah"
|
UNIT_AMPERE_HOURS = "Ah"
|
||||||
UNIT_COULOMB = "C"
|
UNIT_COULOMB = "C"
|
||||||
UNIT_JOULE = "J"
|
UNIT_JOULE = "J"
|
||||||
@@ -113,6 +114,7 @@ INA2XX_SCHEMA = cv.Schema(
|
|||||||
cv.Optional(CONF_TEMPERATURE_COEFFICIENT, default=0): cv.int_range(
|
cv.Optional(CONF_TEMPERATURE_COEFFICIENT, default=0): cv.int_range(
|
||||||
min=0, max=16383
|
min=0, max=16383
|
||||||
),
|
),
|
||||||
|
cv.Optional(CONF_RESET_ON_BOOT, default=True): cv.boolean,
|
||||||
cv.Optional(CONF_SHUNT_VOLTAGE): cv.maybe_simple_value(
|
cv.Optional(CONF_SHUNT_VOLTAGE): cv.maybe_simple_value(
|
||||||
sensor.sensor_schema(
|
sensor.sensor_schema(
|
||||||
unit_of_measurement=UNIT_MILLIVOLT,
|
unit_of_measurement=UNIT_MILLIVOLT,
|
||||||
@@ -206,6 +208,7 @@ async def setup_ina2xx(var, config):
|
|||||||
cg.add(var.set_adc_range(config[CONF_ADC_RANGE]))
|
cg.add(var.set_adc_range(config[CONF_ADC_RANGE]))
|
||||||
cg.add(var.set_adc_avg_samples(config[CONF_ADC_AVERAGING]))
|
cg.add(var.set_adc_avg_samples(config[CONF_ADC_AVERAGING]))
|
||||||
cg.add(var.set_shunt_tempco(config[CONF_TEMPERATURE_COEFFICIENT]))
|
cg.add(var.set_shunt_tempco(config[CONF_TEMPERATURE_COEFFICIENT]))
|
||||||
|
cg.add(var.set_reset_on_boot(config[CONF_RESET_ON_BOOT]))
|
||||||
|
|
||||||
adc_time_config = config[CONF_ADC_TIME]
|
adc_time_config = config[CONF_ADC_TIME]
|
||||||
if isinstance(adc_time_config, dict):
|
if isinstance(adc_time_config, dict):
|
||||||
|
@@ -257,7 +257,12 @@ bool INA2XX::reset_energy_counters() {
|
|||||||
bool INA2XX::reset_config_() {
|
bool INA2XX::reset_config_() {
|
||||||
ESP_LOGV(TAG, "Reset");
|
ESP_LOGV(TAG, "Reset");
|
||||||
ConfigurationRegister cfg{0};
|
ConfigurationRegister cfg{0};
|
||||||
|
if (!this->reset_on_boot_) {
|
||||||
|
ESP_LOGI(TAG, "Skipping on-boot device reset");
|
||||||
|
cfg.RST = false;
|
||||||
|
} else {
|
||||||
cfg.RST = true;
|
cfg.RST = true;
|
||||||
|
}
|
||||||
return this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
|
return this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -127,6 +127,7 @@ class INA2XX : public PollingComponent {
|
|||||||
void set_adc_time_die_temperature(AdcTime time) { this->adc_time_die_temperature_ = time; }
|
void set_adc_time_die_temperature(AdcTime time) { this->adc_time_die_temperature_ = time; }
|
||||||
void set_adc_avg_samples(AdcAvgSamples samples) { this->adc_avg_samples_ = samples; }
|
void set_adc_avg_samples(AdcAvgSamples samples) { this->adc_avg_samples_ = samples; }
|
||||||
void set_shunt_tempco(uint16_t coeff) { this->shunt_tempco_ppm_c_ = coeff; }
|
void set_shunt_tempco(uint16_t coeff) { this->shunt_tempco_ppm_c_ = coeff; }
|
||||||
|
void set_reset_on_boot(bool reset) { this->reset_on_boot_ = reset; }
|
||||||
|
|
||||||
void set_shunt_voltage_sensor(sensor::Sensor *sensor) { this->shunt_voltage_sensor_ = sensor; }
|
void set_shunt_voltage_sensor(sensor::Sensor *sensor) { this->shunt_voltage_sensor_ = sensor; }
|
||||||
void set_bus_voltage_sensor(sensor::Sensor *sensor) { this->bus_voltage_sensor_ = sensor; }
|
void set_bus_voltage_sensor(sensor::Sensor *sensor) { this->bus_voltage_sensor_ = sensor; }
|
||||||
@@ -172,6 +173,7 @@ class INA2XX : public PollingComponent {
|
|||||||
AdcTime adc_time_die_temperature_{AdcTime::ADC_TIME_4120US};
|
AdcTime adc_time_die_temperature_{AdcTime::ADC_TIME_4120US};
|
||||||
AdcAvgSamples adc_avg_samples_{AdcAvgSamples::ADC_AVG_SAMPLES_128};
|
AdcAvgSamples adc_avg_samples_{AdcAvgSamples::ADC_AVG_SAMPLES_128};
|
||||||
uint16_t shunt_tempco_ppm_c_{0};
|
uint16_t shunt_tempco_ppm_c_{0};
|
||||||
|
bool reset_on_boot_{true};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculated coefficients
|
// Calculated coefficients
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from esphome import pins
|
from esphome import pins
|
||||||
@@ -48,6 +49,7 @@ from .gpio import nrf52_pin_to_code # noqa
|
|||||||
CODEOWNERS = ["@tomaszduda23"]
|
CODEOWNERS = ["@tomaszduda23"]
|
||||||
AUTO_LOAD = ["zephyr"]
|
AUTO_LOAD = ["zephyr"]
|
||||||
IS_TARGET_PLATFORM = True
|
IS_TARGET_PLATFORM = True
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def set_core_data(config: ConfigType) -> ConfigType:
|
def set_core_data(config: ConfigType) -> ConfigType:
|
||||||
@@ -127,6 +129,10 @@ def _validate_mcumgr(config):
|
|||||||
def _final_validate(config):
|
def _final_validate(config):
|
||||||
if CONF_DFU in config:
|
if CONF_DFU in config:
|
||||||
_validate_mcumgr(config)
|
_validate_mcumgr(config)
|
||||||
|
if config[KEY_BOOTLOADER] == BOOTLOADER_ADAFRUIT:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Selected generic Adafruit bootloader. The board might crash. Consider settings `bootloader:`"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
FINAL_VALIDATE_SCHEMA = _final_validate
|
FINAL_VALIDATE_SCHEMA = _final_validate
|
||||||
@@ -157,6 +163,13 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
if config[KEY_BOOTLOADER] == BOOTLOADER_MCUBOOT:
|
if config[KEY_BOOTLOADER] == BOOTLOADER_MCUBOOT:
|
||||||
cg.add_define("USE_BOOTLOADER_MCUBOOT")
|
cg.add_define("USE_BOOTLOADER_MCUBOOT")
|
||||||
else:
|
else:
|
||||||
|
if "_sd" in config[KEY_BOOTLOADER]:
|
||||||
|
bootloader = config[KEY_BOOTLOADER].split("_")
|
||||||
|
sd_id = bootloader[2][2:]
|
||||||
|
cg.add_define("USE_SOFTDEVICE_ID", int(sd_id))
|
||||||
|
if (len(bootloader)) > 3:
|
||||||
|
sd_version = bootloader[3][1:]
|
||||||
|
cg.add_define("USE_SOFTDEVICE_VERSION", int(sd_version))
|
||||||
# make sure that firmware.zip is created
|
# make sure that firmware.zip is created
|
||||||
# for Adafruit_nRF52_Bootloader
|
# for Adafruit_nRF52_Bootloader
|
||||||
cg.add_platformio_option("board_upload.protocol", "nrfutil")
|
cg.add_platformio_option("board_upload.protocol", "nrfutil")
|
||||||
|
@@ -11,10 +11,18 @@ from .const import (
|
|||||||
BOARDS_ZEPHYR = {
|
BOARDS_ZEPHYR = {
|
||||||
"adafruit_itsybitsy_nrf52840": {
|
"adafruit_itsybitsy_nrf52840": {
|
||||||
KEY_BOOTLOADER: [
|
KEY_BOOTLOADER: [
|
||||||
|
BOOTLOADER_ADAFRUIT_NRF52_SD140_V6,
|
||||||
|
BOOTLOADER_ADAFRUIT,
|
||||||
|
BOOTLOADER_ADAFRUIT_NRF52_SD132,
|
||||||
|
BOOTLOADER_ADAFRUIT_NRF52_SD140_V7,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"xiao_ble": {
|
||||||
|
KEY_BOOTLOADER: [
|
||||||
|
BOOTLOADER_ADAFRUIT_NRF52_SD140_V7,
|
||||||
BOOTLOADER_ADAFRUIT,
|
BOOTLOADER_ADAFRUIT,
|
||||||
BOOTLOADER_ADAFRUIT_NRF52_SD132,
|
BOOTLOADER_ADAFRUIT_NRF52_SD132,
|
||||||
BOOTLOADER_ADAFRUIT_NRF52_SD140_V6,
|
BOOTLOADER_ADAFRUIT_NRF52_SD140_V6,
|
||||||
BOOTLOADER_ADAFRUIT_NRF52_SD140_V7,
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -66,6 +66,7 @@ from esphome.const import (
|
|||||||
DEVICE_CLASS_SPEED,
|
DEVICE_CLASS_SPEED,
|
||||||
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE_DELTA,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||||
DEVICE_CLASS_VOLTAGE,
|
DEVICE_CLASS_VOLTAGE,
|
||||||
@@ -130,6 +131,7 @@ DEVICE_CLASSES = [
|
|||||||
DEVICE_CLASS_SPEED,
|
DEVICE_CLASS_SPEED,
|
||||||
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE_DELTA,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||||
DEVICE_CLASS_VOLTAGE,
|
DEVICE_CLASS_VOLTAGE,
|
||||||
|
@@ -1056,6 +1056,52 @@ async def sony_action(var, config, args):
|
|||||||
cg.add(var.set_nbits(template_))
|
cg.add(var.set_nbits(template_))
|
||||||
|
|
||||||
|
|
||||||
|
# Symphony
|
||||||
|
SymphonyData, SymphonyBinarySensor, SymphonyTrigger, SymphonyAction, SymphonyDumper = (
|
||||||
|
declare_protocol("Symphony")
|
||||||
|
)
|
||||||
|
SYMPHONY_SCHEMA = cv.Schema(
|
||||||
|
{
|
||||||
|
cv.Required(CONF_DATA): cv.hex_uint32_t,
|
||||||
|
cv.Required(CONF_NBITS): cv.int_range(min=1, max=32),
|
||||||
|
cv.Optional(CONF_COMMAND_REPEATS, default=2): cv.uint8_t,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@register_binary_sensor("symphony", SymphonyBinarySensor, SYMPHONY_SCHEMA)
|
||||||
|
def symphony_binary_sensor(var, config):
|
||||||
|
cg.add(
|
||||||
|
var.set_data(
|
||||||
|
cg.StructInitializer(
|
||||||
|
SymphonyData,
|
||||||
|
("data", config[CONF_DATA]),
|
||||||
|
("nbits", config[CONF_NBITS]),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@register_trigger("symphony", SymphonyTrigger, SymphonyData)
|
||||||
|
def symphony_trigger(var, config):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@register_dumper("symphony", SymphonyDumper)
|
||||||
|
def symphony_dumper(var, config):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@register_action("symphony", SymphonyAction, SYMPHONY_SCHEMA)
|
||||||
|
async def symphony_action(var, config, args):
|
||||||
|
template_ = await cg.templatable(config[CONF_DATA], args, cg.uint32)
|
||||||
|
cg.add(var.set_data(template_))
|
||||||
|
template_ = await cg.templatable(config[CONF_NBITS], args, cg.uint32)
|
||||||
|
cg.add(var.set_nbits(template_))
|
||||||
|
template_ = await cg.templatable(config[CONF_COMMAND_REPEATS], args, cg.uint8)
|
||||||
|
cg.add(var.set_repeats(template_))
|
||||||
|
|
||||||
|
|
||||||
# Raw
|
# Raw
|
||||||
def validate_raw_alternating(value):
|
def validate_raw_alternating(value):
|
||||||
assert isinstance(value, list)
|
assert isinstance(value, list)
|
||||||
|
120
esphome/components/remote_base/symphony_protocol.cpp
Normal file
120
esphome/components/remote_base/symphony_protocol.cpp
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#include "symphony_protocol.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace remote_base {
|
||||||
|
|
||||||
|
static const char *const TAG = "remote.symphony";
|
||||||
|
|
||||||
|
// Reference implementation and timing details:
|
||||||
|
// IRremoteESP8266 ir_Symphony.cpp
|
||||||
|
// https://github.com/crankyoldgit/IRremoteESP8266/blob/master/src/ir_Symphony.cpp
|
||||||
|
// The implementation below mirrors the constant bit-time mapping and
|
||||||
|
// footer-gap handling used there.
|
||||||
|
|
||||||
|
// Symphony protocol timing specifications (tuned to handset captures)
|
||||||
|
static const uint32_t BIT_ZERO_HIGH_US = 460; // short
|
||||||
|
static const uint32_t BIT_ZERO_LOW_US = 1260; // long
|
||||||
|
static const uint32_t BIT_ONE_HIGH_US = 1260; // long
|
||||||
|
static const uint32_t BIT_ONE_LOW_US = 460; // short
|
||||||
|
static const uint32_t CARRIER_FREQUENCY = 38000;
|
||||||
|
|
||||||
|
// IRremoteESP8266 reference: kSymphonyFooterGap = 4 * (mark + space)
|
||||||
|
static const uint32_t FOOTER_GAP_US = 4 * (BIT_ZERO_HIGH_US + BIT_ZERO_LOW_US);
|
||||||
|
// Typical inter-frame gap (~34.8 ms observed)
|
||||||
|
static const uint32_t INTER_FRAME_GAP_US = 34760;
|
||||||
|
|
||||||
|
void SymphonyProtocol::encode(RemoteTransmitData *dst, const SymphonyData &data) {
|
||||||
|
dst->set_carrier_frequency(CARRIER_FREQUENCY);
|
||||||
|
ESP_LOGD(TAG, "Sending Symphony: data=0x%0*X nbits=%u repeats=%u", (data.nbits + 3) / 4, (uint32_t) data.data,
|
||||||
|
data.nbits, data.repeats);
|
||||||
|
// Each bit produces a mark+space (2 entries). We fold the inter-frame/footer gap
|
||||||
|
// into the last bit's space of each frame to avoid over-length gaps.
|
||||||
|
dst->reserve(data.nbits * 2u * data.repeats);
|
||||||
|
|
||||||
|
for (uint8_t repeats = 0; repeats < data.repeats; repeats++) {
|
||||||
|
// Data bits (MSB first)
|
||||||
|
for (uint32_t mask = 1UL << (data.nbits - 1); mask != 0; mask >>= 1) {
|
||||||
|
const bool is_last_bit = (mask == 1);
|
||||||
|
const bool is_last_frame = (repeats == (data.repeats - 1));
|
||||||
|
if (is_last_bit) {
|
||||||
|
// Emit last bit's mark; replace its space with the proper gap
|
||||||
|
if (data.data & mask) {
|
||||||
|
dst->mark(BIT_ONE_HIGH_US);
|
||||||
|
} else {
|
||||||
|
dst->mark(BIT_ZERO_HIGH_US);
|
||||||
|
}
|
||||||
|
dst->space(is_last_frame ? FOOTER_GAP_US : INTER_FRAME_GAP_US);
|
||||||
|
} else {
|
||||||
|
if (data.data & mask) {
|
||||||
|
dst->item(BIT_ONE_HIGH_US, BIT_ONE_LOW_US);
|
||||||
|
} else {
|
||||||
|
dst->item(BIT_ZERO_HIGH_US, BIT_ZERO_LOW_US);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<SymphonyData> SymphonyProtocol::decode(RemoteReceiveData src) {
|
||||||
|
auto is_valid_len = [](uint8_t nbits) -> bool { return nbits == 8 || nbits == 12 || nbits == 16; };
|
||||||
|
|
||||||
|
RemoteReceiveData s = src; // copy
|
||||||
|
SymphonyData out{0, 0, 1};
|
||||||
|
|
||||||
|
for (; out.nbits < 32; out.nbits++) {
|
||||||
|
if (s.expect_mark(BIT_ONE_HIGH_US)) {
|
||||||
|
if (!s.expect_space(BIT_ONE_LOW_US)) {
|
||||||
|
// Allow footer gap immediately after the last mark
|
||||||
|
if (s.peek_space_at_least(FOOTER_GAP_US)) {
|
||||||
|
uint8_t bits_with_this = out.nbits + 1;
|
||||||
|
if (is_valid_len(bits_with_this)) {
|
||||||
|
out.data = (out.data << 1UL) | 1UL;
|
||||||
|
out.nbits = bits_with_this;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
// Successfully consumed a '1' bit (mark + space)
|
||||||
|
out.data = (out.data << 1UL) | 1UL;
|
||||||
|
continue;
|
||||||
|
} else if (s.expect_mark(BIT_ZERO_HIGH_US)) {
|
||||||
|
if (!s.expect_space(BIT_ZERO_LOW_US)) {
|
||||||
|
// Allow footer gap immediately after the last mark
|
||||||
|
if (s.peek_space_at_least(FOOTER_GAP_US)) {
|
||||||
|
uint8_t bits_with_this = out.nbits + 1;
|
||||||
|
if (is_valid_len(bits_with_this)) {
|
||||||
|
out.data = (out.data << 1UL) | 0UL;
|
||||||
|
out.nbits = bits_with_this;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
// Successfully consumed a '0' bit (mark + space)
|
||||||
|
out.data = (out.data << 1UL) | 0UL;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// Completed a valid-length frame followed by a footer gap
|
||||||
|
if (is_valid_len(out.nbits) && s.peek_space_at_least(FOOTER_GAP_US)) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_valid_len(out.nbits) && s.peek_space_at_least(FOOTER_GAP_US)) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SymphonyProtocol::dump(const SymphonyData &data) {
|
||||||
|
const int32_t hex_width = (data.nbits + 3) / 4; // pad to nibble width
|
||||||
|
ESP_LOGI(TAG, "Received Symphony: data=0x%0*X, nbits=%d", hex_width, (uint32_t) data.data, data.nbits);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace remote_base
|
||||||
|
} // namespace esphome
|
44
esphome/components/remote_base/symphony_protocol.h
Normal file
44
esphome/components/remote_base/symphony_protocol.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "remote_base.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace remote_base {
|
||||||
|
|
||||||
|
struct SymphonyData {
|
||||||
|
uint32_t data;
|
||||||
|
uint8_t nbits;
|
||||||
|
uint8_t repeats{1};
|
||||||
|
|
||||||
|
bool operator==(const SymphonyData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class SymphonyProtocol : public RemoteProtocol<SymphonyData> {
|
||||||
|
public:
|
||||||
|
void encode(RemoteTransmitData *dst, const SymphonyData &data) override;
|
||||||
|
optional<SymphonyData> decode(RemoteReceiveData src) override;
|
||||||
|
void dump(const SymphonyData &data) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_REMOTE_PROTOCOL(Symphony)
|
||||||
|
|
||||||
|
template<typename... Ts> class SymphonyAction : public RemoteTransmitterActionBase<Ts...> {
|
||||||
|
public:
|
||||||
|
TEMPLATABLE_VALUE(uint32_t, data)
|
||||||
|
TEMPLATABLE_VALUE(uint8_t, nbits)
|
||||||
|
TEMPLATABLE_VALUE(uint8_t, repeats)
|
||||||
|
|
||||||
|
void encode(RemoteTransmitData *dst, Ts... x) override {
|
||||||
|
SymphonyData data{};
|
||||||
|
data.data = this->data_.value(x...);
|
||||||
|
data.nbits = this->nbits_.value(x...);
|
||||||
|
data.repeats = this->repeats_.value(x...);
|
||||||
|
SymphonyProtocol().encode(dst, data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace remote_base
|
||||||
|
} // namespace esphome
|
@@ -81,7 +81,7 @@ CONFIG_SCHEMA = (
|
|||||||
cv.int_range(min=0, max=0xFFFF, max_included=False),
|
cv.int_range(min=0, max=0xFFFF, max_included=False),
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION): cv.pressure,
|
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION): cv.pressure,
|
||||||
cv.Optional(CONF_TEMPERATURE_OFFSET, default="4°C"): cv.temperature,
|
cv.Optional(CONF_TEMPERATURE_OFFSET, default="4°C"): cv.temperature_delta,
|
||||||
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION_SOURCE): cv.use_id(
|
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION_SOURCE): cv.use_id(
|
||||||
sensor.Sensor
|
sensor.Sensor
|
||||||
),
|
),
|
||||||
|
@@ -89,6 +89,7 @@ from esphome.const import (
|
|||||||
DEVICE_CLASS_SPEED,
|
DEVICE_CLASS_SPEED,
|
||||||
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE_DELTA,
|
||||||
DEVICE_CLASS_TIMESTAMP,
|
DEVICE_CLASS_TIMESTAMP,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||||
@@ -157,6 +158,7 @@ DEVICE_CLASSES = [
|
|||||||
DEVICE_CLASS_SPEED,
|
DEVICE_CLASS_SPEED,
|
||||||
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
DEVICE_CLASS_SULPHUR_DIOXIDE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE_DELTA,
|
||||||
DEVICE_CLASS_TIMESTAMP,
|
DEVICE_CLASS_TIMESTAMP,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||||
|
@@ -71,9 +71,14 @@ from esphome.const import (
|
|||||||
CONF_VISUAL,
|
CONF_VISUAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
CONF_PRESET_CHANGE = "preset_change"
|
|
||||||
CONF_DEFAULT_PRESET = "default_preset"
|
CONF_DEFAULT_PRESET = "default_preset"
|
||||||
|
CONF_HUMIDITY_CONTROL_DEHUMIDIFY_ACTION = "humidity_control_dehumidify_action"
|
||||||
|
CONF_HUMIDITY_CONTROL_HUMIDIFY_ACTION = "humidity_control_humidify_action"
|
||||||
|
CONF_HUMIDITY_CONTROL_OFF_ACTION = "humidity_control_off_action"
|
||||||
|
CONF_HUMIDITY_HYSTERESIS = "humidity_hysteresis"
|
||||||
CONF_ON_BOOT_RESTORE_FROM = "on_boot_restore_from"
|
CONF_ON_BOOT_RESTORE_FROM = "on_boot_restore_from"
|
||||||
|
CONF_PRESET_CHANGE = "preset_change"
|
||||||
|
CONF_TARGET_HUMIDITY_CHANGE_ACTION = "target_humidity_change_action"
|
||||||
|
|
||||||
CODEOWNERS = ["@kbx81"]
|
CODEOWNERS = ["@kbx81"]
|
||||||
|
|
||||||
@@ -241,6 +246,14 @@ def validate_thermostat(config):
|
|||||||
CONF_MAX_HEATING_RUN_TIME,
|
CONF_MAX_HEATING_RUN_TIME,
|
||||||
CONF_SUPPLEMENTAL_HEATING_ACTION,
|
CONF_SUPPLEMENTAL_HEATING_ACTION,
|
||||||
],
|
],
|
||||||
|
CONF_HUMIDITY_CONTROL_DEHUMIDIFY_ACTION: [
|
||||||
|
CONF_HUMIDITY_CONTROL_OFF_ACTION,
|
||||||
|
CONF_HUMIDITY_SENSOR,
|
||||||
|
],
|
||||||
|
CONF_HUMIDITY_CONTROL_HUMIDIFY_ACTION: [
|
||||||
|
CONF_HUMIDITY_CONTROL_OFF_ACTION,
|
||||||
|
CONF_HUMIDITY_SENSOR,
|
||||||
|
],
|
||||||
}
|
}
|
||||||
for config_trigger, req_triggers in requirements.items():
|
for config_trigger, req_triggers in requirements.items():
|
||||||
for req_trigger in req_triggers:
|
for req_trigger in req_triggers:
|
||||||
@@ -338,7 +351,7 @@ def validate_thermostat(config):
|
|||||||
# Warn about using the removed CONF_DEFAULT_MODE and advise users
|
# Warn about using the removed CONF_DEFAULT_MODE and advise users
|
||||||
if CONF_DEFAULT_MODE in config and config[CONF_DEFAULT_MODE] is not None:
|
if CONF_DEFAULT_MODE in config and config[CONF_DEFAULT_MODE] is not None:
|
||||||
raise cv.Invalid(
|
raise cv.Invalid(
|
||||||
f"{CONF_DEFAULT_MODE} is no longer valid. Please switch to using presets and specify a {CONF_DEFAULT_PRESET}."
|
f"{CONF_DEFAULT_MODE} is no longer valid. Please switch to using presets and specify a {CONF_DEFAULT_PRESET}"
|
||||||
)
|
)
|
||||||
|
|
||||||
default_mode = config[CONF_DEFAULT_MODE]
|
default_mode = config[CONF_DEFAULT_MODE]
|
||||||
@@ -588,9 +601,24 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Optional(CONF_SWING_VERTICAL_ACTION): automation.validate_automation(
|
cv.Optional(CONF_SWING_VERTICAL_ACTION): automation.validate_automation(
|
||||||
single=True
|
single=True
|
||||||
),
|
),
|
||||||
|
cv.Optional(
|
||||||
|
CONF_TARGET_HUMIDITY_CHANGE_ACTION
|
||||||
|
): automation.validate_automation(single=True),
|
||||||
cv.Optional(
|
cv.Optional(
|
||||||
CONF_TARGET_TEMPERATURE_CHANGE_ACTION
|
CONF_TARGET_TEMPERATURE_CHANGE_ACTION
|
||||||
): automation.validate_automation(single=True),
|
): automation.validate_automation(single=True),
|
||||||
|
cv.Exclusive(
|
||||||
|
CONF_HUMIDITY_CONTROL_DEHUMIDIFY_ACTION,
|
||||||
|
group_of_exclusion="humidity_control",
|
||||||
|
): automation.validate_automation(single=True),
|
||||||
|
cv.Exclusive(
|
||||||
|
CONF_HUMIDITY_CONTROL_HUMIDIFY_ACTION,
|
||||||
|
group_of_exclusion="humidity_control",
|
||||||
|
): automation.validate_automation(single=True),
|
||||||
|
cv.Optional(
|
||||||
|
CONF_HUMIDITY_CONTROL_OFF_ACTION
|
||||||
|
): automation.validate_automation(single=True),
|
||||||
|
cv.Optional(CONF_HUMIDITY_HYSTERESIS, default=1.0): cv.percentage,
|
||||||
cv.Optional(CONF_DEFAULT_MODE, default=None): cv.valid,
|
cv.Optional(CONF_DEFAULT_MODE, default=None): cv.valid,
|
||||||
cv.Optional(CONF_DEFAULT_PRESET): cv.templatable(cv.string),
|
cv.Optional(CONF_DEFAULT_PRESET): cv.templatable(cv.string),
|
||||||
cv.Optional(CONF_DEFAULT_TARGET_TEMPERATURE_HIGH): cv.temperature,
|
cv.Optional(CONF_DEFAULT_TARGET_TEMPERATURE_HIGH): cv.temperature,
|
||||||
@@ -882,12 +910,39 @@ async def to_code(config):
|
|||||||
config[CONF_SWING_VERTICAL_ACTION],
|
config[CONF_SWING_VERTICAL_ACTION],
|
||||||
)
|
)
|
||||||
cg.add(var.set_supports_swing_mode_vertical(True))
|
cg.add(var.set_supports_swing_mode_vertical(True))
|
||||||
|
if CONF_TARGET_HUMIDITY_CHANGE_ACTION in config:
|
||||||
|
await automation.build_automation(
|
||||||
|
var.get_humidity_change_trigger(),
|
||||||
|
[],
|
||||||
|
config[CONF_TARGET_HUMIDITY_CHANGE_ACTION],
|
||||||
|
)
|
||||||
if CONF_TARGET_TEMPERATURE_CHANGE_ACTION in config:
|
if CONF_TARGET_TEMPERATURE_CHANGE_ACTION in config:
|
||||||
await automation.build_automation(
|
await automation.build_automation(
|
||||||
var.get_temperature_change_trigger(),
|
var.get_temperature_change_trigger(),
|
||||||
[],
|
[],
|
||||||
config[CONF_TARGET_TEMPERATURE_CHANGE_ACTION],
|
config[CONF_TARGET_TEMPERATURE_CHANGE_ACTION],
|
||||||
)
|
)
|
||||||
|
if CONF_HUMIDITY_CONTROL_DEHUMIDIFY_ACTION in config:
|
||||||
|
cg.add(var.set_supports_dehumidification(True))
|
||||||
|
await automation.build_automation(
|
||||||
|
var.get_humidity_control_dehumidify_action_trigger(),
|
||||||
|
[],
|
||||||
|
config[CONF_HUMIDITY_CONTROL_DEHUMIDIFY_ACTION],
|
||||||
|
)
|
||||||
|
if CONF_HUMIDITY_CONTROL_HUMIDIFY_ACTION in config:
|
||||||
|
cg.add(var.set_supports_humidification(True))
|
||||||
|
await automation.build_automation(
|
||||||
|
var.get_humidity_control_humidify_action_trigger(),
|
||||||
|
[],
|
||||||
|
config[CONF_HUMIDITY_CONTROL_HUMIDIFY_ACTION],
|
||||||
|
)
|
||||||
|
if CONF_HUMIDITY_CONTROL_OFF_ACTION in config:
|
||||||
|
await automation.build_automation(
|
||||||
|
var.get_humidity_control_off_action_trigger(),
|
||||||
|
[],
|
||||||
|
config[CONF_HUMIDITY_CONTROL_OFF_ACTION],
|
||||||
|
)
|
||||||
|
cg.add(var.set_humidity_hysteresis(config[CONF_HUMIDITY_HYSTERESIS]))
|
||||||
|
|
||||||
if CONF_PRESET in config:
|
if CONF_PRESET in config:
|
||||||
for preset_config in config[CONF_PRESET]:
|
for preset_config in config[CONF_PRESET]:
|
||||||
|
@@ -32,6 +32,7 @@ void ThermostatClimate::setup() {
|
|||||||
if (this->humidity_sensor_ != nullptr) {
|
if (this->humidity_sensor_ != nullptr) {
|
||||||
this->humidity_sensor_->add_on_state_callback([this](float state) {
|
this->humidity_sensor_->add_on_state_callback([this](float state) {
|
||||||
this->current_humidity = state;
|
this->current_humidity = state;
|
||||||
|
this->switch_to_humidity_control_action_(this->compute_humidity_control_action_());
|
||||||
this->publish_state();
|
this->publish_state();
|
||||||
});
|
});
|
||||||
this->current_humidity = this->humidity_sensor_->state;
|
this->current_humidity = this->humidity_sensor_->state;
|
||||||
@@ -84,6 +85,8 @@ void ThermostatClimate::refresh() {
|
|||||||
this->switch_to_supplemental_action_(this->compute_supplemental_action_());
|
this->switch_to_supplemental_action_(this->compute_supplemental_action_());
|
||||||
this->switch_to_fan_mode_(this->fan_mode.value(), false);
|
this->switch_to_fan_mode_(this->fan_mode.value(), false);
|
||||||
this->switch_to_swing_mode_(this->swing_mode, false);
|
this->switch_to_swing_mode_(this->swing_mode, false);
|
||||||
|
this->switch_to_humidity_control_action_(this->compute_humidity_control_action_());
|
||||||
|
this->check_humidity_change_trigger_();
|
||||||
this->check_temperature_change_trigger_();
|
this->check_temperature_change_trigger_();
|
||||||
this->publish_state();
|
this->publish_state();
|
||||||
}
|
}
|
||||||
@@ -129,6 +132,11 @@ bool ThermostatClimate::hysteresis_valid() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThermostatClimate::humidity_hysteresis_valid() {
|
||||||
|
return !std::isnan(this->humidity_hysteresis_) && this->humidity_hysteresis_ >= 0.0f &&
|
||||||
|
this->humidity_hysteresis_ < 100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
bool ThermostatClimate::limit_setpoints_for_heat_cool() {
|
bool ThermostatClimate::limit_setpoints_for_heat_cool() {
|
||||||
return this->mode == climate::CLIMATE_MODE_HEAT_COOL ||
|
return this->mode == climate::CLIMATE_MODE_HEAT_COOL ||
|
||||||
(this->mode == climate::CLIMATE_MODE_AUTO && this->supports_heat_cool_);
|
(this->mode == climate::CLIMATE_MODE_AUTO && this->supports_heat_cool_);
|
||||||
@@ -189,6 +197,16 @@ void ThermostatClimate::validate_target_temperature_high() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThermostatClimate::validate_target_humidity() {
|
||||||
|
if (std::isnan(this->target_humidity)) {
|
||||||
|
this->target_humidity =
|
||||||
|
(this->get_traits().get_visual_max_humidity() - this->get_traits().get_visual_min_humidity()) / 2.0f;
|
||||||
|
} else {
|
||||||
|
this->target_humidity = clamp<float>(this->target_humidity, this->get_traits().get_visual_min_humidity(),
|
||||||
|
this->get_traits().get_visual_max_humidity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::control(const climate::ClimateCall &call) {
|
void ThermostatClimate::control(const climate::ClimateCall &call) {
|
||||||
bool target_temperature_high_changed = false;
|
bool target_temperature_high_changed = false;
|
||||||
|
|
||||||
@@ -235,6 +253,10 @@ void ThermostatClimate::control(const climate::ClimateCall &call) {
|
|||||||
this->validate_target_temperature();
|
this->validate_target_temperature();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (call.get_target_humidity().has_value()) {
|
||||||
|
this->target_humidity = call.get_target_humidity().value();
|
||||||
|
this->validate_target_humidity();
|
||||||
|
}
|
||||||
// make any changes happen
|
// make any changes happen
|
||||||
this->refresh();
|
this->refresh();
|
||||||
}
|
}
|
||||||
@@ -250,6 +272,9 @@ climate::ClimateTraits ThermostatClimate::traits() {
|
|||||||
if (this->humidity_sensor_ != nullptr)
|
if (this->humidity_sensor_ != nullptr)
|
||||||
traits.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY);
|
traits.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY);
|
||||||
|
|
||||||
|
if (this->supports_humidification_ || this->supports_dehumidification_)
|
||||||
|
traits.add_feature_flags(climate::CLIMATE_SUPPORTS_TARGET_HUMIDITY);
|
||||||
|
|
||||||
if (this->supports_auto_)
|
if (this->supports_auto_)
|
||||||
traits.add_supported_mode(climate::CLIMATE_MODE_AUTO);
|
traits.add_supported_mode(climate::CLIMATE_MODE_AUTO);
|
||||||
if (this->supports_heat_cool_)
|
if (this->supports_heat_cool_)
|
||||||
@@ -423,6 +448,28 @@ climate::ClimateAction ThermostatClimate::compute_supplemental_action_() {
|
|||||||
return target_action;
|
return target_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HumidificationAction ThermostatClimate::compute_humidity_control_action_() {
|
||||||
|
auto target_action = THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF;
|
||||||
|
// if hysteresis value or current_humidity is not valid, we go to OFF
|
||||||
|
if (std::isnan(this->current_humidity) || !this->humidity_hysteresis_valid()) {
|
||||||
|
return THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure set point is valid before computing the action
|
||||||
|
this->validate_target_humidity();
|
||||||
|
// everything has been validated so we can now safely compute the action
|
||||||
|
if (this->dehumidification_required_() && this->humidification_required_()) {
|
||||||
|
// this is bad and should never happen, so just stop.
|
||||||
|
// target_action = THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF;
|
||||||
|
} else if (this->supports_dehumidification_ && this->dehumidification_required_()) {
|
||||||
|
target_action = THERMOSTAT_HUMIDITY_CONTROL_ACTION_DEHUMIDIFY;
|
||||||
|
} else if (this->supports_humidification_ && this->humidification_required_()) {
|
||||||
|
target_action = THERMOSTAT_HUMIDITY_CONTROL_ACTION_HUMIDIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target_action;
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::switch_to_action_(climate::ClimateAction action, bool publish_state) {
|
void ThermostatClimate::switch_to_action_(climate::ClimateAction action, bool publish_state) {
|
||||||
// setup_complete_ helps us ensure an action is called immediately after boot
|
// setup_complete_ helps us ensure an action is called immediately after boot
|
||||||
if ((action == this->action) && this->setup_complete_) {
|
if ((action == this->action) && this->setup_complete_) {
|
||||||
@@ -596,6 +643,44 @@ void ThermostatClimate::trigger_supplemental_action_() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThermostatClimate::switch_to_humidity_control_action_(HumidificationAction action) {
|
||||||
|
// setup_complete_ helps us ensure an action is called immediately after boot
|
||||||
|
if ((action == this->humidification_action_) && this->setup_complete_) {
|
||||||
|
// already in target mode
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Trigger<> *trig = this->humidity_control_off_action_trigger_;
|
||||||
|
switch (action) {
|
||||||
|
case THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF:
|
||||||
|
// trig = this->humidity_control_off_action_trigger_;
|
||||||
|
ESP_LOGVV(TAG, "Switching to HUMIDIFICATION_OFF action");
|
||||||
|
break;
|
||||||
|
case THERMOSTAT_HUMIDITY_CONTROL_ACTION_DEHUMIDIFY:
|
||||||
|
trig = this->humidity_control_dehumidify_action_trigger_;
|
||||||
|
ESP_LOGVV(TAG, "Switching to DEHUMIDIFY action");
|
||||||
|
break;
|
||||||
|
case THERMOSTAT_HUMIDITY_CONTROL_ACTION_HUMIDIFY:
|
||||||
|
trig = this->humidity_control_humidify_action_trigger_;
|
||||||
|
ESP_LOGVV(TAG, "Switching to HUMIDIFY action");
|
||||||
|
break;
|
||||||
|
case THERMOSTAT_HUMIDITY_CONTROL_ACTION_NONE:
|
||||||
|
default:
|
||||||
|
action = THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF;
|
||||||
|
// trig = this->humidity_control_off_action_trigger_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->prev_humidity_control_trigger_ != nullptr) {
|
||||||
|
this->prev_humidity_control_trigger_->stop_action();
|
||||||
|
this->prev_humidity_control_trigger_ = nullptr;
|
||||||
|
}
|
||||||
|
this->humidification_action_ = action;
|
||||||
|
this->prev_humidity_control_trigger_ = trig;
|
||||||
|
if (trig != nullptr) {
|
||||||
|
trig->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bool publish_state) {
|
void ThermostatClimate::switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bool publish_state) {
|
||||||
// setup_complete_ helps us ensure an action is called immediately after boot
|
// setup_complete_ helps us ensure an action is called immediately after boot
|
||||||
if ((fan_mode == this->prev_fan_mode_) && this->setup_complete_) {
|
if ((fan_mode == this->prev_fan_mode_) && this->setup_complete_) {
|
||||||
@@ -887,6 +972,20 @@ void ThermostatClimate::idle_on_timer_callback_() {
|
|||||||
this->switch_to_supplemental_action_(this->compute_supplemental_action_());
|
this->switch_to_supplemental_action_(this->compute_supplemental_action_());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThermostatClimate::check_humidity_change_trigger_() {
|
||||||
|
if ((this->prev_target_humidity_ == this->target_humidity) && this->setup_complete_) {
|
||||||
|
return; // nothing changed, no reason to trigger
|
||||||
|
} else {
|
||||||
|
// save the new temperature so we can check it again later; the trigger will fire below
|
||||||
|
this->prev_target_humidity_ = this->target_humidity;
|
||||||
|
}
|
||||||
|
// trigger the action
|
||||||
|
Trigger<> *trig = this->humidity_change_trigger_;
|
||||||
|
if (trig != nullptr) {
|
||||||
|
trig->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::check_temperature_change_trigger_() {
|
void ThermostatClimate::check_temperature_change_trigger_() {
|
||||||
if (this->supports_two_points_) {
|
if (this->supports_two_points_) {
|
||||||
// setup_complete_ helps us ensure an action is called immediately after boot
|
// setup_complete_ helps us ensure an action is called immediately after boot
|
||||||
@@ -996,6 +1095,32 @@ bool ThermostatClimate::supplemental_heating_required_() {
|
|||||||
(this->supplemental_action_ == climate::CLIMATE_ACTION_HEATING));
|
(this->supplemental_action_ == climate::CLIMATE_ACTION_HEATING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThermostatClimate::dehumidification_required_() {
|
||||||
|
if (this->current_humidity > this->target_humidity + this->humidity_hysteresis_) {
|
||||||
|
// if the current humidity exceeds the target + hysteresis, dehumidification is required
|
||||||
|
return true;
|
||||||
|
} else if (this->current_humidity < this->target_humidity - this->humidity_hysteresis_) {
|
||||||
|
// if the current humidity is less than the target - hysteresis, dehumidification should stop
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// if we get here, the current humidity is between target + hysteresis and target - hysteresis,
|
||||||
|
// so the action should not change
|
||||||
|
return this->humidification_action_ == THERMOSTAT_HUMIDITY_CONTROL_ACTION_DEHUMIDIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThermostatClimate::humidification_required_() {
|
||||||
|
if (this->current_humidity < this->target_humidity - this->humidity_hysteresis_) {
|
||||||
|
// if the current humidity is below the target - hysteresis, humidification is required
|
||||||
|
return true;
|
||||||
|
} else if (this->current_humidity > this->target_humidity + this->humidity_hysteresis_) {
|
||||||
|
// if the current humidity is above the target + hysteresis, humidification should stop
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// if we get here, the current humidity is between target - hysteresis and target + hysteresis,
|
||||||
|
// so the action should not change
|
||||||
|
return this->humidification_action_ == THERMOSTAT_HUMIDITY_CONTROL_ACTION_HUMIDIFY;
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::dump_preset_config_(const char *preset_name, const ThermostatClimateTargetTempConfig &config) {
|
void ThermostatClimate::dump_preset_config_(const char *preset_name, const ThermostatClimateTargetTempConfig &config) {
|
||||||
if (this->supports_heat_) {
|
if (this->supports_heat_) {
|
||||||
ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.1f°C",
|
ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.1f°C",
|
||||||
@@ -1152,8 +1277,12 @@ ThermostatClimate::ThermostatClimate()
|
|||||||
swing_mode_off_trigger_(new Trigger<>()),
|
swing_mode_off_trigger_(new Trigger<>()),
|
||||||
swing_mode_horizontal_trigger_(new Trigger<>()),
|
swing_mode_horizontal_trigger_(new Trigger<>()),
|
||||||
swing_mode_vertical_trigger_(new Trigger<>()),
|
swing_mode_vertical_trigger_(new Trigger<>()),
|
||||||
|
humidity_change_trigger_(new Trigger<>()),
|
||||||
temperature_change_trigger_(new Trigger<>()),
|
temperature_change_trigger_(new Trigger<>()),
|
||||||
preset_change_trigger_(new Trigger<>()) {}
|
preset_change_trigger_(new Trigger<>()),
|
||||||
|
humidity_control_dehumidify_action_trigger_(new Trigger<>()),
|
||||||
|
humidity_control_humidify_action_trigger_(new Trigger<>()),
|
||||||
|
humidity_control_off_action_trigger_(new Trigger<>()) {}
|
||||||
|
|
||||||
void ThermostatClimate::set_default_preset(const std::string &custom_preset) {
|
void ThermostatClimate::set_default_preset(const std::string &custom_preset) {
|
||||||
this->default_custom_preset_ = custom_preset;
|
this->default_custom_preset_ = custom_preset;
|
||||||
@@ -1217,6 +1346,9 @@ void ThermostatClimate::set_sensor(sensor::Sensor *sensor) { this->sensor_ = sen
|
|||||||
void ThermostatClimate::set_humidity_sensor(sensor::Sensor *humidity_sensor) {
|
void ThermostatClimate::set_humidity_sensor(sensor::Sensor *humidity_sensor) {
|
||||||
this->humidity_sensor_ = humidity_sensor;
|
this->humidity_sensor_ = humidity_sensor;
|
||||||
}
|
}
|
||||||
|
void ThermostatClimate::set_humidity_hysteresis(float humidity_hysteresis) {
|
||||||
|
this->humidity_hysteresis_ = std::clamp<float>(humidity_hysteresis, 0.0f, 100.0f);
|
||||||
|
}
|
||||||
void ThermostatClimate::set_use_startup_delay(bool use_startup_delay) { this->use_startup_delay_ = use_startup_delay; }
|
void ThermostatClimate::set_use_startup_delay(bool use_startup_delay) { this->use_startup_delay_ = use_startup_delay; }
|
||||||
void ThermostatClimate::set_supports_heat_cool(bool supports_heat_cool) {
|
void ThermostatClimate::set_supports_heat_cool(bool supports_heat_cool) {
|
||||||
this->supports_heat_cool_ = supports_heat_cool;
|
this->supports_heat_cool_ = supports_heat_cool;
|
||||||
@@ -1284,6 +1416,18 @@ void ThermostatClimate::set_supports_swing_mode_vertical(bool supports_swing_mod
|
|||||||
void ThermostatClimate::set_supports_two_points(bool supports_two_points) {
|
void ThermostatClimate::set_supports_two_points(bool supports_two_points) {
|
||||||
this->supports_two_points_ = supports_two_points;
|
this->supports_two_points_ = supports_two_points;
|
||||||
}
|
}
|
||||||
|
void ThermostatClimate::set_supports_dehumidification(bool supports_dehumidification) {
|
||||||
|
this->supports_dehumidification_ = supports_dehumidification;
|
||||||
|
if (supports_dehumidification) {
|
||||||
|
this->supports_humidification_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ThermostatClimate::set_supports_humidification(bool supports_humidification) {
|
||||||
|
this->supports_humidification_ = supports_humidification;
|
||||||
|
if (supports_humidification) {
|
||||||
|
this->supports_dehumidification_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Trigger<> *ThermostatClimate::get_cool_action_trigger() const { return this->cool_action_trigger_; }
|
Trigger<> *ThermostatClimate::get_cool_action_trigger() const { return this->cool_action_trigger_; }
|
||||||
Trigger<> *ThermostatClimate::get_supplemental_cool_action_trigger() const {
|
Trigger<> *ThermostatClimate::get_supplemental_cool_action_trigger() const {
|
||||||
@@ -1317,8 +1461,18 @@ Trigger<> *ThermostatClimate::get_swing_mode_both_trigger() const { return this-
|
|||||||
Trigger<> *ThermostatClimate::get_swing_mode_off_trigger() const { return this->swing_mode_off_trigger_; }
|
Trigger<> *ThermostatClimate::get_swing_mode_off_trigger() const { return this->swing_mode_off_trigger_; }
|
||||||
Trigger<> *ThermostatClimate::get_swing_mode_horizontal_trigger() const { return this->swing_mode_horizontal_trigger_; }
|
Trigger<> *ThermostatClimate::get_swing_mode_horizontal_trigger() const { return this->swing_mode_horizontal_trigger_; }
|
||||||
Trigger<> *ThermostatClimate::get_swing_mode_vertical_trigger() const { return this->swing_mode_vertical_trigger_; }
|
Trigger<> *ThermostatClimate::get_swing_mode_vertical_trigger() const { return this->swing_mode_vertical_trigger_; }
|
||||||
|
Trigger<> *ThermostatClimate::get_humidity_change_trigger() const { return this->humidity_change_trigger_; }
|
||||||
Trigger<> *ThermostatClimate::get_temperature_change_trigger() const { return this->temperature_change_trigger_; }
|
Trigger<> *ThermostatClimate::get_temperature_change_trigger() const { return this->temperature_change_trigger_; }
|
||||||
Trigger<> *ThermostatClimate::get_preset_change_trigger() const { return this->preset_change_trigger_; }
|
Trigger<> *ThermostatClimate::get_preset_change_trigger() const { return this->preset_change_trigger_; }
|
||||||
|
Trigger<> *ThermostatClimate::get_humidity_control_dehumidify_action_trigger() const {
|
||||||
|
return this->humidity_control_dehumidify_action_trigger_;
|
||||||
|
}
|
||||||
|
Trigger<> *ThermostatClimate::get_humidity_control_humidify_action_trigger() const {
|
||||||
|
return this->humidity_control_humidify_action_trigger_;
|
||||||
|
}
|
||||||
|
Trigger<> *ThermostatClimate::get_humidity_control_off_action_trigger() const {
|
||||||
|
return this->humidity_control_off_action_trigger_;
|
||||||
|
}
|
||||||
|
|
||||||
void ThermostatClimate::dump_config() {
|
void ThermostatClimate::dump_config() {
|
||||||
LOG_CLIMATE("", "Thermostat", this);
|
LOG_CLIMATE("", "Thermostat", this);
|
||||||
@@ -1422,7 +1576,12 @@ void ThermostatClimate::dump_config() {
|
|||||||
" OFF: %s\n"
|
" OFF: %s\n"
|
||||||
" HORIZONTAL: %s\n"
|
" HORIZONTAL: %s\n"
|
||||||
" VERTICAL: %s\n"
|
" VERTICAL: %s\n"
|
||||||
" Supports TWO SET POINTS: %s",
|
" Supports TWO SET POINTS: %s\n"
|
||||||
|
" Supported Humidity Parameters:\n"
|
||||||
|
" CURRENT: %s\n"
|
||||||
|
" TARGET: %s\n"
|
||||||
|
" DEHUMIDIFICATION: %s\n"
|
||||||
|
" HUMIDIFICATION: %s",
|
||||||
YESNO(this->supports_fan_mode_on_), YESNO(this->supports_fan_mode_off_),
|
YESNO(this->supports_fan_mode_on_), YESNO(this->supports_fan_mode_off_),
|
||||||
YESNO(this->supports_fan_mode_auto_), YESNO(this->supports_fan_mode_low_),
|
YESNO(this->supports_fan_mode_auto_), YESNO(this->supports_fan_mode_low_),
|
||||||
YESNO(this->supports_fan_mode_medium_), YESNO(this->supports_fan_mode_high_),
|
YESNO(this->supports_fan_mode_medium_), YESNO(this->supports_fan_mode_high_),
|
||||||
@@ -1430,7 +1589,10 @@ void ThermostatClimate::dump_config() {
|
|||||||
YESNO(this->supports_fan_mode_diffuse_), YESNO(this->supports_fan_mode_quiet_),
|
YESNO(this->supports_fan_mode_diffuse_), YESNO(this->supports_fan_mode_quiet_),
|
||||||
YESNO(this->supports_swing_mode_both_), YESNO(this->supports_swing_mode_off_),
|
YESNO(this->supports_swing_mode_both_), YESNO(this->supports_swing_mode_off_),
|
||||||
YESNO(this->supports_swing_mode_horizontal_), YESNO(this->supports_swing_mode_vertical_),
|
YESNO(this->supports_swing_mode_horizontal_), YESNO(this->supports_swing_mode_vertical_),
|
||||||
YESNO(this->supports_two_points_));
|
YESNO(this->supports_two_points_),
|
||||||
|
YESNO(this->get_traits().has_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_HUMIDITY)),
|
||||||
|
YESNO(this->supports_dehumidification_ || this->supports_humidification_),
|
||||||
|
YESNO(this->supports_dehumidification_), YESNO(this->supports_humidification_));
|
||||||
|
|
||||||
if (!this->preset_config_.empty()) {
|
if (!this->preset_config_.empty()) {
|
||||||
ESP_LOGCONFIG(TAG, " Supported PRESETS:");
|
ESP_LOGCONFIG(TAG, " Supported PRESETS:");
|
||||||
|
@@ -13,6 +13,13 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace thermostat {
|
namespace thermostat {
|
||||||
|
|
||||||
|
enum HumidificationAction : uint8_t {
|
||||||
|
THERMOSTAT_HUMIDITY_CONTROL_ACTION_OFF = 0,
|
||||||
|
THERMOSTAT_HUMIDITY_CONTROL_ACTION_DEHUMIDIFY = 1,
|
||||||
|
THERMOSTAT_HUMIDITY_CONTROL_ACTION_HUMIDIFY = 2,
|
||||||
|
THERMOSTAT_HUMIDITY_CONTROL_ACTION_NONE,
|
||||||
|
};
|
||||||
|
|
||||||
enum ThermostatClimateTimerIndex : uint8_t {
|
enum ThermostatClimateTimerIndex : uint8_t {
|
||||||
THERMOSTAT_TIMER_COOLING_MAX_RUN_TIME = 0,
|
THERMOSTAT_TIMER_COOLING_MAX_RUN_TIME = 0,
|
||||||
THERMOSTAT_TIMER_COOLING_OFF = 1,
|
THERMOSTAT_TIMER_COOLING_OFF = 1,
|
||||||
@@ -90,6 +97,7 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
void set_idle_minimum_time_in_sec(uint32_t time);
|
void set_idle_minimum_time_in_sec(uint32_t time);
|
||||||
void set_sensor(sensor::Sensor *sensor);
|
void set_sensor(sensor::Sensor *sensor);
|
||||||
void set_humidity_sensor(sensor::Sensor *humidity_sensor);
|
void set_humidity_sensor(sensor::Sensor *humidity_sensor);
|
||||||
|
void set_humidity_hysteresis(float humidity_hysteresis);
|
||||||
void set_use_startup_delay(bool use_startup_delay);
|
void set_use_startup_delay(bool use_startup_delay);
|
||||||
void set_supports_auto(bool supports_auto);
|
void set_supports_auto(bool supports_auto);
|
||||||
void set_supports_heat_cool(bool supports_heat_cool);
|
void set_supports_heat_cool(bool supports_heat_cool);
|
||||||
@@ -115,6 +123,8 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
void set_supports_swing_mode_horizontal(bool supports_swing_mode_horizontal);
|
void set_supports_swing_mode_horizontal(bool supports_swing_mode_horizontal);
|
||||||
void set_supports_swing_mode_off(bool supports_swing_mode_off);
|
void set_supports_swing_mode_off(bool supports_swing_mode_off);
|
||||||
void set_supports_swing_mode_vertical(bool supports_swing_mode_vertical);
|
void set_supports_swing_mode_vertical(bool supports_swing_mode_vertical);
|
||||||
|
void set_supports_dehumidification(bool supports_dehumidification);
|
||||||
|
void set_supports_humidification(bool supports_humidification);
|
||||||
void set_supports_two_points(bool supports_two_points);
|
void set_supports_two_points(bool supports_two_points);
|
||||||
|
|
||||||
void set_preset_config(climate::ClimatePreset preset, const ThermostatClimateTargetTempConfig &config);
|
void set_preset_config(climate::ClimatePreset preset, const ThermostatClimateTargetTempConfig &config);
|
||||||
@@ -148,8 +158,12 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
Trigger<> *get_swing_mode_horizontal_trigger() const;
|
Trigger<> *get_swing_mode_horizontal_trigger() const;
|
||||||
Trigger<> *get_swing_mode_off_trigger() const;
|
Trigger<> *get_swing_mode_off_trigger() const;
|
||||||
Trigger<> *get_swing_mode_vertical_trigger() const;
|
Trigger<> *get_swing_mode_vertical_trigger() const;
|
||||||
|
Trigger<> *get_humidity_change_trigger() const;
|
||||||
Trigger<> *get_temperature_change_trigger() const;
|
Trigger<> *get_temperature_change_trigger() const;
|
||||||
Trigger<> *get_preset_change_trigger() const;
|
Trigger<> *get_preset_change_trigger() const;
|
||||||
|
Trigger<> *get_humidity_control_dehumidify_action_trigger() const;
|
||||||
|
Trigger<> *get_humidity_control_humidify_action_trigger() const;
|
||||||
|
Trigger<> *get_humidity_control_off_action_trigger() const;
|
||||||
/// Get current hysteresis values
|
/// Get current hysteresis values
|
||||||
float cool_deadband();
|
float cool_deadband();
|
||||||
float cool_overrun();
|
float cool_overrun();
|
||||||
@@ -166,11 +180,13 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
climate::ClimateFanMode locked_fan_mode();
|
climate::ClimateFanMode locked_fan_mode();
|
||||||
/// Set point and hysteresis validation
|
/// Set point and hysteresis validation
|
||||||
bool hysteresis_valid(); // returns true if valid
|
bool hysteresis_valid(); // returns true if valid
|
||||||
|
bool humidity_hysteresis_valid(); // returns true if valid
|
||||||
bool limit_setpoints_for_heat_cool(); // returns true if set points should be further limited within visual range
|
bool limit_setpoints_for_heat_cool(); // returns true if set points should be further limited within visual range
|
||||||
void validate_target_temperature();
|
void validate_target_temperature();
|
||||||
void validate_target_temperatures(bool pin_target_temperature_high);
|
void validate_target_temperatures(bool pin_target_temperature_high);
|
||||||
void validate_target_temperature_low();
|
void validate_target_temperature_low();
|
||||||
void validate_target_temperature_high();
|
void validate_target_temperature_high();
|
||||||
|
void validate_target_humidity();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Override control to change settings of the climate device.
|
/// Override control to change settings of the climate device.
|
||||||
@@ -192,11 +208,13 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// Re-compute the required action of this climate controller.
|
/// Re-compute the required action of this climate controller.
|
||||||
climate::ClimateAction compute_action_(bool ignore_timers = false);
|
climate::ClimateAction compute_action_(bool ignore_timers = false);
|
||||||
climate::ClimateAction compute_supplemental_action_();
|
climate::ClimateAction compute_supplemental_action_();
|
||||||
|
HumidificationAction compute_humidity_control_action_();
|
||||||
|
|
||||||
/// Switch the climate device to the given climate action.
|
/// Switch the climate device to the given climate action.
|
||||||
void switch_to_action_(climate::ClimateAction action, bool publish_state = true);
|
void switch_to_action_(climate::ClimateAction action, bool publish_state = true);
|
||||||
void switch_to_supplemental_action_(climate::ClimateAction action);
|
void switch_to_supplemental_action_(climate::ClimateAction action);
|
||||||
void trigger_supplemental_action_();
|
void trigger_supplemental_action_();
|
||||||
|
void switch_to_humidity_control_action_(HumidificationAction action);
|
||||||
|
|
||||||
/// Switch the climate device to the given climate fan mode.
|
/// Switch the climate device to the given climate fan mode.
|
||||||
void switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bool publish_state = true);
|
void switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bool publish_state = true);
|
||||||
@@ -207,6 +225,9 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// Switch the climate device to the given climate swing mode.
|
/// Switch the climate device to the given climate swing mode.
|
||||||
void switch_to_swing_mode_(climate::ClimateSwingMode swing_mode, bool publish_state = true);
|
void switch_to_swing_mode_(climate::ClimateSwingMode swing_mode, bool publish_state = true);
|
||||||
|
|
||||||
|
/// Check if the humidity change trigger should be called.
|
||||||
|
void check_humidity_change_trigger_();
|
||||||
|
|
||||||
/// Check if the temperature change trigger should be called.
|
/// Check if the temperature change trigger should be called.
|
||||||
void check_temperature_change_trigger_();
|
void check_temperature_change_trigger_();
|
||||||
|
|
||||||
@@ -243,6 +264,8 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
bool heating_required_();
|
bool heating_required_();
|
||||||
bool supplemental_cooling_required_();
|
bool supplemental_cooling_required_();
|
||||||
bool supplemental_heating_required_();
|
bool supplemental_heating_required_();
|
||||||
|
bool dehumidification_required_();
|
||||||
|
bool humidification_required_();
|
||||||
|
|
||||||
void dump_preset_config_(const char *preset_name, const ThermostatClimateTargetTempConfig &config);
|
void dump_preset_config_(const char *preset_name, const ThermostatClimateTargetTempConfig &config);
|
||||||
|
|
||||||
@@ -259,6 +282,9 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// The current supplemental action
|
/// The current supplemental action
|
||||||
climate::ClimateAction supplemental_action_{climate::CLIMATE_ACTION_OFF};
|
climate::ClimateAction supplemental_action_{climate::CLIMATE_ACTION_OFF};
|
||||||
|
|
||||||
|
/// The current humidification action
|
||||||
|
HumidificationAction humidification_action_{THERMOSTAT_HUMIDITY_CONTROL_ACTION_NONE};
|
||||||
|
|
||||||
/// Default standard preset to use on start up
|
/// Default standard preset to use on start up
|
||||||
climate::ClimatePreset default_preset_{};
|
climate::ClimatePreset default_preset_{};
|
||||||
|
|
||||||
@@ -321,6 +347,12 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// A false value means that the controller has no such support.
|
/// A false value means that the controller has no such support.
|
||||||
bool supports_two_points_{false};
|
bool supports_two_points_{false};
|
||||||
|
|
||||||
|
/// Whether the controller supports dehumidification and/or humidification
|
||||||
|
///
|
||||||
|
/// A false value means that the controller has no such support.
|
||||||
|
bool supports_dehumidification_{false};
|
||||||
|
bool supports_humidification_{false};
|
||||||
|
|
||||||
/// Flags indicating if maximum allowable run time was exceeded
|
/// Flags indicating if maximum allowable run time was exceeded
|
||||||
bool cooling_max_runtime_exceeded_{false};
|
bool cooling_max_runtime_exceeded_{false};
|
||||||
bool heating_max_runtime_exceeded_{false};
|
bool heating_max_runtime_exceeded_{false};
|
||||||
@@ -331,9 +363,10 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// setup_complete_ blocks modifying/resetting the temps immediately after boot
|
/// setup_complete_ blocks modifying/resetting the temps immediately after boot
|
||||||
bool setup_complete_{false};
|
bool setup_complete_{false};
|
||||||
|
|
||||||
/// Store previously-known temperatures
|
/// Store previously-known humidity and temperatures
|
||||||
///
|
///
|
||||||
/// These are used to determine when the temperature change trigger/action needs to be called
|
/// These are used to determine when a temperature/humidity has changed
|
||||||
|
float prev_target_humidity_{NAN};
|
||||||
float prev_target_temperature_{NAN};
|
float prev_target_temperature_{NAN};
|
||||||
float prev_target_temperature_low_{NAN};
|
float prev_target_temperature_low_{NAN};
|
||||||
float prev_target_temperature_high_{NAN};
|
float prev_target_temperature_high_{NAN};
|
||||||
@@ -347,6 +380,9 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
float heating_deadband_{0};
|
float heating_deadband_{0};
|
||||||
float heating_overrun_{0};
|
float heating_overrun_{0};
|
||||||
|
|
||||||
|
/// Hysteresis values used for computing humidification action
|
||||||
|
float humidity_hysteresis_{0};
|
||||||
|
|
||||||
/// Maximum allowable temperature deltas before engaging supplemental cooling/heating actions
|
/// Maximum allowable temperature deltas before engaging supplemental cooling/heating actions
|
||||||
float supplemental_cool_delta_{0};
|
float supplemental_cool_delta_{0};
|
||||||
float supplemental_heat_delta_{0};
|
float supplemental_heat_delta_{0};
|
||||||
@@ -448,12 +484,24 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
/// The trigger to call when the controller should switch the swing mode to "vertical".
|
/// The trigger to call when the controller should switch the swing mode to "vertical".
|
||||||
Trigger<> *swing_mode_vertical_trigger_{nullptr};
|
Trigger<> *swing_mode_vertical_trigger_{nullptr};
|
||||||
|
|
||||||
|
/// The trigger to call when the target humidity changes.
|
||||||
|
Trigger<> *humidity_change_trigger_{nullptr};
|
||||||
|
|
||||||
/// The trigger to call when the target temperature(s) change(es).
|
/// The trigger to call when the target temperature(s) change(es).
|
||||||
Trigger<> *temperature_change_trigger_{nullptr};
|
Trigger<> *temperature_change_trigger_{nullptr};
|
||||||
|
|
||||||
/// The trigger to call when the preset mode changes
|
/// The trigger to call when the preset mode changes
|
||||||
Trigger<> *preset_change_trigger_{nullptr};
|
Trigger<> *preset_change_trigger_{nullptr};
|
||||||
|
|
||||||
|
/// The trigger to call when dehumidification is required
|
||||||
|
Trigger<> *humidity_control_dehumidify_action_trigger_{nullptr};
|
||||||
|
|
||||||
|
/// The trigger to call when humidification is required
|
||||||
|
Trigger<> *humidity_control_humidify_action_trigger_{nullptr};
|
||||||
|
|
||||||
|
/// The trigger to call when (de)humidification should stop
|
||||||
|
Trigger<> *humidity_control_off_action_trigger_{nullptr};
|
||||||
|
|
||||||
/// A reference to the trigger that was previously active.
|
/// A reference to the trigger that was previously active.
|
||||||
///
|
///
|
||||||
/// This is so that the previous trigger can be stopped before enabling a new one
|
/// This is so that the previous trigger can be stopped before enabling a new one
|
||||||
@@ -462,6 +510,7 @@ class ThermostatClimate : public climate::Climate, public Component {
|
|||||||
Trigger<> *prev_fan_mode_trigger_{nullptr};
|
Trigger<> *prev_fan_mode_trigger_{nullptr};
|
||||||
Trigger<> *prev_mode_trigger_{nullptr};
|
Trigger<> *prev_mode_trigger_{nullptr};
|
||||||
Trigger<> *prev_swing_mode_trigger_{nullptr};
|
Trigger<> *prev_swing_mode_trigger_{nullptr};
|
||||||
|
Trigger<> *prev_humidity_control_trigger_{nullptr};
|
||||||
|
|
||||||
/// Default custom preset to use on start up
|
/// Default custom preset to use on start up
|
||||||
std::string default_custom_preset_{};
|
std::string default_custom_preset_{};
|
||||||
|
@@ -14,6 +14,7 @@ MODELS = {
|
|||||||
"GENERIC": Model.MODEL_GENERIC,
|
"GENERIC": Model.MODEL_GENERIC,
|
||||||
"RAC-PT1411HWRU-C": Model.MODEL_RAC_PT1411HWRU_C,
|
"RAC-PT1411HWRU-C": Model.MODEL_RAC_PT1411HWRU_C,
|
||||||
"RAC-PT1411HWRU-F": Model.MODEL_RAC_PT1411HWRU_F,
|
"RAC-PT1411HWRU-F": Model.MODEL_RAC_PT1411HWRU_F,
|
||||||
|
"RAS-2819T": Model.MODEL_RAS_2819T,
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(ToshibaClimate).extend(
|
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(ToshibaClimate).extend(
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "toshiba.h"
|
#include "toshiba.h"
|
||||||
|
#include "esphome/components/remote_base/toshiba_ac_protocol.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -97,6 +98,282 @@ const std::vector<uint8_t> RAC_PT1411HWRU_TEMPERATURE_F{0x10, 0x30, 0x00, 0x20,
|
|||||||
0x22, 0x06, 0x26, 0x07, 0x05, 0x25, 0x04, 0x24, 0x0C,
|
0x22, 0x06, 0x26, 0x07, 0x05, 0x25, 0x04, 0x24, 0x0C,
|
||||||
0x2C, 0x0D, 0x2D, 0x09, 0x08, 0x28, 0x0A, 0x2A, 0x0B};
|
0x2C, 0x0D, 0x2D, 0x09, 0x08, 0x28, 0x0A, 0x2A, 0x0B};
|
||||||
|
|
||||||
|
// RAS-2819T protocol constants
|
||||||
|
const uint16_t RAS_2819T_HEADER1 = 0xC23D;
|
||||||
|
const uint8_t RAS_2819T_HEADER2 = 0xD5;
|
||||||
|
const uint8_t RAS_2819T_MESSAGE_LENGTH = 6;
|
||||||
|
|
||||||
|
// RAS-2819T fan speed codes for rc_code_1 (bytes 2-3)
|
||||||
|
const uint16_t RAS_2819T_FAN_AUTO = 0xBF40;
|
||||||
|
const uint16_t RAS_2819T_FAN_QUIET = 0xFF00;
|
||||||
|
const uint16_t RAS_2819T_FAN_LOW = 0x9F60;
|
||||||
|
const uint16_t RAS_2819T_FAN_MEDIUM = 0x5FA0;
|
||||||
|
const uint16_t RAS_2819T_FAN_HIGH = 0x3FC0;
|
||||||
|
|
||||||
|
// RAS-2819T fan speed codes for rc_code_2 (byte 1)
|
||||||
|
const uint8_t RAS_2819T_FAN2_AUTO = 0x66;
|
||||||
|
const uint8_t RAS_2819T_FAN2_QUIET = 0x01;
|
||||||
|
const uint8_t RAS_2819T_FAN2_LOW = 0x28;
|
||||||
|
const uint8_t RAS_2819T_FAN2_MEDIUM = 0x3C;
|
||||||
|
const uint8_t RAS_2819T_FAN2_HIGH = 0x50;
|
||||||
|
|
||||||
|
// RAS-2819T second packet suffix bytes for rc_code_2 (bytes 3-5)
|
||||||
|
// These are fixed patterns, not actual checksums
|
||||||
|
struct Ras2819tPacketSuffix {
|
||||||
|
uint8_t byte3;
|
||||||
|
uint8_t byte4;
|
||||||
|
uint8_t byte5;
|
||||||
|
};
|
||||||
|
const Ras2819tPacketSuffix RAS_2819T_SUFFIX_AUTO{0x00, 0x02, 0x3D};
|
||||||
|
const Ras2819tPacketSuffix RAS_2819T_SUFFIX_QUIET{0x00, 0x02, 0xD8};
|
||||||
|
const Ras2819tPacketSuffix RAS_2819T_SUFFIX_LOW{0x00, 0x02, 0xFF};
|
||||||
|
const Ras2819tPacketSuffix RAS_2819T_SUFFIX_MEDIUM{0x00, 0x02, 0x13};
|
||||||
|
const Ras2819tPacketSuffix RAS_2819T_SUFFIX_HIGH{0x00, 0x02, 0x27};
|
||||||
|
|
||||||
|
// RAS-2819T swing toggle command
|
||||||
|
const uint64_t RAS_2819T_SWING_TOGGLE = 0xC23D6B94E01F;
|
||||||
|
|
||||||
|
// RAS-2819T single-packet commands
|
||||||
|
const uint64_t RAS_2819T_POWER_OFF_COMMAND = 0xC23D7B84E01F;
|
||||||
|
|
||||||
|
// RAS-2819T known valid command patterns for validation
|
||||||
|
const std::array<uint64_t, 2> RAS_2819T_VALID_SINGLE_COMMANDS = {
|
||||||
|
RAS_2819T_POWER_OFF_COMMAND, // Power off
|
||||||
|
RAS_2819T_SWING_TOGGLE, // Swing toggle
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t RAS_2819T_VALID_HEADER1 = 0xC23D;
|
||||||
|
const uint8_t RAS_2819T_VALID_HEADER2 = 0xD5;
|
||||||
|
|
||||||
|
const uint8_t RAS_2819T_DRY_BYTE2 = 0x1F;
|
||||||
|
const uint8_t RAS_2819T_DRY_BYTE3 = 0xE0;
|
||||||
|
const uint8_t RAS_2819T_DRY_TEMP_OFFSET = 0x24;
|
||||||
|
|
||||||
|
const uint8_t RAS_2819T_AUTO_BYTE2 = 0x1F;
|
||||||
|
const uint8_t RAS_2819T_AUTO_BYTE3 = 0xE0;
|
||||||
|
const uint8_t RAS_2819T_AUTO_TEMP_OFFSET = 0x08;
|
||||||
|
|
||||||
|
const uint8_t RAS_2819T_FAN_ONLY_TEMP = 0xE4;
|
||||||
|
const uint8_t RAS_2819T_FAN_ONLY_TEMP_INV = 0x1B;
|
||||||
|
|
||||||
|
const uint8_t RAS_2819T_HEAT_TEMP_OFFSET = 0x0C;
|
||||||
|
|
||||||
|
// RAS-2819T second packet fixed values
|
||||||
|
const uint8_t RAS_2819T_AUTO_DRY_FAN_BYTE = 0x65;
|
||||||
|
const uint8_t RAS_2819T_AUTO_DRY_SUFFIX = 0x3A;
|
||||||
|
const uint8_t RAS_2819T_HEAT_SUFFIX = 0x3B;
|
||||||
|
|
||||||
|
// RAS-2819T temperature codes for 18-30°C
|
||||||
|
static const uint8_t RAS_2819T_TEMP_CODES[] = {
|
||||||
|
0x10, // 18°C
|
||||||
|
0x30, // 19°C
|
||||||
|
0x20, // 20°C
|
||||||
|
0x60, // 21°C
|
||||||
|
0x70, // 22°C
|
||||||
|
0x50, // 23°C
|
||||||
|
0x40, // 24°C
|
||||||
|
0xC0, // 25°C
|
||||||
|
0xD0, // 26°C
|
||||||
|
0x90, // 27°C
|
||||||
|
0x80, // 28°C
|
||||||
|
0xA0, // 29°C
|
||||||
|
0xB0 // 30°C
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper functions for RAS-2819T protocol
|
||||||
|
//
|
||||||
|
// ===== RAS-2819T PROTOCOL DOCUMENTATION =====
|
||||||
|
//
|
||||||
|
// The RAS-2819T uses a two-packet IR protocol with some exceptions for simple commands.
|
||||||
|
//
|
||||||
|
// PACKET STRUCTURE:
|
||||||
|
// All packets are 6 bytes (48 bits) transmitted with standard Toshiba timing.
|
||||||
|
//
|
||||||
|
// TWO-PACKET COMMANDS (Mode/Temperature/Fan changes):
|
||||||
|
//
|
||||||
|
// First Packet (rc_code_1): [C2 3D] [FAN_HI FAN_LO] [TEMP] [~TEMP]
|
||||||
|
// Byte 0-1: Header (always 0xC23D)
|
||||||
|
// Byte 2-3: Fan speed encoding (varies by mode, see fan tables below)
|
||||||
|
// Byte 4: Temperature + mode encoding
|
||||||
|
// Byte 5: Bitwise complement of temperature byte
|
||||||
|
//
|
||||||
|
// Second Packet (rc_code_2): [D5] [FAN2] [00] [SUF1] [SUF2] [SUF3]
|
||||||
|
// Byte 0: Header (always 0xD5)
|
||||||
|
// Byte 1: Fan speed secondary encoding
|
||||||
|
// Byte 2: Always 0x00
|
||||||
|
// Byte 3-5: Fixed suffix pattern (depends on fan speed and mode)
|
||||||
|
//
|
||||||
|
// TEMPERATURE ENCODING:
|
||||||
|
// Base temp codes: 18°C=0x10, 19°C=0x30, 20°C=0x20, 21°C=0x60, 22°C=0x70,
|
||||||
|
// 23°C=0x50, 24°C=0x40, 25°C=0xC0, 26°C=0xD0, 27°C=0x90,
|
||||||
|
// 28°C=0x80, 29°C=0xA0, 30°C=0xB0
|
||||||
|
// Mode offsets added to base temp:
|
||||||
|
// COOL: No offset
|
||||||
|
// HEAT: +0x0C (e.g., 24°C heat = 0x40 | 0x0C = 0x4C)
|
||||||
|
// AUTO: +0x08 (e.g., 24°C auto = 0x40 | 0x08 = 0x48)
|
||||||
|
// DRY: +0x24 (e.g., 24°C dry = 0x40 | 0x24 = 0x64)
|
||||||
|
//
|
||||||
|
// FAN SPEED ENCODING (First packet bytes 2-3):
|
||||||
|
// AUTO: 0xBF40, QUIET: 0xFF00, LOW: 0x9F60, MEDIUM: 0x5FA0, HIGH: 0x3FC0
|
||||||
|
// Special cases: AUTO/DRY modes use 0x1FE0 instead
|
||||||
|
//
|
||||||
|
// SINGLE-PACKET COMMANDS:
|
||||||
|
// Power Off: 0xC23D7B84E01F (6 bytes, no second packet)
|
||||||
|
// Swing Toggle: 0xC23D6B94E01F (6 bytes, no second packet)
|
||||||
|
//
|
||||||
|
// MODE DETECTION (from first packet):
|
||||||
|
// - Check bytes 2-3: if 0x7B84 → OFF mode
|
||||||
|
// - Check bytes 2-3: if 0x1FE0 → AUTO/DRY/low-temp-COOL (distinguish by temp code)
|
||||||
|
// - Otherwise: COOL/HEAT/FAN_ONLY (distinguish by temp code and byte 5)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fan speed encoding for RAS-2819T first packet (rc_code_1, bytes 2-3)
|
||||||
|
*/
|
||||||
|
static uint16_t get_ras_2819t_fan_code(climate::ClimateFanMode fan_mode) {
|
||||||
|
switch (fan_mode) {
|
||||||
|
case climate::CLIMATE_FAN_QUIET:
|
||||||
|
return RAS_2819T_FAN_QUIET;
|
||||||
|
case climate::CLIMATE_FAN_LOW:
|
||||||
|
return RAS_2819T_FAN_LOW;
|
||||||
|
case climate::CLIMATE_FAN_MEDIUM:
|
||||||
|
return RAS_2819T_FAN_MEDIUM;
|
||||||
|
case climate::CLIMATE_FAN_HIGH:
|
||||||
|
return RAS_2819T_FAN_HIGH;
|
||||||
|
case climate::CLIMATE_FAN_AUTO:
|
||||||
|
default:
|
||||||
|
return RAS_2819T_FAN_AUTO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fan speed encoding for RAS-2819T rc_code_2 packet (second packet)
|
||||||
|
*/
|
||||||
|
struct Ras2819tSecondPacketCodes {
|
||||||
|
uint8_t fan_byte;
|
||||||
|
Ras2819tPacketSuffix suffix;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Ras2819tSecondPacketCodes get_ras_2819t_second_packet_codes(climate::ClimateFanMode fan_mode) {
|
||||||
|
switch (fan_mode) {
|
||||||
|
case climate::CLIMATE_FAN_QUIET:
|
||||||
|
return {RAS_2819T_FAN2_QUIET, RAS_2819T_SUFFIX_QUIET};
|
||||||
|
case climate::CLIMATE_FAN_LOW:
|
||||||
|
return {RAS_2819T_FAN2_LOW, RAS_2819T_SUFFIX_LOW};
|
||||||
|
case climate::CLIMATE_FAN_MEDIUM:
|
||||||
|
return {RAS_2819T_FAN2_MEDIUM, RAS_2819T_SUFFIX_MEDIUM};
|
||||||
|
case climate::CLIMATE_FAN_HIGH:
|
||||||
|
return {RAS_2819T_FAN2_HIGH, RAS_2819T_SUFFIX_HIGH};
|
||||||
|
case climate::CLIMATE_FAN_AUTO:
|
||||||
|
default:
|
||||||
|
return {RAS_2819T_FAN2_AUTO, RAS_2819T_SUFFIX_AUTO};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get temperature code for RAS-2819T protocol
|
||||||
|
*/
|
||||||
|
static uint8_t get_ras_2819t_temp_code(float temperature) {
|
||||||
|
int temp_index = static_cast<int>(temperature) - 18;
|
||||||
|
if (temp_index < 0 || temp_index >= static_cast<int>(sizeof(RAS_2819T_TEMP_CODES))) {
|
||||||
|
ESP_LOGW(TAG, "Temperature %.1f°C out of range [18-30°C], defaulting to 24°C", temperature);
|
||||||
|
return 0x40; // Default to 24°C
|
||||||
|
}
|
||||||
|
|
||||||
|
return RAS_2819T_TEMP_CODES[temp_index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode temperature from RAS-2819T temp code
|
||||||
|
*/
|
||||||
|
static float decode_ras_2819t_temperature(uint8_t temp_code) {
|
||||||
|
uint8_t base_temp_code = temp_code & 0xF0;
|
||||||
|
|
||||||
|
// Find the code in the temperature array
|
||||||
|
for (size_t temp_index = 0; temp_index < sizeof(RAS_2819T_TEMP_CODES); temp_index++) {
|
||||||
|
if (RAS_2819T_TEMP_CODES[temp_index] == base_temp_code) {
|
||||||
|
return static_cast<float>(temp_index + 18); // 18°C is the minimum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_LOGW(TAG, "Unknown temp code: 0x%02X, defaulting to 24°C", base_temp_code);
|
||||||
|
return 24.0f; // Default to 24°C
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode fan speed from RAS-2819T IR codes
|
||||||
|
*/
|
||||||
|
static climate::ClimateFanMode decode_ras_2819t_fan_mode(uint16_t fan_code) {
|
||||||
|
switch (fan_code) {
|
||||||
|
case RAS_2819T_FAN_QUIET:
|
||||||
|
return climate::CLIMATE_FAN_QUIET;
|
||||||
|
case RAS_2819T_FAN_LOW:
|
||||||
|
return climate::CLIMATE_FAN_LOW;
|
||||||
|
case RAS_2819T_FAN_MEDIUM:
|
||||||
|
return climate::CLIMATE_FAN_MEDIUM;
|
||||||
|
case RAS_2819T_FAN_HIGH:
|
||||||
|
return climate::CLIMATE_FAN_HIGH;
|
||||||
|
case RAS_2819T_FAN_AUTO:
|
||||||
|
default:
|
||||||
|
return climate::CLIMATE_FAN_AUTO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate RAS-2819T IR command structure and content
|
||||||
|
*/
|
||||||
|
static bool is_valid_ras_2819t_command(uint64_t rc_code_1, uint64_t rc_code_2 = 0) {
|
||||||
|
// Check header of first packet
|
||||||
|
uint16_t header1 = (rc_code_1 >> 32) & 0xFFFF;
|
||||||
|
if (header1 != RAS_2819T_VALID_HEADER1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single packet commands
|
||||||
|
if (rc_code_2 == 0) {
|
||||||
|
for (uint64_t valid_cmd : RAS_2819T_VALID_SINGLE_COMMANDS) {
|
||||||
|
if (rc_code_1 == valid_cmd) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Additional validation for unknown single packets
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two-packet commands - validate second packet header
|
||||||
|
uint8_t header2 = (rc_code_2 >> 40) & 0xFF;
|
||||||
|
if (header2 != RAS_2819T_VALID_HEADER2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate temperature complement in first packet (byte 4 should be ~byte 5)
|
||||||
|
uint8_t temp_byte = (rc_code_1 >> 8) & 0xFF;
|
||||||
|
uint8_t temp_complement = rc_code_1 & 0xFF;
|
||||||
|
if (temp_byte != static_cast<uint8_t>(~temp_complement)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate fan speed combinations make sense
|
||||||
|
uint16_t fan_code = (rc_code_1 >> 16) & 0xFFFF;
|
||||||
|
uint8_t fan2_byte = (rc_code_2 >> 32) & 0xFF;
|
||||||
|
|
||||||
|
// Check if fan codes are from known valid patterns
|
||||||
|
bool valid_fan_combo = false;
|
||||||
|
if (fan_code == RAS_2819T_FAN_AUTO && fan2_byte == RAS_2819T_FAN2_AUTO)
|
||||||
|
valid_fan_combo = true;
|
||||||
|
if (fan_code == RAS_2819T_FAN_QUIET && fan2_byte == RAS_2819T_FAN2_QUIET)
|
||||||
|
valid_fan_combo = true;
|
||||||
|
if (fan_code == RAS_2819T_FAN_LOW && fan2_byte == RAS_2819T_FAN2_LOW)
|
||||||
|
valid_fan_combo = true;
|
||||||
|
if (fan_code == RAS_2819T_FAN_MEDIUM && fan2_byte == RAS_2819T_FAN2_MEDIUM)
|
||||||
|
valid_fan_combo = true;
|
||||||
|
if (fan_code == RAS_2819T_FAN_HIGH && fan2_byte == RAS_2819T_FAN2_HIGH)
|
||||||
|
valid_fan_combo = true;
|
||||||
|
if (fan_code == 0x1FE0 && fan2_byte == RAS_2819T_AUTO_DRY_FAN_BYTE)
|
||||||
|
valid_fan_combo = true; // AUTO/DRY
|
||||||
|
|
||||||
|
return valid_fan_combo;
|
||||||
|
}
|
||||||
|
|
||||||
void ToshibaClimate::setup() {
|
void ToshibaClimate::setup() {
|
||||||
if (this->sensor_) {
|
if (this->sensor_) {
|
||||||
this->sensor_->add_on_state_callback([this](float state) {
|
this->sensor_->add_on_state_callback([this](float state) {
|
||||||
@@ -126,16 +403,43 @@ void ToshibaClimate::setup() {
|
|||||||
this->minimum_temperature_ = this->temperature_min_();
|
this->minimum_temperature_ = this->temperature_min_();
|
||||||
this->maximum_temperature_ = this->temperature_max_();
|
this->maximum_temperature_ = this->temperature_max_();
|
||||||
this->swing_modes_ = this->toshiba_swing_modes_();
|
this->swing_modes_ = this->toshiba_swing_modes_();
|
||||||
|
|
||||||
|
// Ensure swing mode is always initialized to a valid value
|
||||||
|
if (this->swing_modes_.empty() || this->swing_modes_.find(this->swing_mode) == this->swing_modes_.end()) {
|
||||||
|
// No swing support for this model or current swing mode not supported, reset to OFF
|
||||||
|
this->swing_mode = climate::CLIMATE_SWING_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure mode is valid - ESPHome should only use standard climate modes
|
||||||
|
if (this->mode != climate::CLIMATE_MODE_OFF && this->mode != climate::CLIMATE_MODE_HEAT &&
|
||||||
|
this->mode != climate::CLIMATE_MODE_COOL && this->mode != climate::CLIMATE_MODE_HEAT_COOL &&
|
||||||
|
this->mode != climate::CLIMATE_MODE_DRY && this->mode != climate::CLIMATE_MODE_FAN_ONLY) {
|
||||||
|
ESP_LOGW(TAG, "Invalid mode detected during setup, resetting to OFF");
|
||||||
|
this->mode = climate::CLIMATE_MODE_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure fan mode is valid
|
||||||
|
if (!this->fan_mode.has_value()) {
|
||||||
|
ESP_LOGW(TAG, "Fan mode not set during setup, defaulting to AUTO");
|
||||||
|
this->fan_mode = climate::CLIMATE_FAN_AUTO;
|
||||||
|
}
|
||||||
|
|
||||||
// Never send nan to HA
|
// Never send nan to HA
|
||||||
if (std::isnan(this->target_temperature))
|
if (std::isnan(this->target_temperature))
|
||||||
this->target_temperature = 24;
|
this->target_temperature = 24;
|
||||||
|
// Log final state for debugging HA errors
|
||||||
|
ESP_LOGV(TAG, "Setup complete - Mode: %d, Fan: %s, Swing: %d, Temp: %.1f", static_cast<int>(this->mode),
|
||||||
|
this->fan_mode.has_value() ? std::to_string(static_cast<int>(this->fan_mode.value())).c_str() : "NONE",
|
||||||
|
static_cast<int>(this->swing_mode), this->target_temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToshibaClimate::transmit_state() {
|
void ToshibaClimate::transmit_state() {
|
||||||
if (this->model_ == MODEL_RAC_PT1411HWRU_C || this->model_ == MODEL_RAC_PT1411HWRU_F) {
|
if (this->model_ == MODEL_RAC_PT1411HWRU_C || this->model_ == MODEL_RAC_PT1411HWRU_F) {
|
||||||
transmit_rac_pt1411hwru_();
|
this->transmit_rac_pt1411hwru_();
|
||||||
|
} else if (this->model_ == MODEL_RAS_2819T) {
|
||||||
|
this->transmit_ras_2819t_();
|
||||||
} else {
|
} else {
|
||||||
transmit_generic_();
|
this->transmit_generic_();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +534,7 @@ void ToshibaClimate::transmit_generic_() {
|
|||||||
auto transmit = this->transmitter_->transmit();
|
auto transmit = this->transmitter_->transmit();
|
||||||
auto *data = transmit.get_data();
|
auto *data = transmit.get_data();
|
||||||
|
|
||||||
encode_(data, message, message_length, 1);
|
this->encode_(data, message, message_length, 1);
|
||||||
|
|
||||||
transmit.perform();
|
transmit.perform();
|
||||||
}
|
}
|
||||||
@@ -348,15 +652,12 @@ void ToshibaClimate::transmit_rac_pt1411hwru_() {
|
|||||||
message[11] += message[index];
|
message[11] += message[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGV(TAG, "*** Generated codes: 0x%.2X%.2X%.2X%.2X%.2X%.2X 0x%.2X%.2X%.2X%.2X%.2X%.2X", message[0], message[1],
|
|
||||||
message[2], message[3], message[4], message[5], message[6], message[7], message[8], message[9], message[10],
|
|
||||||
message[11]);
|
|
||||||
|
|
||||||
// load first block of IR code and repeat it once
|
// load first block of IR code and repeat it once
|
||||||
encode_(data, &message[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
this->encode_(data, &message[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
||||||
// load second block of IR code, if present
|
// load second block of IR code, if present
|
||||||
if (message[6] != 0) {
|
if (message[6] != 0) {
|
||||||
encode_(data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH, 0);
|
this->encode_(data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
transmit.perform();
|
transmit.perform();
|
||||||
@@ -366,19 +667,19 @@ void ToshibaClimate::transmit_rac_pt1411hwru_() {
|
|||||||
data->space(TOSHIBA_PACKET_SPACE);
|
data->space(TOSHIBA_PACKET_SPACE);
|
||||||
switch (this->swing_mode) {
|
switch (this->swing_mode) {
|
||||||
case climate::CLIMATE_SWING_VERTICAL:
|
case climate::CLIMATE_SWING_VERTICAL:
|
||||||
encode_(data, &RAC_PT1411HWRU_SWING_VERTICAL[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
this->encode_(data, &RAC_PT1411HWRU_SWING_VERTICAL[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case climate::CLIMATE_SWING_OFF:
|
case climate::CLIMATE_SWING_OFF:
|
||||||
default:
|
default:
|
||||||
encode_(data, &RAC_PT1411HWRU_SWING_OFF[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
this->encode_(data, &RAC_PT1411HWRU_SWING_OFF[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->space(TOSHIBA_PACKET_SPACE);
|
data->space(TOSHIBA_PACKET_SPACE);
|
||||||
transmit.perform();
|
transmit.perform();
|
||||||
|
|
||||||
if (this->sensor_) {
|
if (this->sensor_) {
|
||||||
transmit_rac_pt1411hwru_temp_(true, false);
|
this->transmit_rac_pt1411hwru_temp_(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,15 +731,217 @@ void ToshibaClimate::transmit_rac_pt1411hwru_temp_(const bool cs_state, const bo
|
|||||||
// Byte 5: Footer lower/bitwise complement of byte 4
|
// Byte 5: Footer lower/bitwise complement of byte 4
|
||||||
message[5] = ~message[4];
|
message[5] = ~message[4];
|
||||||
|
|
||||||
ESP_LOGV(TAG, "*** Generated code: 0x%.2X%.2X%.2X%.2X%.2X%.2X", message[0], message[1], message[2], message[3],
|
|
||||||
message[4], message[5]);
|
|
||||||
// load IR code and repeat it once
|
// load IR code and repeat it once
|
||||||
encode_(data, message, RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
this->encode_(data, message, RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
|
||||||
|
|
||||||
transmit.perform();
|
transmit.perform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToshibaClimate::transmit_ras_2819t_() {
|
||||||
|
// Handle swing mode transmission for RAS-2819T
|
||||||
|
// Note: RAS-2819T uses a toggle command, so we need to track state changes
|
||||||
|
|
||||||
|
// Check if ONLY swing mode changed (and no other climate parameters)
|
||||||
|
bool swing_changed = (this->swing_mode != this->last_swing_mode_);
|
||||||
|
bool mode_changed = (this->mode != this->last_mode_);
|
||||||
|
bool fan_changed = (this->fan_mode != this->last_fan_mode_);
|
||||||
|
bool temp_changed = (abs(this->target_temperature - this->last_target_temperature_) > 0.1f);
|
||||||
|
|
||||||
|
bool only_swing_changed = swing_changed && !mode_changed && !fan_changed && !temp_changed;
|
||||||
|
|
||||||
|
if (only_swing_changed) {
|
||||||
|
// Send ONLY swing toggle command (like the physical remote does)
|
||||||
|
auto swing_transmit = this->transmitter_->transmit();
|
||||||
|
auto *swing_data = swing_transmit.get_data();
|
||||||
|
|
||||||
|
// Convert toggle command to bytes for transmission
|
||||||
|
uint8_t swing_message[RAS_2819T_MESSAGE_LENGTH];
|
||||||
|
swing_message[0] = (RAS_2819T_SWING_TOGGLE >> 40) & 0xFF;
|
||||||
|
swing_message[1] = (RAS_2819T_SWING_TOGGLE >> 32) & 0xFF;
|
||||||
|
swing_message[2] = (RAS_2819T_SWING_TOGGLE >> 24) & 0xFF;
|
||||||
|
swing_message[3] = (RAS_2819T_SWING_TOGGLE >> 16) & 0xFF;
|
||||||
|
swing_message[4] = (RAS_2819T_SWING_TOGGLE >> 8) & 0xFF;
|
||||||
|
swing_message[5] = RAS_2819T_SWING_TOGGLE & 0xFF;
|
||||||
|
|
||||||
|
// Use single packet transmission WITH repeat (like regular commands)
|
||||||
|
this->encode_(swing_data, swing_message, RAS_2819T_MESSAGE_LENGTH, 1);
|
||||||
|
swing_transmit.perform();
|
||||||
|
|
||||||
|
// Update all state tracking
|
||||||
|
this->last_swing_mode_ = this->swing_mode;
|
||||||
|
this->last_mode_ = this->mode;
|
||||||
|
this->last_fan_mode_ = this->fan_mode;
|
||||||
|
this->last_target_temperature_ = this->target_temperature;
|
||||||
|
|
||||||
|
// Immediately publish the state change to Home Assistant
|
||||||
|
this->publish_state();
|
||||||
|
|
||||||
|
return; // Exit early - don't send climate command
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, send the regular climate command (temperature/mode/fan)
|
||||||
|
uint8_t message1[RAS_2819T_MESSAGE_LENGTH] = {0};
|
||||||
|
uint8_t message2[RAS_2819T_MESSAGE_LENGTH] = {0};
|
||||||
|
float temperature =
|
||||||
|
clamp<float>(this->target_temperature, TOSHIBA_RAS_2819T_TEMP_C_MIN, TOSHIBA_RAS_2819T_TEMP_C_MAX);
|
||||||
|
|
||||||
|
// Build first packet (RAS_2819T_HEADER1 + 4 bytes)
|
||||||
|
message1[0] = (RAS_2819T_HEADER1 >> 8) & 0xFF;
|
||||||
|
message1[1] = RAS_2819T_HEADER1 & 0xFF;
|
||||||
|
|
||||||
|
// Handle OFF mode
|
||||||
|
if (this->mode == climate::CLIMATE_MODE_OFF) {
|
||||||
|
// Extract bytes from power off command constant
|
||||||
|
message1[2] = (RAS_2819T_POWER_OFF_COMMAND >> 24) & 0xFF;
|
||||||
|
message1[3] = (RAS_2819T_POWER_OFF_COMMAND >> 16) & 0xFF;
|
||||||
|
message1[4] = (RAS_2819T_POWER_OFF_COMMAND >> 8) & 0xFF;
|
||||||
|
message1[5] = RAS_2819T_POWER_OFF_COMMAND & 0xFF;
|
||||||
|
// No second packet for OFF
|
||||||
|
} else {
|
||||||
|
// Get temperature and fan encoding
|
||||||
|
uint8_t temp_code = get_ras_2819t_temp_code(temperature);
|
||||||
|
|
||||||
|
// Get fan speed encoding for rc_code_1
|
||||||
|
climate::ClimateFanMode effective_fan_mode = this->fan_mode.value();
|
||||||
|
|
||||||
|
// Dry mode only supports AUTO fan speed
|
||||||
|
if (this->mode == climate::CLIMATE_MODE_DRY) {
|
||||||
|
effective_fan_mode = climate::CLIMATE_FAN_AUTO;
|
||||||
|
if (this->fan_mode.value() != climate::CLIMATE_FAN_AUTO) {
|
||||||
|
ESP_LOGW(TAG, "Dry mode only supports AUTO fan speed, forcing AUTO");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t fan_code = get_ras_2819t_fan_code(effective_fan_mode);
|
||||||
|
|
||||||
|
// Mode and temperature encoding
|
||||||
|
switch (this->mode) {
|
||||||
|
case climate::CLIMATE_MODE_COOL:
|
||||||
|
// All cooling temperatures support fan speed control
|
||||||
|
message1[2] = (fan_code >> 8) & 0xFF;
|
||||||
|
message1[3] = fan_code & 0xFF;
|
||||||
|
message1[4] = temp_code;
|
||||||
|
message1[5] = ~temp_code;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_HEAT:
|
||||||
|
// Heating supports fan speed control
|
||||||
|
message1[2] = (fan_code >> 8) & 0xFF;
|
||||||
|
message1[3] = fan_code & 0xFF;
|
||||||
|
// Heat mode adds offset to temperature code
|
||||||
|
message1[4] = temp_code | RAS_2819T_HEAT_TEMP_OFFSET;
|
||||||
|
message1[5] = ~(temp_code | RAS_2819T_HEAT_TEMP_OFFSET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_HEAT_COOL:
|
||||||
|
// Auto mode uses fixed encoding
|
||||||
|
message1[2] = RAS_2819T_AUTO_BYTE2;
|
||||||
|
message1[3] = RAS_2819T_AUTO_BYTE3;
|
||||||
|
message1[4] = temp_code | RAS_2819T_AUTO_TEMP_OFFSET;
|
||||||
|
message1[5] = ~(temp_code | RAS_2819T_AUTO_TEMP_OFFSET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_DRY:
|
||||||
|
// Dry mode uses fixed encoding and forces AUTO fan
|
||||||
|
message1[2] = RAS_2819T_DRY_BYTE2;
|
||||||
|
message1[3] = RAS_2819T_DRY_BYTE3;
|
||||||
|
message1[4] = temp_code | RAS_2819T_DRY_TEMP_OFFSET;
|
||||||
|
message1[5] = ~message1[4];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_FAN_ONLY:
|
||||||
|
// Fan only mode supports fan speed control
|
||||||
|
message1[2] = (fan_code >> 8) & 0xFF;
|
||||||
|
message1[3] = fan_code & 0xFF;
|
||||||
|
message1[4] = RAS_2819T_FAN_ONLY_TEMP;
|
||||||
|
message1[5] = RAS_2819T_FAN_ONLY_TEMP_INV;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default case supports fan speed control
|
||||||
|
message1[2] = (fan_code >> 8) & 0xFF;
|
||||||
|
message1[3] = fan_code & 0xFF;
|
||||||
|
message1[4] = temp_code;
|
||||||
|
message1[5] = ~temp_code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build second packet (RAS_2819T_HEADER2 + 4 bytes)
|
||||||
|
message2[0] = RAS_2819T_HEADER2;
|
||||||
|
|
||||||
|
// Get fan speed encoding for rc_code_2
|
||||||
|
Ras2819tSecondPacketCodes second_packet_codes = get_ras_2819t_second_packet_codes(effective_fan_mode);
|
||||||
|
|
||||||
|
// Determine header byte 2 and fan encoding based on mode
|
||||||
|
switch (this->mode) {
|
||||||
|
case climate::CLIMATE_MODE_COOL:
|
||||||
|
message2[1] = second_packet_codes.fan_byte;
|
||||||
|
message2[2] = 0x00;
|
||||||
|
message2[3] = second_packet_codes.suffix.byte3;
|
||||||
|
message2[4] = second_packet_codes.suffix.byte4;
|
||||||
|
message2[5] = second_packet_codes.suffix.byte5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_HEAT:
|
||||||
|
message2[1] = second_packet_codes.fan_byte;
|
||||||
|
message2[2] = 0x00;
|
||||||
|
message2[3] = second_packet_codes.suffix.byte3;
|
||||||
|
message2[4] = 0x00;
|
||||||
|
message2[5] = RAS_2819T_HEAT_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_HEAT_COOL:
|
||||||
|
case climate::CLIMATE_MODE_DRY:
|
||||||
|
// Auto/Dry modes use fixed values regardless of fan setting
|
||||||
|
message2[1] = RAS_2819T_AUTO_DRY_FAN_BYTE;
|
||||||
|
message2[2] = 0x00;
|
||||||
|
message2[3] = 0x00;
|
||||||
|
message2[4] = 0x00;
|
||||||
|
message2[5] = RAS_2819T_AUTO_DRY_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case climate::CLIMATE_MODE_FAN_ONLY:
|
||||||
|
message2[1] = second_packet_codes.fan_byte;
|
||||||
|
message2[2] = 0x00;
|
||||||
|
message2[3] = second_packet_codes.suffix.byte3;
|
||||||
|
message2[4] = 0x00;
|
||||||
|
message2[5] = RAS_2819T_HEAT_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
message2[1] = second_packet_codes.fan_byte;
|
||||||
|
message2[2] = 0x00;
|
||||||
|
message2[3] = second_packet_codes.suffix.byte3;
|
||||||
|
message2[4] = second_packet_codes.suffix.byte4;
|
||||||
|
message2[5] = second_packet_codes.suffix.byte5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log final messages being transmitted
|
||||||
|
|
||||||
|
// Transmit using proper Toshiba protocol timing
|
||||||
|
auto transmit = this->transmitter_->transmit();
|
||||||
|
auto *data = transmit.get_data();
|
||||||
|
|
||||||
|
// Use existing Toshiba encode function for proper timing
|
||||||
|
this->encode_(data, message1, RAS_2819T_MESSAGE_LENGTH, 1);
|
||||||
|
|
||||||
|
if (this->mode != climate::CLIMATE_MODE_OFF) {
|
||||||
|
// Send second packet with gap
|
||||||
|
this->encode_(data, message2, RAS_2819T_MESSAGE_LENGTH, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
transmit.perform();
|
||||||
|
|
||||||
|
// Update all state tracking after successful transmission
|
||||||
|
this->last_swing_mode_ = this->swing_mode;
|
||||||
|
this->last_mode_ = this->mode;
|
||||||
|
this->last_fan_mode_ = this->fan_mode;
|
||||||
|
this->last_target_temperature_ = this->target_temperature;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t ToshibaClimate::is_valid_rac_pt1411hwru_header_(const uint8_t *message) {
|
uint8_t ToshibaClimate::is_valid_rac_pt1411hwru_header_(const uint8_t *message) {
|
||||||
const std::vector<uint8_t> header{RAC_PT1411HWRU_MESSAGE_HEADER0, RAC_PT1411HWRU_CS_HEADER,
|
const std::vector<uint8_t> header{RAC_PT1411HWRU_MESSAGE_HEADER0, RAC_PT1411HWRU_CS_HEADER,
|
||||||
RAC_PT1411HWRU_SWING_HEADER};
|
RAC_PT1411HWRU_SWING_HEADER};
|
||||||
@@ -464,11 +967,11 @@ bool ToshibaClimate::compare_rac_pt1411hwru_packets_(const uint8_t *message1, co
|
|||||||
bool ToshibaClimate::is_valid_rac_pt1411hwru_message_(const uint8_t *message) {
|
bool ToshibaClimate::is_valid_rac_pt1411hwru_message_(const uint8_t *message) {
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
|
|
||||||
switch (is_valid_rac_pt1411hwru_header_(message)) {
|
switch (this->is_valid_rac_pt1411hwru_header_(message)) {
|
||||||
case RAC_PT1411HWRU_MESSAGE_HEADER0:
|
case RAC_PT1411HWRU_MESSAGE_HEADER0:
|
||||||
case RAC_PT1411HWRU_CS_HEADER:
|
case RAC_PT1411HWRU_CS_HEADER:
|
||||||
case RAC_PT1411HWRU_SWING_HEADER:
|
case RAC_PT1411HWRU_SWING_HEADER:
|
||||||
if (is_valid_rac_pt1411hwru_header_(message) && (message[2] == static_cast<uint8_t>(~message[3])) &&
|
if (this->is_valid_rac_pt1411hwru_header_(message) && (message[2] == static_cast<uint8_t>(~message[3])) &&
|
||||||
(message[4] == static_cast<uint8_t>(~message[5]))) {
|
(message[4] == static_cast<uint8_t>(~message[5]))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -490,7 +993,103 @@ bool ToshibaClimate::is_valid_rac_pt1411hwru_message_(const uint8_t *message) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToshibaClimate::process_ras_2819t_command_(const remote_base::ToshibaAcData &toshiba_data) {
|
||||||
|
// Check for power-off command (single packet)
|
||||||
|
if (toshiba_data.rc_code_2 == 0 && toshiba_data.rc_code_1 == RAS_2819T_POWER_OFF_COMMAND) {
|
||||||
|
this->mode = climate::CLIMATE_MODE_OFF;
|
||||||
|
ESP_LOGI(TAG, "Mode: OFF");
|
||||||
|
this->publish_state();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for swing toggle command (single packet)
|
||||||
|
if (toshiba_data.rc_code_2 == 0 && toshiba_data.rc_code_1 == RAS_2819T_SWING_TOGGLE) {
|
||||||
|
// Toggle swing mode
|
||||||
|
if (this->swing_mode == climate::CLIMATE_SWING_VERTICAL) {
|
||||||
|
this->swing_mode = climate::CLIMATE_SWING_OFF;
|
||||||
|
ESP_LOGI(TAG, "Swing: OFF");
|
||||||
|
} else {
|
||||||
|
this->swing_mode = climate::CLIMATE_SWING_VERTICAL;
|
||||||
|
ESP_LOGI(TAG, "Swing: VERTICAL");
|
||||||
|
}
|
||||||
|
this->publish_state();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle regular two-packet commands (mode/temperature/fan changes)
|
||||||
|
if (toshiba_data.rc_code_2 != 0) {
|
||||||
|
// Convert to byte array for easier processing
|
||||||
|
uint8_t message1[6], message2[6];
|
||||||
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
|
message1[i] = (toshiba_data.rc_code_1 >> (40 - i * 8)) & 0xFF;
|
||||||
|
message2[i] = (toshiba_data.rc_code_2 >> (40 - i * 8)) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the protocol using message1 (rc_code_1)
|
||||||
|
uint8_t temp_code = message1[4];
|
||||||
|
|
||||||
|
// Decode mode - check bytes 2-3 pattern and temperature code
|
||||||
|
if ((message1[2] == 0x7B) && (message1[3] == 0x84)) {
|
||||||
|
// OFF mode has specific pattern
|
||||||
|
this->mode = climate::CLIMATE_MODE_OFF;
|
||||||
|
ESP_LOGI(TAG, "Mode: OFF");
|
||||||
|
} else if ((message1[2] == 0x1F) && (message1[3] == 0xE0)) {
|
||||||
|
// 0x1FE0 pattern is used for AUTO, DRY, and low-temp COOL
|
||||||
|
if ((temp_code & 0x0F) == 0x08) {
|
||||||
|
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
||||||
|
ESP_LOGI(TAG, "Mode: AUTO");
|
||||||
|
} else if ((temp_code & 0x0F) == 0x04) {
|
||||||
|
this->mode = climate::CLIMATE_MODE_DRY;
|
||||||
|
ESP_LOGI(TAG, "Mode: DRY");
|
||||||
|
} else {
|
||||||
|
this->mode = climate::CLIMATE_MODE_COOL;
|
||||||
|
ESP_LOGI(TAG, "Mode: COOL (low temp)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Variable fan speed patterns - decode by temperature code
|
||||||
|
if ((temp_code & 0x0F) == 0x0C) {
|
||||||
|
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||||
|
ESP_LOGI(TAG, "Mode: HEAT");
|
||||||
|
} else if (message1[5] == 0x1B) {
|
||||||
|
this->mode = climate::CLIMATE_MODE_FAN_ONLY;
|
||||||
|
ESP_LOGI(TAG, "Mode: FAN_ONLY");
|
||||||
|
} else {
|
||||||
|
this->mode = climate::CLIMATE_MODE_COOL;
|
||||||
|
ESP_LOGI(TAG, "Mode: COOL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode fan speed from rc_code_1
|
||||||
|
uint16_t fan_code = (message1[2] << 8) | message1[3];
|
||||||
|
this->fan_mode = decode_ras_2819t_fan_mode(fan_code);
|
||||||
|
|
||||||
|
// Decode temperature
|
||||||
|
if (this->mode != climate::CLIMATE_MODE_OFF && this->mode != climate::CLIMATE_MODE_FAN_ONLY) {
|
||||||
|
this->target_temperature = decode_ras_2819t_temperature(temp_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->publish_state();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
ESP_LOGD(TAG, "Unknown single-packet RAS-2819T command: 0x%" PRIX64, toshiba_data.rc_code_1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||||
|
// Try modern ToshibaAcProtocol decoder first (handles RAS-2819T and potentially others)
|
||||||
|
remote_base::ToshibaAcProtocol toshiba_protocol;
|
||||||
|
auto decode_result = toshiba_protocol.decode(data);
|
||||||
|
|
||||||
|
if (decode_result.has_value()) {
|
||||||
|
auto toshiba_data = decode_result.value();
|
||||||
|
// Validate and process RAS-2819T commands
|
||||||
|
if (is_valid_ras_2819t_command(toshiba_data.rc_code_1, toshiba_data.rc_code_2)) {
|
||||||
|
return this->process_ras_2819t_command_(toshiba_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to generic processing for older protocols
|
||||||
uint8_t message[18] = {0};
|
uint8_t message[18] = {0};
|
||||||
uint8_t message_length = TOSHIBA_HEADER_LENGTH, temperature_code = 0;
|
uint8_t message_length = TOSHIBA_HEADER_LENGTH, temperature_code = 0;
|
||||||
|
|
||||||
@@ -499,11 +1098,11 @@ bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Read incoming bits into buffer
|
// Read incoming bits into buffer
|
||||||
if (!decode_(&data, message, message_length)) {
|
if (!this->decode_(&data, message, message_length)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Determine incoming message protocol version and/or length
|
// Determine incoming message protocol version and/or length
|
||||||
if (is_valid_rac_pt1411hwru_header_(message)) {
|
if (this->is_valid_rac_pt1411hwru_header_(message)) {
|
||||||
// We already received four bytes
|
// We already received four bytes
|
||||||
message_length = RAC_PT1411HWRU_MESSAGE_LENGTH - 4;
|
message_length = RAC_PT1411HWRU_MESSAGE_LENGTH - 4;
|
||||||
} else if ((message[0] ^ message[1] ^ message[2]) != message[3]) {
|
} else if ((message[0] ^ message[1] ^ message[2]) != message[3]) {
|
||||||
@@ -514,11 +1113,11 @@ bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
|||||||
message_length = message[2] + 2;
|
message_length = message[2] + 2;
|
||||||
}
|
}
|
||||||
// Decode the remaining bytes
|
// Decode the remaining bytes
|
||||||
if (!decode_(&data, &message[4], message_length)) {
|
if (!this->decode_(&data, &message[4], message_length)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If this is a RAC-PT1411HWRU message, we expect the first packet a second time and also possibly a third packet
|
// If this is a RAC-PT1411HWRU message, we expect the first packet a second time and also possibly a third packet
|
||||||
if (is_valid_rac_pt1411hwru_header_(message)) {
|
if (this->is_valid_rac_pt1411hwru_header_(message)) {
|
||||||
// There is always a space between packets
|
// There is always a space between packets
|
||||||
if (!data.expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
|
if (!data.expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -527,7 +1126,7 @@ bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
|||||||
if (!data.expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE)) {
|
if (!data.expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!decode_(&data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
|
if (!this->decode_(&data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If this is a RAC-PT1411HWRU message, there may also be a third packet.
|
// If this is a RAC-PT1411HWRU message, there may also be a third packet.
|
||||||
@@ -535,25 +1134,25 @@ bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
|||||||
if (data.expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
|
if (data.expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
|
||||||
// Validate header 3
|
// Validate header 3
|
||||||
data.expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE);
|
data.expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE);
|
||||||
if (decode_(&data, &message[12], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
|
if (this->decode_(&data, &message[12], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
|
||||||
if (!is_valid_rac_pt1411hwru_message_(&message[12])) {
|
if (!this->is_valid_rac_pt1411hwru_message_(&message[12])) {
|
||||||
// If a third packet was received but the checksum is not valid, fail
|
// If a third packet was received but the checksum is not valid, fail
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!compare_rac_pt1411hwru_packets_(&message[0], &message[6])) {
|
if (!this->compare_rac_pt1411hwru_packets_(&message[0], &message[6])) {
|
||||||
// If the first two packets don't match each other, fail
|
// If the first two packets don't match each other, fail
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!is_valid_rac_pt1411hwru_message_(&message[0])) {
|
if (!this->is_valid_rac_pt1411hwru_message_(&message[0])) {
|
||||||
// If the first packet isn't valid, fail
|
// If the first packet isn't valid, fail
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header has been verified, now determine protocol version and set the climate component properties
|
// Header has been verified, now determine protocol version and set the climate component properties
|
||||||
switch (is_valid_rac_pt1411hwru_header_(message)) {
|
switch (this->is_valid_rac_pt1411hwru_header_(message)) {
|
||||||
// Power, temperature, mode, fan speed
|
// Power, temperature, mode, fan speed
|
||||||
case RAC_PT1411HWRU_MESSAGE_HEADER0:
|
case RAC_PT1411HWRU_MESSAGE_HEADER0:
|
||||||
// Get the mode
|
// Get the mode
|
||||||
@@ -608,7 +1207,7 @@ bool ToshibaClimate::on_receive(remote_base::RemoteReceiveData data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Get the target temperature
|
// Get the target temperature
|
||||||
if (is_valid_rac_pt1411hwru_message_(&message[12])) {
|
if (this->is_valid_rac_pt1411hwru_message_(&message[12])) {
|
||||||
temperature_code =
|
temperature_code =
|
||||||
(message[4] >> 4) | (message[14] & RAC_PT1411HWRU_FLAG_FRAC) | (message[15] & RAC_PT1411HWRU_FLAG_NEG);
|
(message[4] >> 4) | (message[14] & RAC_PT1411HWRU_FLAG_FRAC) | (message[15] & RAC_PT1411HWRU_FLAG_NEG);
|
||||||
if (message[15] & RAC_PT1411HWRU_FLAG_FAH) {
|
if (message[15] & RAC_PT1411HWRU_FLAG_FAH) {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/components/climate_ir/climate_ir.h"
|
#include "esphome/components/climate_ir/climate_ir.h"
|
||||||
|
#include "esphome/components/remote_base/toshiba_ac_protocol.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace toshiba {
|
namespace toshiba {
|
||||||
@@ -10,6 +11,7 @@ enum Model {
|
|||||||
MODEL_GENERIC = 0, // Temperature range is from 17 to 30
|
MODEL_GENERIC = 0, // Temperature range is from 17 to 30
|
||||||
MODEL_RAC_PT1411HWRU_C = 1, // Temperature range is from 16 to 30
|
MODEL_RAC_PT1411HWRU_C = 1, // Temperature range is from 16 to 30
|
||||||
MODEL_RAC_PT1411HWRU_F = 2, // Temperature range is from 16 to 30
|
MODEL_RAC_PT1411HWRU_F = 2, // Temperature range is from 16 to 30
|
||||||
|
MODEL_RAS_2819T = 3, // RAS-2819T protocol variant, temperature range 18 to 30
|
||||||
};
|
};
|
||||||
|
|
||||||
// Supported temperature ranges
|
// Supported temperature ranges
|
||||||
@@ -19,6 +21,8 @@ const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MIN = 16.0;
|
|||||||
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX = 30.0;
|
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX = 30.0;
|
||||||
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MIN = 60.0;
|
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MIN = 60.0;
|
||||||
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MAX = 86.0;
|
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MAX = 86.0;
|
||||||
|
const float TOSHIBA_RAS_2819T_TEMP_C_MIN = 18.0;
|
||||||
|
const float TOSHIBA_RAS_2819T_TEMP_C_MAX = 30.0;
|
||||||
|
|
||||||
class ToshibaClimate : public climate_ir::ClimateIR {
|
class ToshibaClimate : public climate_ir::ClimateIR {
|
||||||
public:
|
public:
|
||||||
@@ -35,6 +39,9 @@ class ToshibaClimate : public climate_ir::ClimateIR {
|
|||||||
void transmit_generic_();
|
void transmit_generic_();
|
||||||
void transmit_rac_pt1411hwru_();
|
void transmit_rac_pt1411hwru_();
|
||||||
void transmit_rac_pt1411hwru_temp_(bool cs_state = true, bool cs_send_update = true);
|
void transmit_rac_pt1411hwru_temp_(bool cs_state = true, bool cs_send_update = true);
|
||||||
|
void transmit_ras_2819t_();
|
||||||
|
// Process RAS-2819T IR command data
|
||||||
|
bool process_ras_2819t_command_(const remote_base::ToshibaAcData &toshiba_data);
|
||||||
// Returns the header if valid, else returns zero
|
// Returns the header if valid, else returns zero
|
||||||
uint8_t is_valid_rac_pt1411hwru_header_(const uint8_t *message);
|
uint8_t is_valid_rac_pt1411hwru_header_(const uint8_t *message);
|
||||||
// Returns true if message is a valid RAC-PT1411HWRU IR message, regardless if first or second packet
|
// Returns true if message is a valid RAC-PT1411HWRU IR message, regardless if first or second packet
|
||||||
@@ -43,11 +50,26 @@ class ToshibaClimate : public climate_ir::ClimateIR {
|
|||||||
bool compare_rac_pt1411hwru_packets_(const uint8_t *message1, const uint8_t *message2);
|
bool compare_rac_pt1411hwru_packets_(const uint8_t *message1, const uint8_t *message2);
|
||||||
bool on_receive(remote_base::RemoteReceiveData data) override;
|
bool on_receive(remote_base::RemoteReceiveData data) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// RAS-2819T state tracking for swing mode optimization
|
||||||
|
climate::ClimateSwingMode last_swing_mode_{climate::CLIMATE_SWING_OFF};
|
||||||
|
climate::ClimateMode last_mode_{climate::CLIMATE_MODE_OFF};
|
||||||
|
optional<climate::ClimateFanMode> last_fan_mode_{};
|
||||||
|
float last_target_temperature_{24.0f};
|
||||||
|
|
||||||
float temperature_min_() {
|
float temperature_min_() {
|
||||||
return (this->model_ == MODEL_GENERIC) ? TOSHIBA_GENERIC_TEMP_C_MIN : TOSHIBA_RAC_PT1411HWRU_TEMP_C_MIN;
|
if (this->model_ == MODEL_RAC_PT1411HWRU_C || this->model_ == MODEL_RAC_PT1411HWRU_F)
|
||||||
|
return TOSHIBA_RAC_PT1411HWRU_TEMP_C_MIN;
|
||||||
|
if (this->model_ == MODEL_RAS_2819T)
|
||||||
|
return TOSHIBA_RAS_2819T_TEMP_C_MIN;
|
||||||
|
return TOSHIBA_GENERIC_TEMP_C_MIN; // Default to GENERIC for unknown models
|
||||||
}
|
}
|
||||||
float temperature_max_() {
|
float temperature_max_() {
|
||||||
return (this->model_ == MODEL_GENERIC) ? TOSHIBA_GENERIC_TEMP_C_MAX : TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX;
|
if (this->model_ == MODEL_RAC_PT1411HWRU_C || this->model_ == MODEL_RAC_PT1411HWRU_F)
|
||||||
|
return TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX;
|
||||||
|
if (this->model_ == MODEL_RAS_2819T)
|
||||||
|
return TOSHIBA_RAS_2819T_TEMP_C_MAX;
|
||||||
|
return TOSHIBA_GENERIC_TEMP_C_MAX; // Default to GENERIC for unknown models
|
||||||
}
|
}
|
||||||
std::set<climate::ClimateSwingMode> toshiba_swing_modes_() {
|
std::set<climate::ClimateSwingMode> toshiba_swing_modes_() {
|
||||||
return (this->model_ == MODEL_GENERIC)
|
return (this->model_ == MODEL_GENERIC)
|
||||||
|
@@ -3,6 +3,7 @@ from esphome.components import i2c, sensor
|
|||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
|
CONF_OVERSAMPLING,
|
||||||
CONF_PRESSURE,
|
CONF_PRESSURE,
|
||||||
CONF_TEMPERATURE,
|
CONF_TEMPERATURE,
|
||||||
DEVICE_CLASS_PRESSURE,
|
DEVICE_CLASS_PRESSURE,
|
||||||
@@ -18,6 +19,17 @@ CODEOWNERS = ["@gcormier"]
|
|||||||
CONF_K_VALUE = "k_value"
|
CONF_K_VALUE = "k_value"
|
||||||
|
|
||||||
xgzp68xx_ns = cg.esphome_ns.namespace("xgzp68xx")
|
xgzp68xx_ns = cg.esphome_ns.namespace("xgzp68xx")
|
||||||
|
XGZP68XXOversampling = xgzp68xx_ns.enum("XGZP68XXOversampling")
|
||||||
|
OVERSAMPLING_OPTIONS = {
|
||||||
|
"256X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_256X,
|
||||||
|
"512X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_512X,
|
||||||
|
"1024X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_1024X,
|
||||||
|
"2048X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_2048X,
|
||||||
|
"4096X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_4096X,
|
||||||
|
"8192X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_8192X,
|
||||||
|
"16384X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_16384X,
|
||||||
|
"32768X": XGZP68XXOversampling.XGZP68XX_OVERSAMPLING_32768X,
|
||||||
|
}
|
||||||
XGZP68XXComponent = xgzp68xx_ns.class_(
|
XGZP68XXComponent = xgzp68xx_ns.class_(
|
||||||
"XGZP68XXComponent", cg.PollingComponent, i2c.I2CDevice
|
"XGZP68XXComponent", cg.PollingComponent, i2c.I2CDevice
|
||||||
)
|
)
|
||||||
@@ -31,6 +43,12 @@ CONFIG_SCHEMA = (
|
|||||||
accuracy_decimals=1,
|
accuracy_decimals=1,
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=DEVICE_CLASS_PRESSURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
).extend(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_OVERSAMPLING, default="4096X"): cv.enum(
|
||||||
|
OVERSAMPLING_OPTIONS, upper=True
|
||||||
|
),
|
||||||
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||||
unit_of_measurement=UNIT_CELSIUS,
|
unit_of_measurement=UNIT_CELSIUS,
|
||||||
@@ -58,5 +76,6 @@ async def to_code(config):
|
|||||||
if pressure_config := config.get(CONF_PRESSURE):
|
if pressure_config := config.get(CONF_PRESSURE):
|
||||||
sens = await sensor.new_sensor(pressure_config)
|
sens = await sensor.new_sensor(pressure_config)
|
||||||
cg.add(var.set_pressure_sensor(sens))
|
cg.add(var.set_pressure_sensor(sens))
|
||||||
|
cg.add(var.set_pressure_oversampling(pressure_config[CONF_OVERSAMPLING]))
|
||||||
|
|
||||||
cg.add(var.set_k_value(config[CONF_K_VALUE]))
|
cg.add(var.set_k_value(config[CONF_K_VALUE]))
|
||||||
|
@@ -16,16 +16,49 @@ static const uint8_t SYSCONFIG_ADDRESS = 0xA5;
|
|||||||
static const uint8_t PCONFIG_ADDRESS = 0xA6;
|
static const uint8_t PCONFIG_ADDRESS = 0xA6;
|
||||||
static const uint8_t READ_COMMAND = 0x0A;
|
static const uint8_t READ_COMMAND = 0x0A;
|
||||||
|
|
||||||
|
[[maybe_unused]] static const char *oversampling_to_str(XGZP68XXOversampling oversampling) {
|
||||||
|
switch (oversampling) {
|
||||||
|
case XGZP68XX_OVERSAMPLING_256X:
|
||||||
|
return "256x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_512X:
|
||||||
|
return "512x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_1024X:
|
||||||
|
return "1024x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_2048X:
|
||||||
|
return "2048x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_4096X:
|
||||||
|
return "4096x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_8192X:
|
||||||
|
return "8192x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_16384X:
|
||||||
|
return "16384x";
|
||||||
|
case XGZP68XX_OVERSAMPLING_32768X:
|
||||||
|
return "32768x";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void XGZP68XXComponent::update() {
|
void XGZP68XXComponent::update() {
|
||||||
|
// Do we need to change oversampling?
|
||||||
|
if (this->last_pressure_oversampling_ != this->pressure_oversampling_) {
|
||||||
|
uint8_t oldconfig = 0;
|
||||||
|
this->read_register(PCONFIG_ADDRESS, &oldconfig, 1);
|
||||||
|
uint8_t newconfig = (oldconfig & 0xf8) | (this->pressure_oversampling_ & 0x7);
|
||||||
|
this->write_register(PCONFIG_ADDRESS, &newconfig, 1);
|
||||||
|
ESP_LOGD(TAG, "oversampling to %s: oldconfig = 0x%x newconfig = 0x%x",
|
||||||
|
oversampling_to_str(this->pressure_oversampling_), oldconfig, newconfig);
|
||||||
|
this->last_pressure_oversampling_ = this->pressure_oversampling_;
|
||||||
|
}
|
||||||
|
|
||||||
// Request temp + pressure acquisition
|
// Request temp + pressure acquisition
|
||||||
this->write_register(0x30, &READ_COMMAND, 1);
|
this->write_register(0x30, &READ_COMMAND, 1);
|
||||||
|
|
||||||
// Wait 20mS per datasheet
|
// Wait 20mS per datasheet
|
||||||
this->set_timeout("measurement", 20, [this]() {
|
this->set_timeout("measurement", 20, [this]() {
|
||||||
uint8_t data[5];
|
uint8_t data[5] = {};
|
||||||
uint32_t pressure_raw;
|
uint32_t pressure_raw = 0;
|
||||||
uint16_t temperature_raw;
|
uint16_t temperature_raw = 0;
|
||||||
float pressure_in_pa, temperature;
|
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
// Read the sensor data
|
// Read the sensor data
|
||||||
@@ -42,23 +75,11 @@ void XGZP68XXComponent::update() {
|
|||||||
ESP_LOGV(TAG, "Got raw pressure=%" PRIu32 ", raw temperature=%u", pressure_raw, temperature_raw);
|
ESP_LOGV(TAG, "Got raw pressure=%" PRIu32 ", raw temperature=%u", pressure_raw, temperature_raw);
|
||||||
ESP_LOGV(TAG, "K value is %u", this->k_value_);
|
ESP_LOGV(TAG, "K value is %u", this->k_value_);
|
||||||
|
|
||||||
// The most significant bit of both pressure and temperature will be 1 to indicate a negative value.
|
// Sign extend the pressure
|
||||||
// This is directly from the datasheet, and the calculations below will handle this.
|
float pressure_in_pa = (float) (((int32_t) pressure_raw << 8) >> 8);
|
||||||
if (pressure_raw > pow(2, 23)) {
|
pressure_in_pa /= (float) (this->k_value_);
|
||||||
// Negative pressure
|
|
||||||
pressure_in_pa = (pressure_raw - pow(2, 24)) / (float) (this->k_value_);
|
|
||||||
} else {
|
|
||||||
// Positive pressure
|
|
||||||
pressure_in_pa = pressure_raw / (float) (this->k_value_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (temperature_raw > pow(2, 15)) {
|
float temperature = ((float) (int16_t) temperature_raw) / 256.0f;
|
||||||
// Negative temperature
|
|
||||||
temperature = (float) (temperature_raw - pow(2, 16)) / 256.0f;
|
|
||||||
} else {
|
|
||||||
// Positive temperature
|
|
||||||
temperature = (float) temperature_raw / 256.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->pressure_sensor_ != nullptr)
|
if (this->pressure_sensor_ != nullptr)
|
||||||
this->pressure_sensor_->publish_state(pressure_in_pa);
|
this->pressure_sensor_->publish_state(pressure_in_pa);
|
||||||
@@ -69,20 +90,27 @@ void XGZP68XXComponent::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XGZP68XXComponent::setup() {
|
void XGZP68XXComponent::setup() {
|
||||||
uint8_t config;
|
uint8_t config1 = 0, config2 = 0;
|
||||||
|
|
||||||
// Display some sample bits to confirm we are talking to the sensor
|
// Display some sample bits to confirm we are talking to the sensor
|
||||||
this->read_register(SYSCONFIG_ADDRESS, &config, 1);
|
if (i2c::ErrorCode::ERROR_OK != this->read_register(SYSCONFIG_ADDRESS, &config1, 1)) {
|
||||||
ESP_LOGCONFIG(TAG,
|
this->mark_failed();
|
||||||
"Gain value is %d\n"
|
return;
|
||||||
"XGZP68xx started!",
|
}
|
||||||
(config >> 3) & 0b111);
|
if (i2c::ErrorCode::ERROR_OK != this->read_register(PCONFIG_ADDRESS, &config2, 1)) {
|
||||||
|
this->mark_failed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ESP_LOGD(TAG, "sys_config 0x%x, p_config 0x%x", config1, config2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGZP68XXComponent::dump_config() {
|
void XGZP68XXComponent::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "XGZP68xx:");
|
ESP_LOGCONFIG(TAG, "XGZP68xx:");
|
||||||
LOG_SENSOR(" ", "Temperature: ", this->temperature_sensor_);
|
LOG_SENSOR(" ", "Temperature: ", this->temperature_sensor_);
|
||||||
LOG_SENSOR(" ", "Pressure: ", this->pressure_sensor_);
|
LOG_SENSOR(" ", "Pressure: ", this->pressure_sensor_);
|
||||||
|
if (this->pressure_sensor_ != nullptr) {
|
||||||
|
ESP_LOGCONFIG(TAG, " Oversampling: %s", oversampling_to_str(this->pressure_oversampling_));
|
||||||
|
}
|
||||||
LOG_I2C_DEVICE(this);
|
LOG_I2C_DEVICE(this);
|
||||||
if (this->is_failed()) {
|
if (this->is_failed()) {
|
||||||
ESP_LOGE(TAG, " Connection failed");
|
ESP_LOGE(TAG, " Connection failed");
|
||||||
|
@@ -7,11 +7,29 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace xgzp68xx {
|
namespace xgzp68xx {
|
||||||
|
|
||||||
|
/// Enum listing all oversampling options for the XGZP68XX.
|
||||||
|
enum XGZP68XXOversampling : uint8_t {
|
||||||
|
XGZP68XX_OVERSAMPLING_256X = 0b100,
|
||||||
|
XGZP68XX_OVERSAMPLING_512X = 0b101,
|
||||||
|
XGZP68XX_OVERSAMPLING_1024X = 0b000,
|
||||||
|
XGZP68XX_OVERSAMPLING_2048X = 0b001,
|
||||||
|
XGZP68XX_OVERSAMPLING_4096X = 0b010,
|
||||||
|
XGZP68XX_OVERSAMPLING_8192X = 0b011,
|
||||||
|
XGZP68XX_OVERSAMPLING_16384X = 0b110,
|
||||||
|
XGZP68XX_OVERSAMPLING_32768X = 0b111,
|
||||||
|
|
||||||
|
XGZP68XX_OVERSAMPLING_UNKNOWN = (uint8_t) -1,
|
||||||
|
};
|
||||||
|
|
||||||
class XGZP68XXComponent : public PollingComponent, public sensor::Sensor, public i2c::I2CDevice {
|
class XGZP68XXComponent : public PollingComponent, public sensor::Sensor, public i2c::I2CDevice {
|
||||||
public:
|
public:
|
||||||
SUB_SENSOR(temperature)
|
SUB_SENSOR(temperature)
|
||||||
SUB_SENSOR(pressure)
|
SUB_SENSOR(pressure)
|
||||||
void set_k_value(uint16_t k_value) { this->k_value_ = k_value; }
|
void set_k_value(uint16_t k_value) { this->k_value_ = k_value; }
|
||||||
|
/// Set the pressure oversampling value. Defaults to 4096X.
|
||||||
|
void set_pressure_oversampling(XGZP68XXOversampling pressure_oversampling) {
|
||||||
|
this->pressure_oversampling_ = pressure_oversampling;
|
||||||
|
}
|
||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
void setup() override;
|
void setup() override;
|
||||||
@@ -21,6 +39,8 @@ class XGZP68XXComponent : public PollingComponent, public sensor::Sensor, public
|
|||||||
/// Internal method to read the pressure from the component after it has been scheduled.
|
/// Internal method to read the pressure from the component after it has been scheduled.
|
||||||
void read_pressure_();
|
void read_pressure_();
|
||||||
uint16_t k_value_;
|
uint16_t k_value_;
|
||||||
|
XGZP68XXOversampling pressure_oversampling_{XGZP68XX_OVERSAMPLING_4096X};
|
||||||
|
XGZP68XXOversampling last_pressure_oversampling_{XGZP68XX_OVERSAMPLING_UNKNOWN};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xgzp68xx
|
} // namespace xgzp68xx
|
||||||
|
@@ -228,12 +228,19 @@ def copy_files():
|
|||||||
"name": "esphome nrf52",
|
"name": "esphome nrf52",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 248832,
|
"maximum_ram_size": 248832,
|
||||||
"maximum_size": 815104
|
"maximum_size": 815104,
|
||||||
|
"speed": 115200
|
||||||
},
|
},
|
||||||
"url": "https://esphome.io/",
|
"url": "https://esphome.io/",
|
||||||
"vendor": "esphome"
|
"vendor": "esphome",
|
||||||
|
"build": {
|
||||||
|
"softdevice": {
|
||||||
|
"sd_fwid": "0x00B6"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
write_file_if_changed(
|
write_file_if_changed(
|
||||||
CORE.relative_build_path(f"boards/{zephyr_data()[KEY_BOARD]}.json"),
|
CORE.relative_build_path(f"boards/{zephyr_data()[KEY_BOARD]}.json"),
|
||||||
fake_board_manifest,
|
fake_board_manifest,
|
||||||
|
@@ -696,6 +696,7 @@ CONF_OPEN_DRAIN = "open_drain"
|
|||||||
CONF_OPEN_DRAIN_INTERRUPT = "open_drain_interrupt"
|
CONF_OPEN_DRAIN_INTERRUPT = "open_drain_interrupt"
|
||||||
CONF_OPEN_DURATION = "open_duration"
|
CONF_OPEN_DURATION = "open_duration"
|
||||||
CONF_OPEN_ENDSTOP = "open_endstop"
|
CONF_OPEN_ENDSTOP = "open_endstop"
|
||||||
|
CONF_OPENTHREAD = "openthread"
|
||||||
CONF_OPERATION = "operation"
|
CONF_OPERATION = "operation"
|
||||||
CONF_OPTIMISTIC = "optimistic"
|
CONF_OPTIMISTIC = "optimistic"
|
||||||
CONF_OPTION = "option"
|
CONF_OPTION = "option"
|
||||||
@@ -1299,6 +1300,7 @@ DEVICE_CLASS_SULPHUR_DIOXIDE = "sulphur_dioxide"
|
|||||||
DEVICE_CLASS_SWITCH = "switch"
|
DEVICE_CLASS_SWITCH = "switch"
|
||||||
DEVICE_CLASS_TAMPER = "tamper"
|
DEVICE_CLASS_TAMPER = "tamper"
|
||||||
DEVICE_CLASS_TEMPERATURE = "temperature"
|
DEVICE_CLASS_TEMPERATURE = "temperature"
|
||||||
|
DEVICE_CLASS_TEMPERATURE_DELTA = "temperature_delta"
|
||||||
DEVICE_CLASS_TIMESTAMP = "timestamp"
|
DEVICE_CLASS_TIMESTAMP = "timestamp"
|
||||||
DEVICE_CLASS_UPDATE = "update"
|
DEVICE_CLASS_UPDATE = "update"
|
||||||
DEVICE_CLASS_VIBRATION = "vibration"
|
DEVICE_CLASS_VIBRATION = "vibration"
|
||||||
|
@@ -10,6 +10,10 @@ from esphome.helpers import get_bool_env
|
|||||||
|
|
||||||
from .util.password import password_hash
|
from .util.password import password_hash
|
||||||
|
|
||||||
|
# Sentinel file name used for CORE.config_path when dashboard initializes.
|
||||||
|
# This ensures .parent returns the config directory instead of root.
|
||||||
|
_DASHBOARD_SENTINEL_FILE = "___DASHBOARD_SENTINEL___.yaml"
|
||||||
|
|
||||||
|
|
||||||
class DashboardSettings:
|
class DashboardSettings:
|
||||||
"""Settings for the dashboard."""
|
"""Settings for the dashboard."""
|
||||||
@@ -48,7 +52,12 @@ class DashboardSettings:
|
|||||||
self.config_dir = Path(args.configuration)
|
self.config_dir = Path(args.configuration)
|
||||||
self.absolute_config_dir = self.config_dir.resolve()
|
self.absolute_config_dir = self.config_dir.resolve()
|
||||||
self.verbose = args.verbose
|
self.verbose = args.verbose
|
||||||
CORE.config_path = self.config_dir / "."
|
# Set to a sentinel file so .parent gives us the config directory.
|
||||||
|
# Previously this was `os.path.join(self.config_dir, ".")` which worked because
|
||||||
|
# os.path.dirname("/config/.") returns "/config", but Path("/config/.").parent
|
||||||
|
# normalizes to Path("/config") first, then .parent returns Path("/"), breaking
|
||||||
|
# secret resolution. Using a sentinel file ensures .parent gives the correct directory.
|
||||||
|
CORE.config_path = self.config_dir / _DASHBOARD_SENTINEL_FILE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def relative_url(self) -> str:
|
def relative_url(self) -> str:
|
||||||
|
@@ -1058,7 +1058,8 @@ class DownloadBinaryRequestHandler(BaseHandler):
|
|||||||
"download",
|
"download",
|
||||||
f"{storage_json.name}-{file_name}",
|
f"{storage_json.name}-{file_name}",
|
||||||
)
|
)
|
||||||
path = storage_json.firmware_bin_path.with_name(file_name)
|
|
||||||
|
path = storage_json.firmware_bin_path.parent.joinpath(file_name)
|
||||||
|
|
||||||
if not path.is_file():
|
if not path.is_file():
|
||||||
args = ["esphome", "idedata", settings.rel_path(configuration)]
|
args = ["esphome", "idedata", settings.rel_path(configuration)]
|
||||||
|
@@ -12,7 +12,7 @@ platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile
|
|||||||
esptool==5.1.0
|
esptool==5.1.0
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
esphome-dashboard==20251013.0
|
esphome-dashboard==20251013.0
|
||||||
aioesphomeapi==42.0.0
|
aioesphomeapi==42.2.0
|
||||||
zeroconf==0.148.0
|
zeroconf==0.148.0
|
||||||
puremagic==1.30
|
puremagic==1.30
|
||||||
ruamel.yaml==0.18.15 # dashboard_import
|
ruamel.yaml==0.18.15 # dashboard_import
|
||||||
|
@@ -50,7 +50,14 @@ PACKAGE_DEPENDENCIES = {
|
|||||||
|
|
||||||
# Bus types that can be defined directly in config files
|
# Bus types that can be defined directly in config files
|
||||||
# Components defining these directly cannot be grouped (they create unique bus IDs)
|
# Components defining these directly cannot be grouped (they create unique bus IDs)
|
||||||
DIRECT_BUS_TYPES = ("i2c", "spi", "uart", "modbus")
|
DIRECT_BUS_TYPES = (
|
||||||
|
"i2c",
|
||||||
|
"spi",
|
||||||
|
"uart",
|
||||||
|
"modbus",
|
||||||
|
"remote_transmitter",
|
||||||
|
"remote_receiver",
|
||||||
|
)
|
||||||
|
|
||||||
# Signature for components with no bus requirements
|
# Signature for components with no bus requirements
|
||||||
# These components can be merged with any other group
|
# These components can be merged with any other group
|
||||||
@@ -68,6 +75,8 @@ BASE_BUS_COMPONENTS = {
|
|||||||
"uart",
|
"uart",
|
||||||
"modbus",
|
"modbus",
|
||||||
"canbus",
|
"canbus",
|
||||||
|
"remote_transmitter",
|
||||||
|
"remote_receiver",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Components that must be tested in isolation (not grouped or batched with others)
|
# Components that must be tested in isolation (not grouped or batched with others)
|
||||||
@@ -83,8 +92,6 @@ ISOLATED_COMPONENTS = {
|
|||||||
"openthread": "Conflicts with wifi: used by most components",
|
"openthread": "Conflicts with wifi: used by most components",
|
||||||
"openthread_info": "Conflicts with wifi: used by most components",
|
"openthread_info": "Conflicts with wifi: used by most components",
|
||||||
"matrix_keypad": "Needs isolation due to keypad",
|
"matrix_keypad": "Needs isolation due to keypad",
|
||||||
"mcp4725": "no YAML config to specify i2c bus id",
|
|
||||||
"mcp47a1": "no YAML config to specify i2c bus id",
|
|
||||||
"modbus_controller": "Defines multiple modbus buses for testing client/server functionality - conflicts with package modbus bus",
|
"modbus_controller": "Defines multiple modbus buses for testing client/server functionality - conflicts with package modbus bus",
|
||||||
"neopixelbus": "RMT type conflict with ESP32 Arduino/ESP-IDF headers (enum vs struct rmt_channel_t)",
|
"neopixelbus": "RMT type conflict with ESP32 Arduino/ESP-IDF headers (enum vs struct rmt_channel_t)",
|
||||||
"packages": "cannot merge packages",
|
"packages": "cannot merge packages",
|
||||||
|
@@ -99,7 +99,8 @@ def find_component_tests(
|
|||||||
if not comp_dir.is_dir():
|
if not comp_dir.is_dir():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for test_file in comp_dir.glob("test.*.yaml"):
|
# Find test files matching test.*.yaml or test-*.yaml patterns
|
||||||
|
for test_file in comp_dir.glob("test[.-]*.yaml"):
|
||||||
component_tests[comp_dir.name].append(test_file)
|
component_tests[comp_dir.name].append(test_file)
|
||||||
|
|
||||||
return dict(component_tests)
|
return dict(component_tests)
|
||||||
|
@@ -8,14 +8,12 @@ sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return 0.6;
|
return 0.6;
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
return 0.0;
|
||||||
- platform: template
|
- platform: template
|
||||||
id: template_temperature
|
id: template_temperature
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return 42.0;
|
return 42.0;
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
return 0.0;
|
||||||
|
@@ -5,9 +5,8 @@ sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return 42.0;
|
return 42.0;
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
return 0.0;
|
||||||
update_interval: 15s
|
update_interval: 15s
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: heatpumpir
|
- platform: heatpumpir
|
||||||
protocol: ballu
|
protocol: ballu
|
||||||
@@ -10,3 +6,4 @@ climate:
|
|||||||
name: HeatpumpIR Climate
|
name: HeatpumpIR Climate
|
||||||
min_temperature: 18
|
min_temperature: 18
|
||||||
max_temperature: 30
|
max_temperature: 30
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
6
tests/components/bh1900nux/common.yaml
Normal file
6
tests/components/bh1900nux/common.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
sensor:
|
||||||
|
- platform: bh1900nux
|
||||||
|
i2c_id: i2c_bus
|
||||||
|
name: Temperature Living Room
|
||||||
|
address: 0x48
|
||||||
|
update_interval: 30s
|
4
tests/components/bh1900nux/test.esp32-c3-idf.yaml
Normal file
4
tests/components/bh1900nux/test.esp32-c3-idf.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
i2c: !include ../../test_build_components/common/i2c/esp32-c3-idf.yaml
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
4
tests/components/bh1900nux/test.esp32-idf.yaml
Normal file
4
tests/components/bh1900nux/test.esp32-idf.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
i2c: !include ../../test_build_components/common/i2c/esp32-idf.yaml
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
4
tests/components/bh1900nux/test.esp8266-ard.yaml
Normal file
4
tests/components/bh1900nux/test.esp8266-ard.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
i2c: !include ../../test_build_components/common/i2c/esp8266-ard.yaml
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
4
tests/components/bh1900nux/test.rp2040-ard.yaml
Normal file
4
tests/components/bh1900nux/test.rp2040-ard.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
i2c: !include ../../test_build_components/common/i2c/rp2040-ard.yaml
|
||||||
|
|
||||||
|
<<: !include common.yaml
|
@@ -23,9 +23,8 @@ binary_sensor:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
if (id(some_binary_sensor).state) {
|
if (id(some_binary_sensor).state) {
|
||||||
return x;
|
return x;
|
||||||
} else {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
return {};
|
||||||
- settle: 100ms
|
- settle: 100ms
|
||||||
- timeout: 10s
|
- timeout: 10s
|
||||||
|
|
||||||
|
@@ -4,25 +4,22 @@ binary_sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
- platform: template
|
- platform: template
|
||||||
id: bin2
|
id: bin2
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 20000) {
|
if (millis() > 20000) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
- platform: template
|
- platform: template
|
||||||
id: bin3
|
id: bin3
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 30000) {
|
if (millis() > 30000) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: binary_sensor_map
|
- platform: binary_sensor_map
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: climate_ir_lg
|
- platform: climate_ir_lg
|
||||||
name: LG Climate
|
name: LG Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -4,17 +4,15 @@ sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return 0.6;
|
return 0.6;
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
return 0.0;
|
||||||
- platform: template
|
- platform: template
|
||||||
id: template_temperature2
|
id: template_temperature2
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 20000) {
|
if (millis() > 20000) {
|
||||||
return 0.8;
|
return 0.8;
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
return 0.0;
|
||||||
- platform: combination
|
- platform: combination
|
||||||
type: kalman
|
type: kalman
|
||||||
name: Kalman-filtered temperature
|
name: Kalman-filtered temperature
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: coolix
|
- platform: coolix
|
||||||
name: Coolix Climate
|
name: Coolix Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: heatpumpir
|
- platform: heatpumpir
|
||||||
protocol: daikin
|
protocol: daikin
|
||||||
@@ -10,3 +6,4 @@ climate:
|
|||||||
name: HeatpumpIR Climate
|
name: HeatpumpIR Climate
|
||||||
min_temperature: 18
|
min_temperature: 18
|
||||||
max_temperature: 30
|
max_temperature: 30
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,18 +1,3 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${tx_pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
id: tsvr
|
|
||||||
|
|
||||||
remote_receiver:
|
|
||||||
id: rcvr
|
|
||||||
pin:
|
|
||||||
number: ${rx_pin}
|
|
||||||
inverted: true
|
|
||||||
mode:
|
|
||||||
input: true
|
|
||||||
pullup: true
|
|
||||||
tolerance: 40%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: daikin_arc
|
- platform: daikin_arc
|
||||||
name: Daikin AC
|
name: Daikin AC
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
substitutions:
|
packages:
|
||||||
tx_pin: GPIO0
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
rx_pin: GPIO2
|
remote_receiver: !include ../../test_build_components/common/remote_receiver/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: daikin_brc
|
- platform: daikin_brc
|
||||||
name: Daikin_brc Climate
|
name: Daikin_brc Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: delonghi
|
- platform: delonghi
|
||||||
name: Delonghi Climate
|
name: Delonghi Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -4,9 +4,8 @@ binary_sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: duty_time
|
- platform: duty_time
|
||||||
|
@@ -1,14 +1,5 @@
|
|||||||
remote_transmitter:
|
|
||||||
id: tx
|
|
||||||
pin: ${remote_transmitter_pin}
|
|
||||||
carrier_duty_percent: 100%
|
|
||||||
|
|
||||||
remote_receiver:
|
|
||||||
id: rcvr
|
|
||||||
pin: ${remote_receiver_pin}
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: emmeti
|
- platform: emmeti
|
||||||
name: Emmeti
|
name: Emmeti
|
||||||
receiver_id: rcvr
|
receiver_id: rcvr
|
||||||
transmitter_id: tx
|
transmitter_id: xmitr
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
substitutions:
|
packages:
|
||||||
remote_transmitter_pin: GPIO33
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
remote_receiver_pin: GPIO32
|
remote_receiver: !include ../../test_build_components/common/remote_receiver/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
substitutions:
|
packages:
|
||||||
remote_transmitter_pin: GPIO0
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
remote_receiver_pin: GPIO2
|
remote_receiver: !include ../../test_build_components/common/remote_receiver/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -4,9 +4,8 @@ binary_sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (millis() > 10000) {
|
if (millis() > 10000) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: fujitsu_general
|
- platform: fujitsu_general
|
||||||
name: Fujitsu General Climate
|
name: Fujitsu General Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: gree
|
- platform: gree
|
||||||
name: GREE
|
name: GREE
|
||||||
model: generic
|
model: generic
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: heatpumpir
|
- platform: heatpumpir
|
||||||
protocol: mitsubishi_heavy_zm
|
protocol: mitsubishi_heavy_zm
|
||||||
@@ -10,6 +6,7 @@ climate:
|
|||||||
name: HeatpumpIR Climate Mitsubishi
|
name: HeatpumpIR Climate Mitsubishi
|
||||||
min_temperature: 18
|
min_temperature: 18
|
||||||
max_temperature: 30
|
max_temperature: 30
|
||||||
|
transmitter_id: xmitr
|
||||||
- platform: heatpumpir
|
- platform: heatpumpir
|
||||||
protocol: daikin
|
protocol: daikin
|
||||||
horizontal_default: mleft
|
horizontal_default: mleft
|
||||||
@@ -17,6 +14,7 @@ climate:
|
|||||||
name: HeatpumpIR Climate Daikin
|
name: HeatpumpIR Climate Daikin
|
||||||
min_temperature: 18
|
min_temperature: 18
|
||||||
max_temperature: 30
|
max_temperature: 30
|
||||||
|
transmitter_id: xmitr
|
||||||
- platform: heatpumpir
|
- platform: heatpumpir
|
||||||
protocol: panasonic_altdke
|
protocol: panasonic_altdke
|
||||||
horizontal_default: mright
|
horizontal_default: mright
|
||||||
@@ -24,3 +22,4 @@ climate:
|
|||||||
name: HeatpumpIR Climate Panasonic
|
name: HeatpumpIR Climate Panasonic
|
||||||
min_temperature: 18
|
min_temperature: 18
|
||||||
max_temperature: 30
|
max_temperature: 30
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO6
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/bk72xx-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: hitachi_ac344
|
- platform: hitachi_ac344
|
||||||
name: Hitachi Climate
|
name: Hitachi Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO6
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/bk72xx-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
remote_transmitter:
|
|
||||||
pin: ${pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
climate:
|
climate:
|
||||||
- platform: hitachi_ac424
|
- platform: hitachi_ac424
|
||||||
name: Hitachi Climate
|
name: Hitachi Climate
|
||||||
|
transmitter_id: xmitr
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO6
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/bk72xx-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-c3-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO2
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
substitutions:
|
packages:
|
||||||
pin: GPIO5
|
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||||
|
|
||||||
<<: !include common.yaml
|
<<: !include common.yaml
|
||||||
|
@@ -7,6 +7,7 @@ sensor:
|
|||||||
max_current: 40 A
|
max_current: 40 A
|
||||||
adc_range: 1
|
adc_range: 1
|
||||||
temperature_coefficient: 50
|
temperature_coefficient: 50
|
||||||
|
reset_on_boot: true
|
||||||
shunt_voltage:
|
shunt_voltage:
|
||||||
id: ina2xx_i2c_shunt_voltage
|
id: ina2xx_i2c_shunt_voltage
|
||||||
name: "INA2xx Shunt Voltage"
|
name: "INA2xx Shunt Voltage"
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user