1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-15 07:10:33 +01:00

Merge remote-tracking branch 'origin/dev' into nrf52

This commit is contained in:
Tomasz Duda 2024-07-06 18:08:06 +02:00
commit 383f99cbde
121 changed files with 924 additions and 11628 deletions

View File

@ -1,7 +1,9 @@
{
"name": "ESPHome Dev",
"image": "ghcr.io/esphome/esphome-lint:dev",
"postCreateCommand": ["script/devcontainer-post-create"],
"postCreateCommand": [
"script/devcontainer-post-create"
],
"containerEnv": {
"DEVCONTAINER": "1",
"PIP_BREAK_SYSTEM_PACKAGES": "1",
@ -27,6 +29,9 @@
"extensions": [
// python
"ms-python.python",
"ms-python.pylint",
"ms-python.flake8",
"ms-python.black-formatter",
"visualstudioexptteam.vscodeintellicode",
// yaml
"redhat.vscode-yaml",
@ -38,9 +43,21 @@
"settings": {
"python.languageServer": "Pylance",
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"pylint.args": [
"--rcfile=${workspaceFolder}/pyproject.toml"
],
"flake8.args": [
"--config=${workspaceFolder}/.flake8"
],
"black-formatter.args": [
"--config",
"${workspaceFolder}/pyproject.toml"
],
"[python]": {
// VS will say "Value is not accepted" before building the devcontainer, but the warning
// should go away after build is completed.
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,

View File

@ -46,7 +46,7 @@ runs:
- name: Build and push to ghcr by digest
id: build-ghcr
uses: docker/build-push-action@v6.1.0
uses: docker/build-push-action@v6.3.0
with:
context: .
file: ./docker/Dockerfile
@ -69,7 +69,7 @@ runs:
- name: Build and push to dockerhub by digest
id: build-dockerhub
uses: docker/build-push-action@v6.1.0
uses: docker/build-push-action@v6.3.0
with:
context: .
file: ./docker/Dockerfile

View File

@ -46,9 +46,9 @@ jobs:
with:
python-version: "3.9"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
uses: docker/setup-buildx-action@v3.4.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
uses: docker/setup-qemu-action@v3.1.0
- name: Set TAG
run: |

View File

@ -248,72 +248,6 @@ jobs:
run: script/ci-suggest-changes
if: always()
compile-tests-list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4.1.7
- name: Find all YAML test files
id: set-matrix
run: echo "matrix=$(ls tests/test*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
validate-tests:
name: Validate YAML test ${{ matrix.file }}
runs-on: ubuntu-latest
needs:
- common
- compile-tests-list
strategy:
fail-fast: false
matrix:
file: ${{ fromJson(needs.compile-tests-list.outputs.matrix) }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4.1.7
- name: Restore Python
uses: ./.github/actions/restore-python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Run esphome config ${{ matrix.file }}
run: |
. venv/bin/activate
esphome config ${{ matrix.file }}
compile-tests:
name: Run YAML test ${{ matrix.file }}
runs-on: ubuntu-latest
needs:
- common
- black
- ci-custom
- clang-format
- flake8
- pylint
- pytest
- pyupgrade
- compile-tests-list
- validate-tests
strategy:
fail-fast: false
max-parallel: 2
matrix:
file: ${{ fromJson(needs.compile-tests-list.outputs.matrix) }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4.1.7
- name: Restore Python
uses: ./.github/actions/restore-python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Run esphome compile ${{ matrix.file }}
run: |
. venv/bin/activate
esphome compile ${{ matrix.file }}
clang-tidy:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
@ -550,7 +484,6 @@ jobs:
- pylint
- pytest
- pyupgrade
- compile-tests
- clang-tidy
- list-components
- test-build-components

View File

@ -90,10 +90,10 @@ jobs:
python-version: "3.9"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
uses: docker/setup-buildx-action@v3.4.0
- name: Set up QEMU
if: matrix.platform != 'linux/amd64'
uses: docker/setup-qemu-action@v3.0.0
uses: docker/setup-qemu-action@v3.1.0
- name: Log in to docker hub
uses: docker/login-action@v3.2.0
@ -141,7 +141,7 @@ jobs:
echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT
- name: Upload digests
uses: actions/upload-artifact@v4.3.3
uses: actions/upload-artifact@v4.3.4
with:
name: digests-${{ steps.sanitize.outputs.name }}
path: /tmp/digests
@ -177,14 +177,14 @@ jobs:
- uses: actions/checkout@v4.1.7
- name: Download digests
uses: actions/download-artifact@v4.1.7
uses: actions/download-artifact@v4.1.8
with:
pattern: digests-*
path: /tmp/digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
uses: docker/setup-buildx-action@v3.4.0
- name: Log in to docker hub
if: matrix.registry == 'dockerhub'

View File

@ -34,28 +34,32 @@ RUN \
python3-wheel=0.38.4-2 \
iputils-ping=3:20221126-1 \
git=1:2.39.2-1.1 \
curl=7.88.1-10+deb12u5 \
curl=7.88.1-10+deb12u6 \
openssh-client=1:9.2p1-2+deb12u2 \
python3-cffi=1.15.1-5 \
libcairo2=1.16.0-7 \
libmagic1=1:5.44-3 \
patch=2.7.6-7; \
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
apt-get install -y --no-install-recommends \
build-essential=12.9 \
python3-dev=3.11.2-1+b1 \
zlib1g-dev=1:1.2.13.dfsg-1 \
libjpeg-dev=1:2.1.5-2 \
libfreetype-dev=2.12.1+dfsg-5 \
libssl-dev=3.0.11-1~deb12u2 \
libffi-dev=3.4.4-1 \
libopenjp2-7=2.5.0-2 \
libtiff6=4.5.0-6+deb12u1 \
cargo=0.66.0+ds1-1 \
pkg-config=1.8.1-1 \
gcc-arm-linux-gnueabihf=4:12.2.0-3; \
fi; \
rm -rf \
patch=2.7.6-7 \
&& ( \
( \
[ "$TARGETARCH$TARGETVARIANT" = "armv7" ] && \
apt-get install -y --no-install-recommends \
build-essential=12.9 \
python3-dev=3.11.2-1+b1 \
zlib1g-dev=1:1.2.13.dfsg-1 \
libjpeg-dev=1:2.1.5-2 \
libfreetype-dev=2.12.1+dfsg-5+deb12u3 \
libssl-dev=3.0.13-1~deb12u1 \
libffi-dev=3.4.4-1 \
libopenjp2-7=2.5.0-2 \
libtiff6=4.5.0-6+deb12u1 \
cargo=0.66.0+ds1-1 \
pkg-config=1.8.1-1 \
gcc-arm-linux-gnueabihf=4:12.2.0-3 \
) \
|| [ "$TARGETARCH$TARGETVARIANT" != "armv7" ] \
) \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
@ -190,8 +194,8 @@ RUN \
clang-format-13=1:13.0.1-11+b2 \
clang-tidy-14=1:14.0.6-12 \
patch=2.7.6-7 \
software-properties-common=0.99.30-4 \
nano=7.2-1 \
software-properties-common=0.99.30-4.1~deb12u1 \
nano=7.2-1+deb12u1 \
build-essential=12.9 \
python3-dev=3.11.2-1+b1 \
&& rm -rf \

View File

@ -1,7 +1,7 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c, esp32
from esphome.const import CONF_ID, CONF_TEMPERATURE_OFFSET
from esphome.const import CONF_ID, CONF_SAMPLE_RATE, CONF_TEMPERATURE_OFFSET
CODEOWNERS = ["@trvrnrth"]
DEPENDENCIES = ["i2c"]
@ -11,7 +11,6 @@ MULTI_CONF = True
CONF_BME680_BSEC_ID = "bme680_bsec_id"
CONF_IAQ_MODE = "iaq_mode"
CONF_SUPPLY_VOLTAGE = "supply_voltage"
CONF_SAMPLE_RATE = "sample_rate"
CONF_STATE_SAVE_INTERVAL = "state_save_interval"
bme680_bsec_ns = cg.esphome_ns.namespace("bme680_bsec")

View File

@ -4,33 +4,33 @@ from esphome.components import sensor
from esphome.const import (
CONF_GAS_RESISTANCE,
CONF_HUMIDITY,
CONF_IAQ_ACCURACY,
CONF_PRESSURE,
CONF_SAMPLE_RATE,
CONF_TEMPERATURE,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
ICON_GAS_CYLINDER,
ICON_GAUGE,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
UNIT_HECTOPASCAL,
UNIT_OHM,
UNIT_PARTS_PER_MILLION,
UNIT_PERCENT,
ICON_GAS_CYLINDER,
ICON_GAUGE,
)
from . import (
BME680BSECComponent,
CONF_BME680_BSEC_ID,
CONF_SAMPLE_RATE,
SAMPLE_RATE_OPTIONS,
)
DEPENDENCIES = ["bme680_bsec"]
CONF_IAQ = "iaq"
CONF_IAQ_ACCURACY = "iaq_accuracy"
CONF_CO2_EQUIVALENT = "co2_equivalent"
CONF_BREATH_VOC_EQUIVALENT = "breath_voc_equivalent"
UNIT_IAQ = "IAQ"

View File

@ -1,11 +1,11 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import text_sensor
from esphome.const import CONF_IAQ_ACCURACY
from . import BME680BSECComponent, CONF_BME680_BSEC_ID
DEPENDENCIES = ["bme680_bsec"]
CONF_IAQ_ACCURACY = "iaq_accuracy"
ICON_ACCURACY = "mdi:checkbox-marked-circle-outline"
TYPES = [CONF_IAQ_ACCURACY]

View File

@ -1,7 +1,10 @@
import logging
import esphome.codegen as cg
import esphome.config_validation as cv
import esphome.final_validate as fv
from esphome.components.ota import BASE_OTA_SCHEMA, ota_to_code, OTAComponent
from esphome.config_helpers import merge_config
from esphome.const import (
CONF_ESPHOME,
CONF_ID,
@ -16,6 +19,8 @@ from esphome.const import (
)
from esphome.core import coroutine_with_priority
_LOGGER = logging.getLogger(__name__)
CODEOWNERS = ["@esphome/core"]
AUTO_LOAD = ["md5", "socket"]
@ -26,16 +31,62 @@ ESPHomeOTAComponent = esphome.class_("ESPHomeOTAComponent", OTAComponent)
def ota_esphome_final_validate(config):
fconf = fv.full_config.get()[CONF_OTA]
used_ports = []
for ota_conf in fconf:
full_conf = fv.full_config.get()
full_ota_conf = full_conf[CONF_OTA]
new_ota_conf = []
merged_ota_esphome_configs_by_port = {}
ports_with_merged_configs = []
for ota_conf in full_ota_conf:
if ota_conf.get(CONF_PLATFORM) == CONF_ESPHOME:
if (plat_port := ota_conf.get(CONF_PORT)) not in used_ports:
used_ports.append(plat_port)
if (
conf_port := ota_conf.get(CONF_PORT)
) not in merged_ota_esphome_configs_by_port:
merged_ota_esphome_configs_by_port[conf_port] = ota_conf
else:
raise cv.Invalid(
f"Only one instance of the {CONF_ESPHOME} {CONF_OTA} {CONF_PLATFORM} is allowed per port. Note that this error may result from OTA specified in packages"
if merged_ota_esphome_configs_by_port[conf_port][
CONF_VERSION
] != ota_conf.get(CONF_VERSION):
raise cv.Invalid(
f"Found multiple configurations but {CONF_VERSION} is inconsistent"
)
if (
merged_ota_esphome_configs_by_port[conf_port][CONF_ID].is_manual
and ota_conf.get(CONF_ID).is_manual
):
raise cv.Invalid(
f"Found multiple configurations but {CONF_ID} is inconsistent"
)
if (
CONF_PASSWORD in merged_ota_esphome_configs_by_port[conf_port]
and CONF_PASSWORD in ota_conf
and merged_ota_esphome_configs_by_port[conf_port][CONF_PASSWORD]
!= ota_conf.get(CONF_PASSWORD)
):
raise cv.Invalid(
f"Found multiple configurations but {CONF_PASSWORD} is inconsistent"
)
ports_with_merged_configs.append(conf_port)
merged_ota_esphome_configs_by_port[conf_port] = merge_config(
merged_ota_esphome_configs_by_port[conf_port], ota_conf
)
else:
new_ota_conf.append(ota_conf)
for port_conf in merged_ota_esphome_configs_by_port.values():
new_ota_conf.append(port_conf)
full_conf[CONF_OTA] = new_ota_conf
fv.full_config.set(full_conf)
if len(ports_with_merged_configs) > 0:
_LOGGER.warning(
"Found and merged multiple configurations for %s %s %s port(s) %s",
CONF_OTA,
CONF_PLATFORM,
CONF_ESPHOME,
ports_with_merged_configs,
)
CONFIG_SCHEMA = (

View File

@ -65,7 +65,8 @@ void EthernetComponent::setup() {
.intr_flags = 0,
};
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
defined(USE_ESP32_VARIANT_ESP32C6)
auto host = SPI2_HOST;
#else
auto host = SPI3_HOST;

View File

@ -38,6 +38,9 @@ PROTOCOL_MAX_TEMPERATURE = 30.0
PROTOCOL_TARGET_TEMPERATURE_STEP = 1.0
PROTOCOL_CURRENT_TEMPERATURE_STEP = 0.5
PROTOCOL_CONTROL_PACKET_SIZE = 10
PROTOCOL_MIN_SENSORS_PACKET_SIZE = 18
PROTOCOL_DEFAULT_SENSORS_PACKET_SIZE = 22
PROTOCOL_STATUS_MESSAGE_HEADER_SIZE = 0
CODEOWNERS = ["@paveldn"]
DEPENDENCIES = ["climate", "uart"]
@ -48,6 +51,9 @@ CONF_CONTROL_PACKET_SIZE = "control_packet_size"
CONF_HORIZONTAL_AIRFLOW = "horizontal_airflow"
CONF_ON_ALARM_START = "on_alarm_start"
CONF_ON_ALARM_END = "on_alarm_end"
CONF_ON_STATUS_MESSAGE = "on_status_message"
CONF_SENSORS_PACKET_SIZE = "sensors_packet_size"
CONF_STATUS_MESSAGE_HEADER_SIZE = "status_message_header_size"
CONF_VERTICAL_AIRFLOW = "vertical_airflow"
CONF_WIFI_SIGNAL = "wifi_signal"
@ -129,6 +135,11 @@ HaierAlarmEndTrigger = haier_ns.class_(
automation.Trigger.template(cg.uint8, cg.const_char_ptr),
)
StatusMessageTrigger = haier_ns.class_(
"StatusMessageTrigger",
automation.Trigger.template(cg.const_char_ptr, cg.size_t),
)
def validate_visual(config):
if CONF_VISUAL in config:
@ -193,6 +204,11 @@ BASE_CONFIG_SCHEMA = (
cv.Optional(
CONF_ANSWER_TIMEOUT,
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_ON_STATUS_MESSAGE): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StatusMessageTrigger),
}
),
}
)
.extend(uart.UART_DEVICE_SCHEMA)
@ -228,6 +244,14 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(
CONF_CONTROL_PACKET_SIZE, default=PROTOCOL_CONTROL_PACKET_SIZE
): cv.int_range(min=PROTOCOL_CONTROL_PACKET_SIZE, max=50),
cv.Optional(
CONF_SENSORS_PACKET_SIZE,
default=PROTOCOL_DEFAULT_SENSORS_PACKET_SIZE,
): cv.int_range(min=PROTOCOL_MIN_SENSORS_PACKET_SIZE, max=50),
cv.Optional(
CONF_STATUS_MESSAGE_HEADER_SIZE,
default=PROTOCOL_STATUS_MESSAGE_HEADER_SIZE,
): cv.int_range(min=PROTOCOL_STATUS_MESSAGE_HEADER_SIZE),
cv.Optional(
CONF_SUPPORTED_PRESETS,
default=["BOOST", "ECO", "SLEEP"], # No AWAY by default
@ -468,6 +492,16 @@ async def to_code(config):
config[CONF_CONTROL_PACKET_SIZE] - PROTOCOL_CONTROL_PACKET_SIZE
)
)
if CONF_SENSORS_PACKET_SIZE in config:
cg.add(
var.set_extra_sensors_packet_bytes_size(
config[CONF_SENSORS_PACKET_SIZE] - PROTOCOL_MIN_SENSORS_PACKET_SIZE
)
)
if CONF_STATUS_MESSAGE_HEADER_SIZE in config:
cg.add(
var.set_status_message_header_size(config[CONF_STATUS_MESSAGE_HEADER_SIZE])
)
for conf in config.get(CONF_ON_ALARM_START, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(
@ -478,5 +512,10 @@ async def to_code(config):
await automation.build_automation(
trigger, [(cg.uint8, "code"), (cg.const_char_ptr, "message")], conf
)
for conf in config.get(CONF_ON_STATUS_MESSAGE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(
trigger, [(cg.const_char_ptr, "data"), (cg.size_t, "data_size")], conf
)
# https://github.com/paveldn/HaierProtocol
cg.add_library("pavlodn/HaierProtocol", "0.9.28")
cg.add_library("pavlodn/HaierProtocol", "0.9.31")

View File

@ -186,6 +186,10 @@ void HaierClimateBase::send_custom_command(const haier_protocol::HaierMessage &m
this->action_request_ = PendingAction({ActionRequest::SEND_CUSTOM_COMMAND, message});
}
void HaierClimateBase::add_status_message_callback(std::function<void(const char *, size_t)> &&callback) {
this->status_message_callback_.add(std::move(callback));
}
haier_protocol::HandlerError HaierClimateBase::answer_preprocess_(
haier_protocol::FrameType request_message_type, haier_protocol::FrameType expected_request_message_type,
haier_protocol::FrameType answer_message_type, haier_protocol::FrameType expected_answer_message_type,

View File

@ -4,6 +4,7 @@
#include <set>
#include "esphome/components/climate/climate.h"
#include "esphome/components/uart/uart.h"
#include "esphome/core/automation.h"
// HaierProtocol
#include <protocol/haier_protocol.h>
@ -56,6 +57,7 @@ class HaierClimateBase : public esphome::Component,
void set_answer_timeout(uint32_t timeout);
void set_send_wifi(bool send_wifi);
void send_custom_command(const haier_protocol::HaierMessage &message);
void add_status_message_callback(std::function<void(const char *, size_t)> &&callback);
protected:
enum class ProtocolPhases {
@ -140,11 +142,19 @@ class HaierClimateBase : public esphome::Component,
esphome::climate::ClimateTraits traits_;
HvacSettings current_hvac_settings_;
HvacSettings next_hvac_settings_;
std::unique_ptr<uint8_t[]> last_status_message_;
std::unique_ptr<uint8_t[]> last_status_message_{nullptr};
std::chrono::steady_clock::time_point last_request_timestamp_; // For interval between messages
std::chrono::steady_clock::time_point last_valid_status_timestamp_; // For protocol timeout
std::chrono::steady_clock::time_point last_status_request_; // To request AC status
std::chrono::steady_clock::time_point last_signal_request_; // To send WiFI signal level
CallbackManager<void(const char *, size_t)> status_message_callback_{};
};
class StatusMessageTrigger : public Trigger<const char *, size_t> {
public:
explicit StatusMessageTrigger(HaierClimateBase *parent) {
parent->add_status_message_callback([this](const char *data, size_t data_size) { this->trigger(data, data_size); });
}
};
} // namespace haier

View File

@ -18,12 +18,13 @@ constexpr int PROTOCOL_OUTDOOR_TEMPERATURE_OFFSET = -64;
constexpr uint8_t CONTROL_MESSAGE_RETRIES = 5;
constexpr std::chrono::milliseconds CONTROL_MESSAGE_RETRIES_INTERVAL = std::chrono::milliseconds(500);
constexpr size_t ALARM_STATUS_REQUEST_INTERVAL_MS = 600000;
const uint8_t ONE_BUF[] = {0x00, 0x01};
const uint8_t ZERO_BUF[] = {0x00, 0x00};
HonClimate::HonClimate()
: cleaning_status_(CleaningState::NO_CLEANING), got_valid_outdoor_temp_(false), active_alarms_{0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00} {
last_status_message_ = std::unique_ptr<uint8_t[]>(new uint8_t[sizeof(hon_protocol::HaierPacketControl)]);
this->fan_mode_speed_ = (uint8_t) hon_protocol::FanMode::FAN_MID;
this->other_modes_fan_speed_ = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
}
@ -169,11 +170,18 @@ haier_protocol::HandlerError HonClimate::status_handler_(haier_protocol::FrameTy
this->action_request_.reset();
this->force_send_control_ = false;
} else {
if (data_size >= sizeof(hon_protocol::HaierPacketControl) + 2) {
memcpy(this->last_status_message_.get(), data + 2, sizeof(hon_protocol::HaierPacketControl));
if (!this->last_status_message_) {
this->real_control_packet_size_ = sizeof(hon_protocol::HaierPacketControl) + this->extra_control_packet_bytes_;
this->real_sensors_packet_size_ = sizeof(hon_protocol::HaierPacketSensors) + this->extra_sensors_packet_bytes_;
this->last_status_message_.reset();
this->last_status_message_ = std::unique_ptr<uint8_t[]>(new uint8_t[this->real_control_packet_size_]);
};
if (data_size >= this->real_control_packet_size_ + 2) {
memcpy(this->last_status_message_.get(), data + 2 + this->status_message_header_size_,
this->real_control_packet_size_);
this->status_message_callback_.call((const char *) data, data_size);
} else {
ESP_LOGW(TAG, "Status packet too small: %d (should be >= %d)", data_size,
sizeof(hon_protocol::HaierPacketControl));
ESP_LOGW(TAG, "Status packet too small: %d (should be >= %d)", data_size, this->real_control_packet_size_);
}
switch (this->protocol_phase_) {
case ProtocolPhases::SENDING_FIRST_STATUS_REQUEST:
@ -479,8 +487,8 @@ void HonClimate::initialization() {
}
haier_protocol::HaierMessage HonClimate::get_control_message() {
uint8_t control_out_buffer[sizeof(hon_protocol::HaierPacketControl)];
memcpy(control_out_buffer, this->last_status_message_.get(), sizeof(hon_protocol::HaierPacketControl));
uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
control_out_buffer[4] = 0; // This byte should be cleared before setting values
bool has_hvac_settings = false;
@ -636,7 +644,7 @@ haier_protocol::HaierMessage HonClimate::get_control_message() {
out_data->health_mode = this->health_mode_ ? 1 : 0;
return haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
control_out_buffer, sizeof(hon_protocol::HaierPacketControl));
control_out_buffer, this->real_control_packet_size_);
}
void HonClimate::process_alarm_message_(const uint8_t *packet, uint8_t size, bool check_new) {
@ -758,15 +766,17 @@ void HonClimate::update_sub_text_sensor_(SubTextSensorType type, const std::stri
#endif // USE_TEXT_SENSOR
haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *packet_buffer, uint8_t size) {
size_t expected_size = 2 + sizeof(hon_protocol::HaierPacketControl) + sizeof(hon_protocol::HaierPacketSensors) +
this->extra_control_packet_bytes_;
if (size < expected_size)
size_t expected_size =
2 + this->status_message_header_size_ + this->real_control_packet_size_ + this->real_sensors_packet_size_;
if (size < expected_size) {
ESP_LOGW(TAG, "Unexpected message size %d (expexted >= %d)", size, expected_size);
return haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
}
uint16_t subtype = (((uint16_t) packet_buffer[0]) << 8) + packet_buffer[1];
if ((subtype == 0x7D01) && (size >= expected_size + 4 + sizeof(hon_protocol::HaierPacketBigData))) {
if ((subtype == 0x7D01) && (size >= expected_size + sizeof(hon_protocol::HaierPacketBigData))) {
// Got BigData packet
const hon_protocol::HaierPacketBigData *bd_packet =
(const hon_protocol::HaierPacketBigData *) (&packet_buffer[expected_size + 4]);
(const hon_protocol::HaierPacketBigData *) (&packet_buffer[expected_size]);
#ifdef USE_SENSOR
this->update_sub_sensor_(SubSensorType::INDOOR_COIL_TEMPERATURE, bd_packet->indoor_coil_temperature / 2.0 - 20);
this->update_sub_sensor_(SubSensorType::OUTDOOR_COIL_TEMPERATURE, bd_packet->outdoor_coil_temperature - 64);
@ -795,9 +805,9 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
hon_protocol::HaierPacketControl control;
hon_protocol::HaierPacketSensors sensors;
} packet;
memcpy(&packet.control, packet_buffer + 2, sizeof(hon_protocol::HaierPacketControl));
memcpy(&packet.sensors,
packet_buffer + 2 + sizeof(hon_protocol::HaierPacketControl) + this->extra_control_packet_bytes_,
memcpy(&packet.control, packet_buffer + 2 + this->status_message_header_size_,
sizeof(hon_protocol::HaierPacketControl));
memcpy(&packet.sensors, packet_buffer + 2 + this->status_message_header_size_ + this->real_control_packet_size_,
sizeof(hon_protocol::HaierPacketSensors));
if (packet.sensors.error_status != 0) {
ESP_LOGW(TAG, "HVAC error, code=0x%02X", packet.sensors.error_status);
@ -996,8 +1006,6 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
}
void HonClimate::fill_control_messages_queue_() {
static uint8_t one_buf[] = {0x00, 0x01};
static uint8_t zero_buf[] = {0x00, 0x00};
if (!this->current_hvac_settings_.valid && !this->force_send_control_)
return;
this->clear_control_messages_queue_();
@ -1009,7 +1017,7 @@ void HonClimate::fill_control_messages_queue_() {
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::BEEPER_STATUS,
this->beeper_status_ ? zero_buf : one_buf, 2));
this->beeper_status_ ? ZERO_BUF : ONE_BUF, 2));
}
// Health mode
{
@ -1017,7 +1025,7 @@ void HonClimate::fill_control_messages_queue_() {
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::HEALTH_MODE,
this->health_mode_ ? one_buf : zero_buf, 2));
this->health_mode_ ? ONE_BUF : ZERO_BUF, 2));
}
// Climate mode
bool new_power = this->mode != CLIMATE_MODE_OFF;
@ -1092,7 +1100,7 @@ void HonClimate::fill_control_messages_queue_() {
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::AC_POWER,
new_power ? one_buf : zero_buf, 2));
new_power ? ONE_BUF : ZERO_BUF, 2));
}
// CLimate preset
{
@ -1165,6 +1173,35 @@ void HonClimate::fill_control_messages_queue_() {
(uint8_t) hon_protocol::DataParameters::SET_POINT,
buffer, 2));
}
// Vertical swing mode
if (climate_control.swing_mode.has_value()) {
uint8_t vertical_swing_buf[] = {0x00, (uint8_t) hon_protocol::VerticalSwingMode::AUTO};
uint8_t horizontal_swing_buf[] = {0x00, (uint8_t) hon_protocol::HorizontalSwingMode::AUTO};
switch (climate_control.swing_mode.value()) {
case CLIMATE_SWING_OFF:
horizontal_swing_buf[1] = (uint8_t) this->settings_.last_horizontal_swing;
vertical_swing_buf[1] = (uint8_t) this->settings_.last_vertiacal_swing;
break;
case CLIMATE_SWING_VERTICAL:
horizontal_swing_buf[1] = (uint8_t) this->settings_.last_horizontal_swing;
break;
case CLIMATE_SWING_HORIZONTAL:
vertical_swing_buf[1] = (uint8_t) this->settings_.last_vertiacal_swing;
break;
case CLIMATE_SWING_BOTH:
break;
}
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::HORIZONTAL_SWING_MODE,
horizontal_swing_buf, 2));
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::VERTICAL_SWING_MODE,
vertical_swing_buf, 2));
}
// Fan mode
if (climate_control.fan_mode.has_value()) {
switch (climate_control.fan_mode.value()) {
@ -1202,40 +1239,56 @@ void HonClimate::clear_control_messages_queue_() {
bool HonClimate::prepare_pending_action() {
switch (this->action_request_.value().action) {
case ActionRequest::START_SELF_CLEAN: {
uint8_t control_out_buffer[sizeof(hon_protocol::HaierPacketControl)];
memcpy(control_out_buffer, this->last_status_message_.get(), sizeof(hon_protocol::HaierPacketControl));
hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
out_data->self_cleaning_status = 1;
out_data->steri_clean = 0;
out_data->set_point = 0x06;
out_data->vertical_swing_mode = (uint8_t) hon_protocol::VerticalSwingMode::CENTER;
out_data->horizontal_swing_mode = (uint8_t) hon_protocol::HorizontalSwingMode::CENTER;
out_data->ac_power = 1;
out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
out_data->light_status = 0;
this->action_request_.value().message = haier_protocol::HaierMessage(
haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
control_out_buffer, sizeof(hon_protocol::HaierPacketControl));
}
return true;
case ActionRequest::START_STERI_CLEAN: {
uint8_t control_out_buffer[sizeof(hon_protocol::HaierPacketControl)];
memcpy(control_out_buffer, this->last_status_message_.get(), sizeof(hon_protocol::HaierPacketControl));
hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
out_data->self_cleaning_status = 0;
out_data->steri_clean = 1;
out_data->set_point = 0x06;
out_data->vertical_swing_mode = (uint8_t) hon_protocol::VerticalSwingMode::CENTER;
out_data->horizontal_swing_mode = (uint8_t) hon_protocol::HorizontalSwingMode::CENTER;
out_data->ac_power = 1;
out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
out_data->light_status = 0;
this->action_request_.value().message = haier_protocol::HaierMessage(
haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
control_out_buffer, sizeof(hon_protocol::HaierPacketControl));
}
return true;
case ActionRequest::START_SELF_CLEAN:
if (this->control_method_ == HonControlMethod::SET_GROUP_PARAMETERS) {
uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
out_data->self_cleaning_status = 1;
out_data->steri_clean = 0;
out_data->set_point = 0x06;
out_data->vertical_swing_mode = (uint8_t) hon_protocol::VerticalSwingMode::CENTER;
out_data->horizontal_swing_mode = (uint8_t) hon_protocol::HorizontalSwingMode::CENTER;
out_data->ac_power = 1;
out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
out_data->light_status = 0;
this->action_request_.value().message = haier_protocol::HaierMessage(
haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
control_out_buffer, this->real_control_packet_size_);
return true;
} else if (this->control_method_ == HonControlMethod::SET_SINGLE_PARAMETER) {
this->action_request_.value().message =
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::SELF_CLEANING,
ONE_BUF, 2);
return true;
} else {
this->action_request_.reset();
return false;
}
case ActionRequest::START_STERI_CLEAN:
if (this->control_method_ == HonControlMethod::SET_GROUP_PARAMETERS) {
uint8_t control_out_buffer[haier_protocol::MAX_FRAME_SIZE];
memcpy(control_out_buffer, this->last_status_message_.get(), this->real_control_packet_size_);
hon_protocol::HaierPacketControl *out_data = (hon_protocol::HaierPacketControl *) control_out_buffer;
out_data->self_cleaning_status = 0;
out_data->steri_clean = 1;
out_data->set_point = 0x06;
out_data->vertical_swing_mode = (uint8_t) hon_protocol::VerticalSwingMode::CENTER;
out_data->horizontal_swing_mode = (uint8_t) hon_protocol::HorizontalSwingMode::CENTER;
out_data->ac_power = 1;
out_data->ac_mode = (uint8_t) hon_protocol::ConditioningMode::DRY;
out_data->light_status = 0;
this->action_request_.value().message = haier_protocol::HaierMessage(
haier_protocol::FrameType::CONTROL, (uint16_t) hon_protocol::SubcommandsControl::SET_GROUP_PARAMETERS,
control_out_buffer, this->real_control_packet_size_);
return true;
} else {
// No Steri clean support (yet?) in SET_SINGLE_PARAMETER
this->action_request_.reset();
return false;
}
default:
return HaierClimateBase::prepare_pending_action();
}
@ -1251,6 +1304,7 @@ void HonClimate::process_protocol_reset() {
#endif // USE_SENSOR
this->got_valid_outdoor_temp_ = false;
this->hvac_hardware_info_.reset();
this->last_status_message_.reset(nullptr);
}
bool HonClimate::should_get_big_data_() {

View File

@ -104,6 +104,8 @@ class HonClimate : public HaierClimateBase {
void start_self_cleaning();
void start_steri_cleaning();
void set_extra_control_packet_bytes_size(size_t size) { this->extra_control_packet_bytes_ = size; };
void set_extra_sensors_packet_bytes_size(size_t size) { this->extra_sensors_packet_bytes_ = size; };
void set_status_message_header_size(size_t size) { this->status_message_header_size_ = size; };
void set_control_method(HonControlMethod method) { this->control_method_ = method; };
void add_alarm_start_callback(std::function<void(uint8_t, const char *)> &&callback);
void add_alarm_end_callback(std::function<void(uint8_t, const char *)> &&callback);
@ -158,7 +160,11 @@ class HonClimate : public HaierClimateBase {
esphome::optional<hon_protocol::HorizontalSwingMode> pending_horizontal_direction_{};
esphome::optional<HardwareInfo> hvac_hardware_info_{};
uint8_t active_alarms_[8];
int extra_control_packet_bytes_;
int extra_control_packet_bytes_{0};
int extra_sensors_packet_bytes_{4};
int status_message_header_size_{0};
int real_control_packet_size_{sizeof(hon_protocol::HaierPacketControl)};
int real_sensors_packet_size_{sizeof(hon_protocol::HaierPacketSensors) + 4};
HonControlMethod control_method_;
std::queue<haier_protocol::HaierMessage> control_messages_queue_;
CallbackManager<void(uint8_t, const char *)> alarm_start_callback_{};

View File

@ -41,15 +41,20 @@ enum class ConditioningMode : uint8_t {
enum class DataParameters : uint8_t {
AC_POWER = 0x01,
SET_POINT = 0x02,
VERTICAL_SWING_MODE = 0x03,
AC_MODE = 0x04,
FAN_MODE = 0x05,
USE_FAHRENHEIT = 0x07,
DISPLAY_STATUS = 0x09,
TEN_DEGREE = 0x0A,
HEALTH_MODE = 0x0B,
HORIZONTAL_SWING_MODE = 0x0C,
SELF_CLEANING = 0x0D,
BEEPER_STATUS = 0x16,
LOCK_REMOTE = 0x17,
QUIET_MODE = 0x19,
FAST_MODE = 0x1A,
SLEEP_MODE = 0x1B,
};
enum class SpecialMode : uint8_t { NONE = 0x00, ELDERLY = 0x01, CHILDREN = 0x02, PREGNANT = 0x03 };

View File

@ -37,6 +37,7 @@ haier_protocol::HandlerError Smartair2Climate::status_handler_(haier_protocol::F
} else {
if (data_size >= sizeof(smartair2_protocol::HaierPacketControl) + 2) {
memcpy(this->last_status_message_.get(), data + 2, sizeof(smartair2_protocol::HaierPacketControl));
this->status_message_callback_.call((const char *) data, data_size);
} else {
ESP_LOGW(TAG, "Status packet too small: %d (should be >= %d)", data_size,
sizeof(smartair2_protocol::HaierPacketControl));

View File

@ -116,19 +116,18 @@ void HttpRequestUpdate::update() {
}
}
std::string current_version = this->current_version_;
if (current_version.empty()) {
std::string current_version;
#ifdef ESPHOME_PROJECT_VERSION
current_version = ESPHOME_PROJECT_VERSION;
current_version = ESPHOME_PROJECT_VERSION;
#else
current_version = ESPHOME_VERSION;
current_version = ESPHOME_VERSION;
#endif
}
this->update_info_.current_version = current_version;
if (this->update_info_.latest_version.empty()) {
if (this->update_info_.latest_version.empty() || this->update_info_.latest_version == update_info_.current_version) {
this->state_ = update::UPDATE_STATE_NO_UPDATE;
} else if (this->update_info_.latest_version != this->current_version_) {
} else {
this->state_ = update::UPDATE_STATE_AVAILABLE;
}

View File

@ -22,15 +22,12 @@ class HttpRequestUpdate : public update::UpdateEntity, public PollingComponent {
void set_request_parent(HttpRequestComponent *request_parent) { this->request_parent_ = request_parent; }
void set_ota_parent(OtaHttpRequestComponent *ota_parent) { this->ota_parent_ = ota_parent; }
void set_current_version(const std::string &current_version) { this->current_version_ = current_version; }
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
protected:
HttpRequestComponent *request_parent_;
OtaHttpRequestComponent *ota_parent_;
std::string source_url_;
std::string current_version_{""};
};
} // namespace http_request

View File

@ -2,7 +2,7 @@ import esphome.config_validation as cv
import esphome.codegen as cg
from esphome import pins
from esphome.const import CONF_CHANNEL, CONF_ID, CONF_NUMBER
from esphome.const import CONF_CHANNEL, CONF_ID, CONF_NUMBER, CONF_SAMPLE_RATE
from esphome.components import microphone, esp32
from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin
@ -20,7 +20,6 @@ DEPENDENCIES = ["i2s_audio"]
CONF_ADC_PIN = "adc_pin"
CONF_ADC_TYPE = "adc_type"
CONF_PDM = "pdm"
CONF_SAMPLE_RATE = "sample_rate"
CONF_BITS_PER_SAMPLE = "bits_per_sample"
CONF_USE_APLL = "use_apll"

View File

@ -57,7 +57,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
}
}
break;
#if defined(CONFIG_ESP_CONSOLE_USB_CDC) && (defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3))
#ifdef USE_LOGGER_USB_CDC
case logger::UART_SELECTION_USB_CDC:
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
if (esp_usb_console_available_for_read()) {
@ -68,15 +68,15 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
byte = data;
}
break;
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
#endif // USE_LOGGER_USB_CDC
#ifdef USE_LOGGER_USB_SERIAL_JTAG
case logger::UART_SELECTION_USB_SERIAL_JTAG: {
if (usb_serial_jtag_read_bytes((char *) &data, 1, 0)) {
byte = data;
}
break;
}
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C6 || USE_ESP32_VARIANT_ESP32S3
#endif // USE_LOGGER_USB_SERIAL_JTAG
default:
break;
}
@ -99,19 +99,19 @@ void ImprovSerialComponent::write_data_(std::vector<uint8_t> &data) {
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32S2 && !USE_ESP32_VARIANT_ESP32S3
uart_write_bytes(this->uart_num_, data.data(), data.size());
break;
#if defined(CONFIG_ESP_CONSOLE_USB_CDC) && (defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3))
#ifdef USE_LOGGER_USB_CDC
case logger::UART_SELECTION_USB_CDC: {
const char *msg = (char *) data.data();
esp_usb_console_write_buf(msg, data.size());
break;
}
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
#endif // USE_LOGGER_USB_CDC
#ifdef USE_LOGGER_USB_SERIAL_JTAG
case logger::UART_SELECTION_USB_SERIAL_JTAG:
usb_serial_jtag_write_bytes((char *) data.data(), data.size(), 20 / portTICK_PERIOD_MS);
usb_serial_jtag_ll_txfifo_flush(); // fixes for issue in IDF 4.4.7
break;
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
#endif // USE_LOGGER_USB_SERIAL_JTAG
default:
break;
}

View File

@ -115,12 +115,15 @@ void LEDCOutput::write_state(float state) {
const uint32_t max_duty = (uint32_t(1) << this->bit_depth_) - 1;
const float duty_rounded = roundf(state * max_duty);
auto duty = static_cast<uint32_t>(duty_rounded);
#ifdef USE_ARDUINO
ESP_LOGV(TAG, "Setting duty: %u on channel %u", duty, this->channel_);
ledcWrite(this->channel_, duty);
#endif
#ifdef USE_ESP_IDF
// ensure that 100% on is not 99.975% on
if ((duty == max_duty) && (max_duty != 1)) {
duty = max_duty + 1;
}
auto speed_mode = get_speed_mode(channel_);
auto chan_num = static_cast<ledc_channel_t>(channel_ % 8);
int hpoint = ledc_angle_to_htop(this->phase_angle_, this->bit_depth_);

View File

@ -37,6 +37,7 @@ RAW_ENCODING = {
"NONE": RawEncoding.NONE,
"HEXBYTES": RawEncoding.HEXBYTES,
"COMMA": RawEncoding.COMMA,
"ANSI": RawEncoding.ANSI,
}
CONFIG_SCHEMA = cv.All(
@ -49,7 +50,7 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_REGISTER_TYPE): cv.enum(MODBUS_REGISTER_TYPE),
cv.Optional(CONF_REGISTER_COUNT, default=0): cv.positive_int,
cv.Optional(CONF_RESPONSE_SIZE, default=2): cv.positive_int,
cv.Optional(CONF_RAW_ENCODE, default="NONE"): cv.enum(RAW_ENCODING),
cv.Optional(CONF_RAW_ENCODE, default="ANSI"): cv.enum(RAW_ENCODING),
}
),
validate_modbus_register,

View File

@ -27,8 +27,11 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
sprintf(buffer, index != this->offset ? ",%d" : "%d", b);
output << buffer;
break;
case RawEncoding::ANSI:
if (b < 0x20)
break;
// FALLTHROUGH
// Anything else no encoding
case RawEncoding::NONE:
default:
output << (char) b;
break;

View File

@ -9,7 +9,7 @@
namespace esphome {
namespace modbus_controller {
enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2 };
enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2, ANSI = 3 };
class ModbusTextSensor : public Component, public text_sensor::TextSensor, public SensorItem {
public:

View File

@ -27,7 +27,7 @@ async def to_code(config):
var = await binary_sensor.new_binary_sensor(config)
hub = await cg.get_variable(config[CONF_MPR121_ID])
cg.add(var.set_channel(config[CONF_CHANNEL]))
cg.register_parented(var, hub)
await cg.register_parented(var, hub)
if CONF_TOUCH_THRESHOLD in config:
cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD]))

View File

@ -223,13 +223,19 @@ void Tuya::handle_command_(uint8_t command, uint8_t version, const uint8_t *buff
break;
case TuyaCommandType::DATAPOINT_DELIVER:
break;
case TuyaCommandType::DATAPOINT_REPORT:
case TuyaCommandType::DATAPOINT_REPORT_ASYNC:
case TuyaCommandType::DATAPOINT_REPORT_SYNC:
if (this->init_state_ == TuyaInitState::INIT_DATAPOINT) {
this->init_state_ = TuyaInitState::INIT_DONE;
this->set_timeout("datapoint_dump", 1000, [this] { this->dump_config(); });
this->initialized_callback_.call();
}
this->handle_datapoints_(buffer, len);
if (command_type == TuyaCommandType::DATAPOINT_REPORT_SYNC) {
this->send_command_(
TuyaCommand{.cmd = TuyaCommandType::DATAPOINT_REPORT_ACK, .payload = std::vector<uint8_t>{0x01}});
}
break;
case TuyaCommandType::DATAPOINT_QUERY:
break;
@ -423,7 +429,7 @@ void Tuya::send_raw_command_(TuyaCommand command) {
break;
case TuyaCommandType::DATAPOINT_DELIVER:
case TuyaCommandType::DATAPOINT_QUERY:
this->expected_response_ = TuyaCommandType::DATAPOINT_REPORT;
this->expected_response_ = TuyaCommandType::DATAPOINT_REPORT_ASYNC;
break;
default:
break;

View File

@ -53,10 +53,12 @@ enum class TuyaCommandType : uint8_t {
WIFI_RESET = 0x04,
WIFI_SELECT = 0x05,
DATAPOINT_DELIVER = 0x06,
DATAPOINT_REPORT = 0x07,
DATAPOINT_REPORT_ASYNC = 0x07,
DATAPOINT_QUERY = 0x08,
WIFI_TEST = 0x0E,
LOCAL_TIME_QUERY = 0x1C,
DATAPOINT_REPORT_SYNC = 0x22,
DATAPOINT_REPORT_ACK = 0x23,
WIFI_RSSI = 0x24,
VACUUM_MAP_UPLOAD = 0x28,
GET_NETWORK_STATUS = 0x2B,

View File

@ -96,10 +96,24 @@ void ESP32ArduinoUARTComponent::setup() {
next_uart_num++;
} else {
#ifdef USE_LOGGER
// The logger doesn't use this UART component, instead it targets the UARTs
// directly (i.e. Serial/Serial0, Serial1, and Serial2). If the logger is
// enabled, skip the UART that it is configured to use.
if (logger::global_logger->get_baud_rate() > 0 && logger::global_logger->get_uart() == next_uart_num) {
bool logger_uses_hardware_uart = true;
#ifdef USE_LOGGER_USB_CDC
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_CDC) {
// this is not a hardware UART, ignore it
logger_uses_hardware_uart = false;
}
#endif // USE_LOGGER_USB_CDC
#ifdef USE_LOGGER_USB_SERIAL_JTAG
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_SERIAL_JTAG) {
// this is not a hardware UART, ignore it
logger_uses_hardware_uart = false;
}
#endif // USE_LOGGER_USB_SERIAL_JTAG
if (logger_uses_hardware_uart && logger::global_logger->get_baud_rate() > 0 &&
logger::global_logger->get_uart() == next_uart_num) {
next_uart_num++;
}
#endif // USE_LOGGER

View File

@ -60,10 +60,30 @@ uart_config_t IDFUARTComponent::get_config_() {
void IDFUARTComponent::setup() {
static uint8_t next_uart_num = 0;
#ifdef USE_LOGGER
if (logger::global_logger->get_uart_num() == next_uart_num)
bool logger_uses_hardware_uart = true;
#ifdef USE_LOGGER_USB_CDC
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_CDC) {
// this is not a hardware UART, ignore it
logger_uses_hardware_uart = false;
}
#endif // USE_LOGGER_USB_CDC
#ifdef USE_LOGGER_USB_SERIAL_JTAG
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_SERIAL_JTAG) {
// this is not a hardware UART, ignore it
logger_uses_hardware_uart = false;
}
#endif // USE_LOGGER_USB_SERIAL_JTAG
if (logger_uses_hardware_uart && logger::global_logger->get_baud_rate() > 0 &&
logger::global_logger->get_uart_num() == next_uart_num) {
next_uart_num++;
#endif
}
#endif // USE_LOGGER
if (next_uart_num >= UART_NUM_MAX) {
ESP_LOGW(TAG, "Maximum number of UART components created already.");
this->mark_failed();

View File

@ -1,7 +1,9 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor
from esphome.components import sensor, time
from esphome.const import (
CONF_TIME_ID,
DEVICE_CLASS_TIMESTAMP,
ENTITY_CATEGORY_DIAGNOSTIC,
STATE_CLASS_TOTAL_INCREASING,
UNIT_SECOND,
@ -10,19 +12,50 @@ from esphome.const import (
)
uptime_ns = cg.esphome_ns.namespace("uptime")
UptimeSensor = uptime_ns.class_("UptimeSensor", sensor.Sensor, cg.PollingComponent)
UptimeSecondsSensor = uptime_ns.class_(
"UptimeSecondsSensor", sensor.Sensor, cg.PollingComponent
)
UptimeTimestampSensor = uptime_ns.class_(
"UptimeTimestampSensor", sensor.Sensor, cg.Component
)
CONFIG_SCHEMA = sensor.sensor_schema(
UptimeSensor,
unit_of_measurement=UNIT_SECOND,
icon=ICON_TIMER,
accuracy_decimals=0,
state_class=STATE_CLASS_TOTAL_INCREASING,
device_class=DEVICE_CLASS_DURATION,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
).extend(cv.polling_component_schema("60s"))
CONFIG_SCHEMA = cv.typed_schema(
{
"seconds": sensor.sensor_schema(
UptimeSecondsSensor,
unit_of_measurement=UNIT_SECOND,
icon=ICON_TIMER,
accuracy_decimals=0,
state_class=STATE_CLASS_TOTAL_INCREASING,
device_class=DEVICE_CLASS_DURATION,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
).extend(cv.polling_component_schema("60s")),
"timestamp": sensor.sensor_schema(
UptimeTimestampSensor,
icon=ICON_TIMER,
accuracy_decimals=0,
device_class=DEVICE_CLASS_TIMESTAMP,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
)
.extend(
cv.Schema(
{
cv.GenerateID(CONF_TIME_ID): cv.All(
cv.requires_component("time"), cv.use_id(time.RealTimeClock)
),
}
)
)
.extend(cv.COMPONENT_SCHEMA),
},
default_type="seconds",
)
async def to_code(config):
var = await sensor.new_sensor(config)
await cg.register_component(var, config)
if time_id_config := config.get(CONF_TIME_ID):
time_id = await cg.get_variable(time_id_config)
cg.add(var.set_time(time_id))

View File

@ -1,14 +1,15 @@
#include "uptime_sensor.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include "uptime_seconds_sensor.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace uptime {
static const char *const TAG = "uptime.sensor";
void UptimeSensor::update() {
void UptimeSecondsSensor::update() {
const uint32_t ms = millis();
const uint64_t ms_mask = (1ULL << 32) - 1ULL;
const uint32_t last_ms = this->uptime_ & ms_mask;
@ -26,9 +27,12 @@ void UptimeSensor::update() {
const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f;
this->publish_state(seconds);
}
std::string UptimeSensor::unique_id() { return get_mac_address() + "-uptime"; }
float UptimeSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
void UptimeSensor::dump_config() { LOG_SENSOR("", "Uptime Sensor", this); }
std::string UptimeSecondsSensor::unique_id() { return get_mac_address() + "-uptime"; }
float UptimeSecondsSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
void UptimeSecondsSensor::dump_config() {
LOG_SENSOR("", "Uptime Sensor", this);
ESP_LOGCONFIG(TAG, " Type: Seconds");
}
} // namespace uptime
} // namespace esphome

View File

@ -1,12 +1,12 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/core/component.h"
namespace esphome {
namespace uptime {
class UptimeSensor : public sensor::Sensor, public PollingComponent {
class UptimeSecondsSensor : public sensor::Sensor, public PollingComponent {
public:
void update() override;
void dump_config() override;

View File

@ -0,0 +1,39 @@
#include "uptime_timestamp_sensor.h"
#ifdef USE_TIME
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace uptime {
static const char *const TAG = "uptime.sensor";
void UptimeTimestampSensor::setup() {
this->time_->add_on_time_sync_callback([this]() {
if (this->has_state_)
return; // No need to update the timestamp if it's already set
auto now = this->time_->now();
const uint32_t ms = millis();
if (!now.is_valid())
return; // No need to update the timestamp if the time is not valid
time_t timestamp = now.timestamp;
uint32_t seconds = ms / 1000;
timestamp -= seconds;
this->publish_state(timestamp);
});
}
float UptimeTimestampSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
void UptimeTimestampSensor::dump_config() {
LOG_SENSOR("", "Uptime Sensor", this);
ESP_LOGCONFIG(TAG, " Type: Timestamp");
}
} // namespace uptime
} // namespace esphome
#endif // USE_TIME

View File

@ -0,0 +1,30 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_TIME
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/time/real_time_clock.h"
#include "esphome/core/component.h"
namespace esphome {
namespace uptime {
class UptimeTimestampSensor : public sensor::Sensor, public Component {
public:
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
void set_time(time::RealTimeClock *time) { this->time_ = time; }
protected:
time::RealTimeClock *time_;
};
} // namespace uptime
} // namespace esphome
#endif // USE_TIME

View File

@ -114,7 +114,7 @@ EAP_AUTH_SCHEMA = cv.All(
cv.Optional(CONF_USERNAME): cv.string_strict,
cv.Optional(CONF_PASSWORD): cv.string_strict,
cv.Optional(CONF_CERTIFICATE_AUTHORITY): wpa2_eap.validate_certificate,
cv.Optional(CONF_TTLS_PHASE_2): cv.All(
cv.SplitDefault(CONF_TTLS_PHASE_2, esp32_idf="mschapv2"): cv.All(
cv.enum(TTLS_PHASE_2), cv.only_with_esp_idf
),
cv.Inclusive(
@ -350,7 +350,7 @@ def eap_auth(config):
("ca_cert", ca_cert),
("client_cert", client_cert),
("client_key", key),
("ttls_phase_2", config.get(CONF_TTLS_PHASE_2, TTLS_PHASE_2["mschapv2"])),
("ttls_phase_2", config.get(CONF_TTLS_PHASE_2)),
)

View File

@ -757,7 +757,7 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
WiFiSTAConnectStatus WiFiComponent::wifi_sta_connect_status_() {
if (s_sta_connected && this->got_ipv4_address_) {
#if USE_NETWORK_IPV6
#if USE_NETWORK_IPV6 && (USE_NETWORK_MIN_IPV6_ADDR_COUNT > 0)
if (this->num_ipv6_addresses_ >= USE_NETWORK_MIN_IPV6_ADDR_COUNT) {
return WiFiSTAConnectStatus::CONNECTED;
}

View File

@ -132,7 +132,7 @@ async def to_code(config):
# the '+1' modifier is relative to the device's own address that will
# be automatically added to the provided list.
cg.add_build_flag(f"-DCONFIG_WIREGUARD_MAX_SRC_IPS={len(allowed_ips) + 1}")
cg.add_library("droscy/esp_wireguard", "0.4.1")
cg.add_library("droscy/esp_wireguard", "0.4.2")
await cg.register_component(var, config)

View File

@ -357,6 +357,7 @@ CONF_HUMIDITY_SENSOR = "humidity_sensor"
CONF_HYSTERESIS = "hysteresis"
CONF_I2C = "i2c"
CONF_I2C_ID = "i2c_id"
CONF_IAQ_ACCURACY = "iaq_accuracy"
CONF_IBEACON_MAJOR = "ibeacon_major"
CONF_IBEACON_MINOR = "ibeacon_minor"
CONF_IBEACON_UUID = "ibeacon_uuid"
@ -721,6 +722,7 @@ CONF_RX_BUFFER_SIZE = "rx_buffer_size"
CONF_RX_ONLY = "rx_only"
CONF_RX_PIN = "rx_pin"
CONF_SAFE_MODE = "safe_mode"
CONF_SAMPLE_RATE = "sample_rate"
CONF_SAMSUNG = "samsung"
CONF_SATELLITES = "satellites"
CONF_SCAN = "scan"

View File

@ -98,7 +98,7 @@ std::string to_string(long double value) { return str_snprintf("%Lf", 32, value)
// Mathematics
float lerp(float completion, float start, float end) { return start + (end - start) * completion; }
uint8_t crc8(uint8_t *data, uint8_t len) {
uint8_t crc8(const uint8_t *data, uint8_t len) {
uint8_t crc = 0;
while ((len--) != 0u) {

View File

@ -159,7 +159,7 @@ template<typename T, typename U> T remap(U value, U min, U max, T min_out, T max
}
/// Calculate a CRC-8 checksum of \p data with size \p len.
uint8_t crc8(uint8_t *data, uint8_t len);
uint8_t crc8(const uint8_t *data, uint8_t len);
/// Calculate a CRC-16 checksum of \p data with size \p len.
uint16_t crc16(const uint8_t *data, uint16_t len, uint16_t crc = 0xffff, uint16_t reverse_poly = 0xa001,

View File

@ -39,7 +39,7 @@ lib_deps =
bblanchon/ArduinoJson@6.18.5 ; json
wjtje/qr-code-generator-library@1.7.0 ; qr_code
functionpointer/arduino-MLX90393@1.0.0 ; mlx90393
pavlodn/HaierProtocol@0.9.28 ; haier
pavlodn/HaierProtocol@0.9.31 ; haier
; This is using the repository until a new release is published to PlatformIO
https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library
build_flags =
@ -94,7 +94,7 @@ lib_deps =
ESP8266mDNS ; mdns (Arduino built-in)
DNSServer ; captive_portal (Arduino built-in)
crankyoldgit/IRremoteESP8266@2.8.6 ; heatpumpir
droscy/esp_wireguard@0.4.1 ; wireguard
droscy/esp_wireguard@0.4.2 ; wireguard
build_flags =
${common:arduino.build_flags}
-Wno-nonnull-compare
@ -124,7 +124,7 @@ lib_deps =
DNSServer ; captive_portal (Arduino built-in)
esphome/ESP32-audioI2S@2.0.7 ; i2s_audio
crankyoldgit/IRremoteESP8266@2.8.6 ; heatpumpir
droscy/esp_wireguard@0.4.1 ; wireguard
droscy/esp_wireguard@0.4.2 ; wireguard
build_flags =
${common:arduino.build_flags}
-DUSE_ESP32
@ -142,7 +142,7 @@ platform_packages =
framework = espidf
lib_deps =
${common:idf.lib_deps}
droscy/esp_wireguard@0.4.1 ; wireguard
droscy/esp_wireguard@0.4.2 ; wireguard
build_flags =
${common:idf.build_flags}
-Wno-nonnull-compare
@ -174,7 +174,7 @@ extends = common:arduino
platform = libretiny
framework = arduino
lib_deps =
droscy/esp_wireguard@0.4.1 ; wireguard
droscy/esp_wireguard@0.4.2 ; wireguard
build_flags =
${common:arduino.build_flags}
-DUSE_LIBRETINY

View File

@ -140,7 +140,10 @@ def get_components(files: list[str], get_dependencies: bool = False):
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"-c", "--changed", action="store_true", help="Only run on changed files"
"-c",
"--changed",
action="store_true",
help="List all components required for testing based on changes",
)
parser.add_argument(
"-b", "--branch", help="Branch to compare changed files against"
@ -158,7 +161,9 @@ def main():
changed = changed_files(args.branch)
else:
changed = changed_files()
files = [f for f in files if f in changed]
# If any base test file(s) changed, there's no need to filter out components
if not any("tests/test_build_components" in file for file in changed):
files = [f for f in files if f in changed]
for c in get_components(files, args.changed):
print(c)

View File

@ -0,0 +1,114 @@
wifi:
ssid: MySSID
password: password1
uart:
- id: uart_haier
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
uart_id: uart_haier
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
haier_id: haier_ac
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
haier_id: haier_ac
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
haier_id: haier_ac
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
haier_id: haier_ac
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version

View File

@ -1,113 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO17
rx_pin: GPIO16
uart:
- id: uart_haier
tx_pin: 17
rx_pin: 16
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
haier_id: haier_ac
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
haier_id: haier_ac
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
haier_id: haier_ac
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
haier_id: haier_ac
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -1,109 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO4
rx_pin: GPIO5
uart:
- id: uart_haier
tx_pin: 4
rx_pin: 5
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -1,109 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO4
rx_pin: GPIO5
uart:
- id: uart_haier
tx_pin: 4
rx_pin: 5
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -1,109 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO17
rx_pin: GPIO16
uart:
- id: uart_haier
tx_pin: 17
rx_pin: 16
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -1,109 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO4
rx_pin: GPIO5
uart:
- id: uart_haier
tx_pin: 4
rx_pin: 5
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -1,109 +1,5 @@
wifi:
ssid: MySSID
password: password1
substitutions:
tx_pin: GPIO4
rx_pin: GPIO5
uart:
- id: uart_haier
tx_pin: 4
rx_pin: 5
baud_rate: 9600
climate:
- platform: haier
id: haier_ac
protocol: hOn
name: Haier AC
wifi_signal: true
answer_timeout: 200ms
beeper: true
visual:
min_temperature: 16 °C
max_temperature: 30 °C
temperature_step:
target_temperature: 1
current_temperature: 0.5
supported_modes:
- 'OFF'
- HEAT_COOL
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- 'OFF'
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- AWAY
- BOOST
- ECO
- SLEEP
on_alarm_start:
then:
- logger.log:
level: DEBUG
format: "Alarm activated. Code: %d. Message: \"%s\""
args: [code, message]
on_alarm_end:
then:
- logger.log:
level: DEBUG
format: "Alarm deactivated. Code: %d. Message: \"%s\""
args: [code, message]
sensor:
- platform: haier
outdoor_temperature:
name: Haier outdoor temperature
humidity:
name: Haier Indoor Humidity
compressor_current:
name: Haier Compressor Current
compressor_frequency:
name: Haier Compressor Frequency
expansion_valve_open_degree:
name: Haier Expansion Valve Open Degree
indoor_coil_temperature:
name: Haier Indoor Coil Temperature
outdoor_coil_temperature:
name: Haier Outdoor Coil Temperature
outdoor_defrost_temperature:
name: Haier Outdoor Defrost Temperature
outdoor_in_air_temperature:
name: Haier Outdoor In Air Temperature
outdoor_out_air_temperature:
name: Haier Outdoor Out Air Temperature
power:
name: Haier Power
binary_sensor:
- platform: haier
compressor_status:
name: Haier Outdoor Compressor Status
defrost_status:
name: Haier Defrost Status
four_way_valve_status:
name: Haier Four Way Valve Status
indoor_electric_heating_status:
name: Haier Indoor Electric Heating Status
indoor_fan_status:
name: Haier Indoor Fan Status
outdoor_fan_status:
name: Haier Outdoor Fan Status
button:
- platform: haier
self_cleaning:
name: Haier start self cleaning
steri_cleaning:
name: Haier start 56°C steri-cleaning
text_sensor:
- platform: haier
appliance_name:
name: Haier appliance name
cleaning_status:
name: Haier cleaning status
protocol_version:
name: Haier protocol version
<<: !include common.yaml

View File

@ -0,0 +1,8 @@
esphome:
on_boot:
then:
- logger.log: Hello world
logger:
level: DEBUG
hardware_uart: USB_CDC

View File

@ -0,0 +1,8 @@
esphome:
on_boot:
then:
- logger.log: Hello world
logger:
level: DEBUG
hardware_uart: USB_SERIAL_JTAG

View File

@ -0,0 +1 @@
<<: !include common-usb_cdc.yaml

View File

@ -0,0 +1 @@
<<: !include common-usb_cdc.yaml

View File

@ -0,0 +1 @@
<<: !include common-usb_cdc.yaml

View File

@ -0,0 +1 @@
<<: !include common-usb_cdc.yaml

View File

@ -0,0 +1 @@
<<: !include common-usb_serial_jtag.yaml

View File

@ -0,0 +1 @@
<<: !include common-usb_serial_jtag.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -1 +1 @@
<<: !include common.yaml
<<: !include common-default_uart.yaml

View File

@ -0,0 +1,6 @@
wifi:
ssid: MySSID
password: password1
mdns:
disabled: true

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,6 @@
wifi:
ssid: MySSID
password: password1
safe_mode:
disabled: true

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

@ -0,0 +1 @@
<<: !include common-enabled.yaml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_cdc.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_cdc.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_cdc.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_cdc.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_serial_jtag.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

View File

@ -0,0 +1,30 @@
<<: !include ../logger/common-usb_serial_jtag.yaml
esphome:
on_boot:
then:
- uart.write:
id: uart_1
data: 'Hello World'
- uart.write:
id: uart_1
data: [0x00, 0x20, 0x42]
uart:
- id: uart_1
tx_pin: 4
rx_pin: 5
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2
- id: uart_2
tx_pin: 6
rx_pin: 7
baud_rate: 9600
data_bits: 8
rx_buffer_size: 512
parity: EVEN
stop_bits: 2

Some files were not shown because too many files have changed in this diff Show More