mirror of
https://github.com/esphome/esphome.git
synced 2025-10-01 09:32:21 +01:00
Merge branch 'dev' into multi_device
This commit is contained in:
@@ -3,7 +3,7 @@ import esphome.config_validation as cv
|
|||||||
from esphome.const import CONF_SIZE, CONF_TEXT
|
from esphome.const import CONF_SIZE, CONF_TEXT
|
||||||
from esphome.cpp_generator import MockObjClass
|
from esphome.cpp_generator import MockObjClass
|
||||||
|
|
||||||
from ..defines import CONF_MAIN, literal
|
from ..defines import CONF_MAIN
|
||||||
from ..lv_validation import color, color_retmapper, lv_text
|
from ..lv_validation import color, color_retmapper, lv_text
|
||||||
from ..lvcode import LocalVariable, lv, lv_expr
|
from ..lvcode import LocalVariable, lv, lv_expr
|
||||||
from ..schemas import TEXT_SCHEMA
|
from ..schemas import TEXT_SCHEMA
|
||||||
@@ -34,7 +34,7 @@ class QrCodeType(WidgetType):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_uses(self):
|
def get_uses(self):
|
||||||
return ("canvas", "img")
|
return ("canvas", "img", "label")
|
||||||
|
|
||||||
def obj_creator(self, parent: MockObjClass, config: dict):
|
def obj_creator(self, parent: MockObjClass, config: dict):
|
||||||
dark_color = color_retmapper(config[CONF_DARK_COLOR])
|
dark_color = color_retmapper(config[CONF_DARK_COLOR])
|
||||||
@@ -45,10 +45,8 @@ class QrCodeType(WidgetType):
|
|||||||
async def to_code(self, w: Widget, config):
|
async def to_code(self, w: Widget, config):
|
||||||
if (value := config.get(CONF_TEXT)) is not None:
|
if (value := config.get(CONF_TEXT)) is not None:
|
||||||
value = await lv_text.process(value)
|
value = await lv_text.process(value)
|
||||||
with LocalVariable(
|
with LocalVariable("qr_text", cg.std_string, value, modifier="") as str_obj:
|
||||||
"qr_text", cg.const_char_ptr, value, modifier=""
|
lv.qrcode_update(w.obj, str_obj.c_str(), str_obj.size())
|
||||||
) as str_obj:
|
|
||||||
lv.qrcode_update(w.obj, str_obj, literal(f"strlen({str_obj})"))
|
|
||||||
|
|
||||||
|
|
||||||
qr_code_spec = QrCodeType()
|
qr_code_spec = QrCodeType()
|
||||||
|
@@ -68,6 +68,7 @@ def AUTO_LOAD():
|
|||||||
|
|
||||||
CONF_DISCOVER_IP = "discover_ip"
|
CONF_DISCOVER_IP = "discover_ip"
|
||||||
CONF_IDF_SEND_ASYNC = "idf_send_async"
|
CONF_IDF_SEND_ASYNC = "idf_send_async"
|
||||||
|
CONF_WAIT_FOR_CONNECTION = "wait_for_connection"
|
||||||
|
|
||||||
|
|
||||||
def validate_message_just_topic(value):
|
def validate_message_just_topic(value):
|
||||||
@@ -298,6 +299,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_PUBLISH_NAN_AS_NONE, default=False): cv.boolean,
|
cv.Optional(CONF_PUBLISH_NAN_AS_NONE, default=False): cv.boolean,
|
||||||
|
cv.Optional(CONF_WAIT_FOR_CONNECTION, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
validate_config,
|
validate_config,
|
||||||
@@ -453,6 +455,8 @@ async def to_code(config):
|
|||||||
|
|
||||||
cg.add(var.set_publish_nan_as_none(config[CONF_PUBLISH_NAN_AS_NONE]))
|
cg.add(var.set_publish_nan_as_none(config[CONF_PUBLISH_NAN_AS_NONE]))
|
||||||
|
|
||||||
|
cg.add(var.set_wait_for_connection(config[CONF_WAIT_FOR_CONNECTION]))
|
||||||
|
|
||||||
|
|
||||||
MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema(
|
MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
|
@@ -176,7 +176,8 @@ void MQTTClientComponent::dump_config() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool MQTTClientComponent::can_proceed() {
|
bool MQTTClientComponent::can_proceed() {
|
||||||
return network::is_disabled() || this->state_ == MQTT_CLIENT_DISABLED || this->is_connected();
|
return network::is_disabled() || this->state_ == MQTT_CLIENT_DISABLED || this->is_connected() ||
|
||||||
|
!this->wait_for_connection_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MQTTClientComponent::start_dnslookup_() {
|
void MQTTClientComponent::start_dnslookup_() {
|
||||||
|
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
#ifdef USE_MQTT
|
#ifdef USE_MQTT
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
|
||||||
#include "esphome/core/automation.h"
|
|
||||||
#include "esphome/core/log.h"
|
|
||||||
#include "esphome/components/json/json_util.h"
|
#include "esphome/components/json/json_util.h"
|
||||||
#include "esphome/components/network/ip_address.h"
|
#include "esphome/components/network/ip_address.h"
|
||||||
|
#include "esphome/core/automation.h"
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
#if defined(USE_ESP32)
|
#if defined(USE_ESP32)
|
||||||
#include "mqtt_backend_esp32.h"
|
#include "mqtt_backend_esp32.h"
|
||||||
#elif defined(USE_ESP8266)
|
#elif defined(USE_ESP8266)
|
||||||
@@ -267,6 +267,8 @@ class MQTTClientComponent : public Component {
|
|||||||
void set_publish_nan_as_none(bool publish_nan_as_none);
|
void set_publish_nan_as_none(bool publish_nan_as_none);
|
||||||
bool is_publish_nan_as_none() const;
|
bool is_publish_nan_as_none() const;
|
||||||
|
|
||||||
|
void set_wait_for_connection(bool wait_for_connection) { this->wait_for_connection_ = wait_for_connection; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void send_device_info_();
|
void send_device_info_();
|
||||||
|
|
||||||
@@ -334,6 +336,7 @@ class MQTTClientComponent : public Component {
|
|||||||
optional<MQTTClientDisconnectReason> disconnect_reason_{};
|
optional<MQTTClientDisconnectReason> disconnect_reason_{};
|
||||||
|
|
||||||
bool publish_nan_as_none_{false};
|
bool publish_nan_as_none_{false};
|
||||||
|
bool wait_for_connection_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MQTTClientComponent *global_mqtt_client; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
extern MQTTClientComponent *global_mqtt_client; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
@@ -646,7 +646,9 @@ lvgl:
|
|||||||
on_click:
|
on_click:
|
||||||
lvgl.qrcode.update:
|
lvgl.qrcode.update:
|
||||||
id: lv_qr
|
id: lv_qr
|
||||||
text: homeassistant.io
|
text:
|
||||||
|
format: "A string with a number %d"
|
||||||
|
args: ['(int)(random_uint32() % 1000)']
|
||||||
|
|
||||||
- slider:
|
- slider:
|
||||||
min_value: 0
|
min_value: 0
|
||||||
|
Reference in New Issue
Block a user