mirror of
https://github.com/esphome/esphome.git
synced 2025-01-12 07:33:19 +01:00
Merge remote-tracking branch 'upstream/dev' into gsm
This commit is contained in:
commit
6cd0d8f8c2
14 changed files with 67 additions and 27 deletions
|
@ -141,7 +141,7 @@ struct ClimateDeviceRestoreState {
|
|||
float target_temperature_low;
|
||||
float target_temperature_high;
|
||||
};
|
||||
};
|
||||
} __attribute__((packed));
|
||||
float target_humidity;
|
||||
|
||||
/// Convert this struct to a climate call that can be performed.
|
||||
|
|
|
@ -39,8 +39,8 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
this->status_clear_warning();
|
||||
uint32_t data = 0;
|
||||
bool final_dout;
|
||||
|
||||
{
|
||||
InterruptLock lock;
|
||||
|
@ -59,8 +59,17 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
|
|||
this->sck_pin_->digital_write(false);
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
final_dout = this->dout_pin_->digital_read();
|
||||
}
|
||||
|
||||
if (!final_dout) {
|
||||
ESP_LOGW(TAG, "HX711 DOUT pin not high after reading (data 0x%" PRIx32 ")!", data);
|
||||
this->status_set_warning();
|
||||
return false;
|
||||
}
|
||||
|
||||
this->status_clear_warning();
|
||||
|
||||
if (data & 0x800000ULL) {
|
||||
data |= 0xFF000000ULL;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_LVGL_BINARY_SENSOR
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#endif // USE_LVGL_BINARY_SENSOR
|
||||
#endif // USE_BINARY_SENSOR
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
#include "esphome/components/rotary_encoder/rotary_encoder.h"
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
|
|
|
@ -19,7 +19,7 @@ class LVGLNumber : public number::Number {
|
|||
}
|
||||
|
||||
protected:
|
||||
void control(float value) {
|
||||
void control(float value) override {
|
||||
if (this->control_lambda_ != nullptr)
|
||||
this->control_lambda_(value);
|
||||
else
|
||||
|
|
|
@ -19,7 +19,7 @@ class LVGLSwitch : public switch_::Switch {
|
|||
}
|
||||
|
||||
protected:
|
||||
void write_state(bool value) {
|
||||
void write_state(bool value) override {
|
||||
if (this->state_lambda_ != nullptr)
|
||||
this->state_lambda_(value);
|
||||
else
|
||||
|
|
|
@ -19,7 +19,7 @@ class LVGLText : public text::Text {
|
|||
}
|
||||
|
||||
protected:
|
||||
void control(const std::string &value) {
|
||||
void control(const std::string &value) override {
|
||||
if (this->control_lambda_ != nullptr)
|
||||
this->control_lambda_(value);
|
||||
else
|
||||
|
|
|
@ -271,6 +271,7 @@ async def set_obj_properties(w: Widget, config):
|
|||
"""Generate a list of C++ statements to apply properties to an lv_obj_t"""
|
||||
if layout := config.get(CONF_LAYOUT):
|
||||
layout_type: str = layout[CONF_TYPE]
|
||||
add_lv_use(layout_type)
|
||||
lv_obj.set_layout(w.obj, literal(f"LV_LAYOUT_{layout_type.upper()}"))
|
||||
if layout_type == TYPE_GRID:
|
||||
wid = config[CONF_ID]
|
||||
|
@ -334,7 +335,7 @@ async def set_obj_properties(w: Widget, config):
|
|||
for key, value in states.items():
|
||||
if isinstance(value, cv.Lambda):
|
||||
lambs[key] = value
|
||||
elif value == "true":
|
||||
elif value:
|
||||
adds.add(key)
|
||||
else:
|
||||
clears.add(key)
|
||||
|
|
|
@ -150,12 +150,40 @@ bool MQTTComponent::send_discovery_() {
|
|||
const std::string &node_area = App.get_area();
|
||||
|
||||
JsonObject device_info = root.createNestedObject(MQTT_DEVICE);
|
||||
device_info[MQTT_DEVICE_IDENTIFIERS] = get_mac_address();
|
||||
const auto mac = get_mac_address();
|
||||
device_info[MQTT_DEVICE_IDENTIFIERS] = mac;
|
||||
device_info[MQTT_DEVICE_NAME] = node_friendly_name;
|
||||
device_info[MQTT_DEVICE_SW_VERSION] = "esphome v" ESPHOME_VERSION " " + App.get_compilation_time();
|
||||
#ifdef ESPHOME_PROJECT_NAME
|
||||
device_info[MQTT_DEVICE_SW_VERSION] = ESPHOME_PROJECT_VERSION " (ESPHome " ESPHOME_VERSION ")";
|
||||
const char *model = std::strchr(ESPHOME_PROJECT_NAME, '.');
|
||||
if (model == nullptr) { // must never happen but check anyway
|
||||
device_info[MQTT_DEVICE_MODEL] = ESPHOME_BOARD;
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = ESPHOME_PROJECT_NAME;
|
||||
} else {
|
||||
device_info[MQTT_DEVICE_MODEL] = model + 1;
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = std::string(ESPHOME_PROJECT_NAME, model - ESPHOME_PROJECT_NAME);
|
||||
}
|
||||
#else
|
||||
device_info[MQTT_DEVICE_SW_VERSION] = ESPHOME_VERSION " (" + App.get_compilation_time() + ")";
|
||||
device_info[MQTT_DEVICE_MODEL] = ESPHOME_BOARD;
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "espressif";
|
||||
device_info[MQTT_DEVICE_SUGGESTED_AREA] = node_area;
|
||||
#if defined(USE_ESP8266) || defined(USE_ESP32)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Espressif";
|
||||
#elif defined(USE_RP2040)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Raspberry Pi";
|
||||
#elif defined(USE_BK72XX)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Beken";
|
||||
#elif defined(USE_RTL87XX)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Realtek";
|
||||
#elif defined(USE_HOST)
|
||||
device_info[MQTT_DEVICE_MANUFACTURER] = "Host";
|
||||
#endif
|
||||
#endif
|
||||
if (!node_area.empty()) {
|
||||
device_info[MQTT_DEVICE_SUGGESTED_AREA] = node_area;
|
||||
}
|
||||
|
||||
device_info[MQTT_DEVICE_CONNECTIONS][0][0] = "mac";
|
||||
device_info[MQTT_DEVICE_CONNECTIONS][0][1] = mac;
|
||||
},
|
||||
this->qos_, discovery_info.retain);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ constexpr const char *const MQTT_DEVICE_MODEL = "mdl";
|
|||
constexpr const char *const MQTT_DEVICE_NAME = "name";
|
||||
constexpr const char *const MQTT_DEVICE_SUGGESTED_AREA = "sa";
|
||||
constexpr const char *const MQTT_DEVICE_SW_VERSION = "sw";
|
||||
constexpr const char *const MQTT_DEVICE_HW_VERSION = "hw";
|
||||
constexpr const char *const MQTT_DOCKED_TEMPLATE = "dock_tpl";
|
||||
constexpr const char *const MQTT_DOCKED_TOPIC = "dock_t";
|
||||
constexpr const char *const MQTT_EFFECT_COMMAND_TOPIC = "fx_cmd_t";
|
||||
|
@ -322,6 +323,7 @@ constexpr const char *const MQTT_DEVICE_MODEL = "model";
|
|||
constexpr const char *const MQTT_DEVICE_NAME = "name";
|
||||
constexpr const char *const MQTT_DEVICE_SUGGESTED_AREA = "suggested_area";
|
||||
constexpr const char *const MQTT_DEVICE_SW_VERSION = "sw_version";
|
||||
constexpr const char *const MQTT_DEVICE_HW_VERSION = "hw_version";
|
||||
constexpr const char *const MQTT_DOCKED_TEMPLATE = "docked_template";
|
||||
constexpr const char *const MQTT_DOCKED_TOPIC = "docked_topic";
|
||||
constexpr const char *const MQTT_EFFECT_COMMAND_TOPIC = "effect_command_topic";
|
||||
|
|
|
@ -13,7 +13,7 @@ class SpiLedStrip : public light::AddressableLight,
|
|||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
|
||||
spi::DATA_RATE_1MHZ> {
|
||||
public:
|
||||
void setup() { this->spi_setup(); }
|
||||
void setup() override { this->spi_setup(); }
|
||||
|
||||
int32_t size() const override { return this->num_leds_; }
|
||||
|
||||
|
@ -43,7 +43,7 @@ class SpiLedStrip : public light::AddressableLight,
|
|||
memset(this->buf_, 0, 4);
|
||||
}
|
||||
|
||||
void dump_config() {
|
||||
void dump_config() override {
|
||||
esph_log_config(TAG, "SPI LED Strip:");
|
||||
esph_log_config(TAG, " LEDs: %d", this->num_leds_);
|
||||
if (this->data_rate_ >= spi::DATA_RATE_1MHZ)
|
||||
|
|
|
@ -647,7 +647,7 @@ void Sprinkler::set_valve_run_duration(const optional<size_t> valve_number, cons
|
|||
return;
|
||||
}
|
||||
auto call = this->valve_[valve_number.value()].run_duration_number->make_call();
|
||||
if (this->valve_[valve_number.value()].run_duration_number->traits.get_unit_of_measurement() == min_str) {
|
||||
if (this->valve_[valve_number.value()].run_duration_number->traits.get_unit_of_measurement() == MIN_STR) {
|
||||
call.set_value(run_duration.value() / 60.0);
|
||||
} else {
|
||||
call.set_value(run_duration.value());
|
||||
|
@ -729,7 +729,7 @@ uint32_t Sprinkler::valve_run_duration(const size_t valve_number) {
|
|||
return 0;
|
||||
}
|
||||
if (this->valve_[valve_number].run_duration_number != nullptr) {
|
||||
if (this->valve_[valve_number].run_duration_number->traits.get_unit_of_measurement() == min_str) {
|
||||
if (this->valve_[valve_number].run_duration_number->traits.get_unit_of_measurement() == MIN_STR) {
|
||||
return static_cast<uint32_t>(roundf(this->valve_[valve_number].run_duration_number->state * 60));
|
||||
} else {
|
||||
return static_cast<uint32_t>(roundf(this->valve_[valve_number].run_duration_number->state));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace esphome {
|
||||
namespace sprinkler {
|
||||
|
||||
const std::string min_str = "min";
|
||||
const std::string MIN_STR = "min";
|
||||
|
||||
enum SprinklerState : uint8_t {
|
||||
// NOTE: these states are used by both SprinklerValveOperator and Sprinkler (the controller)!
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
import logging
|
||||
from importlib import resources
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
import tzlocal
|
||||
|
||||
from esphome import automation
|
||||
from esphome.automation import Condition
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import automation
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_AT,
|
||||
CONF_CRON,
|
||||
CONF_DAYS_OF_MONTH,
|
||||
CONF_DAYS_OF_WEEK,
|
||||
CONF_HOUR,
|
||||
CONF_HOURS,
|
||||
CONF_ID,
|
||||
CONF_MINUTE,
|
||||
CONF_MINUTES,
|
||||
CONF_MONTHS,
|
||||
CONF_ON_TIME,
|
||||
CONF_ON_TIME_SYNC,
|
||||
CONF_SECOND,
|
||||
CONF_SECONDS,
|
||||
CONF_TIMEZONE,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_AT,
|
||||
CONF_SECOND,
|
||||
CONF_HOUR,
|
||||
CONF_MINUTE,
|
||||
)
|
||||
from esphome.core import coroutine_with_priority
|
||||
from esphome.automation import Condition
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class EntityBase {
|
|||
EntityCategory entity_category_{ENTITY_CATEGORY_NONE};
|
||||
};
|
||||
|
||||
class EntityBase_DeviceClass {
|
||||
class EntityBase_DeviceClass { // NOLINT(readability-identifier-naming)
|
||||
public:
|
||||
/// Get the device class, using the manual override if set.
|
||||
std::string get_device_class();
|
||||
|
@ -74,7 +74,7 @@ class EntityBase_DeviceClass {
|
|||
const char *device_class_{nullptr}; ///< Device class override
|
||||
};
|
||||
|
||||
class EntityBase_UnitOfMeasurement {
|
||||
class EntityBase_UnitOfMeasurement { // NOLINT(readability-identifier-naming)
|
||||
public:
|
||||
/// Get the unit of measurement, using the manual override if set.
|
||||
std::string get_unit_of_measurement();
|
||||
|
|
Loading…
Reference in a new issue