diff --git a/esphome/codegen.py b/esphome/codegen.py index 5e1e934e58..3ea3df8706 100644 --- a/esphome/codegen.py +++ b/esphome/codegen.py @@ -75,8 +75,7 @@ from esphome.cpp_types import ( # noqa optional, arduino_json_ns, JsonObject, - JsonObjectRef, - JsonObjectConstRef, + JsonObjectConst, Controller, GPIOPin, InternalGPIOPin, diff --git a/esphome/components/http_request/__init__.py b/esphome/components/http_request/__init__.py index 774d6a0f91..e044e5fece 100644 --- a/esphome/components/http_request/__init__.py +++ b/esphome/components/http_request/__init__.py @@ -172,7 +172,7 @@ async def http_request_action_to_code(config, action_id, template_arg, args): if CONF_JSON in config: json_ = config[CONF_JSON] if isinstance(json_, Lambda): - args_ = args + [(cg.JsonObjectRef, "root")] + args_ = args + [(cg.JsonObject, "root")] lambda_ = await cg.process_lambda(json_, args_, return_type=cg.void) cg.add(var.set_json(lambda_)) else: diff --git a/esphome/components/http_request/http_request.h b/esphome/components/http_request/http_request.h index 9cc027b58d..a38bdf9c95 100644 --- a/esphome/components/http_request/http_request.h +++ b/esphome/components/http_request/http_request.h @@ -78,7 +78,7 @@ template class HttpRequestSendAction : public Action { void add_json(const char *key, TemplatableValue value) { this->json_.insert({key, value}); } - void set_json(std::function json_func) { this->json_func_ = json_func; } + void set_json(std::function json_func) { this->json_func_ = json_func; } void register_response_trigger(HttpRequestResponseTrigger *trigger) { this->response_triggers_.push_back(trigger); } @@ -118,17 +118,17 @@ template class HttpRequestSendAction : public Action { } protected: - void encode_json_(Ts... x, JsonObject &root) { + void encode_json_(Ts... x, JsonObject root) { for (const auto &item : this->json_) { auto val = item.second; root[item.first] = val.value(x...); } } - void encode_json_func_(Ts... x, JsonObject &root) { this->json_func_(x..., root); } + void encode_json_func_(Ts... x, JsonObject root) { this->json_func_(x..., root); } HttpRequestComponent *parent_; std::map> headers_{}; std::map> json_{}; - std::function json_func_{nullptr}; + std::function json_func_{nullptr}; std::vector response_triggers_; }; diff --git a/esphome/components/json/__init__.py b/esphome/components/json/__init__.py index fda0a552f1..6a0e4c50d2 100644 --- a/esphome/components/json/__init__.py +++ b/esphome/components/json/__init__.py @@ -7,12 +7,11 @@ json_ns = cg.esphome_ns.namespace("json") CONFIG_SCHEMA = cv.All( cv.Schema({}), - cv.only_with_arduino, ) @coroutine_with_priority(1.0) async def to_code(config): - cg.add_library("ottowinter/ArduinoJson-esphomelib", "5.13.3") + cg.add_library("bblanchon/ArduinoJson", "6.18.5") cg.add_define("USE_JSON") cg.add_global(json_ns.using) diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index 12c5beb73f..6a4eba78ab 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -1,8 +1,10 @@ -#ifdef USE_ARDUINO - #include "json_util.h" #include "esphome/core/log.h" +#ifdef USE_ESP8266 +#include +#endif + namespace esphome { namespace json { @@ -10,110 +12,49 @@ static const char *const TAG = "json"; static std::vector global_json_build_buffer; // NOLINT -const char *build_json(const json_build_t &f, size_t *length) { - global_json_buffer.clear(); - JsonObject &root = global_json_buffer.createObject(); +std::string build_json(const json_build_t &f) { + // Here we are allocating as much heap memory as available minus 2kb to be safe + // as we can not have a true dynamic sized document. + // The excess memory is freed below with `shrinkToFit()` +#ifdef USE_ESP8266 + const size_t free_heap = ESP.getMaxFreeBlockSize() - 2048; // NOLINT(readability-static-accessed-through-instance) +#elif defined(USE_ESP32) + const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) - 2048; +#endif + DynamicJsonDocument json_document(free_heap); + JsonObject root = json_document.to(); f(root); + json_document.shrinkToFit(); - // The Json buffer size gives us a good estimate for the required size. - // Usually, it's a bit larger than the actual required string size - // | JSON Buffer Size | String Size | - // Discovery | 388 | 351 | - // Discovery | 372 | 356 | - // Discovery | 336 | 311 | - // Discovery | 408 | 393 | - global_json_build_buffer.reserve(global_json_buffer.size() + 1); - size_t bytes_written = root.printTo(global_json_build_buffer.data(), global_json_build_buffer.capacity()); - - if (bytes_written >= global_json_build_buffer.capacity() - 1) { - global_json_build_buffer.reserve(root.measureLength() + 1); - bytes_written = root.printTo(global_json_build_buffer.data(), global_json_build_buffer.capacity()); - } - - *length = bytes_written; - return global_json_build_buffer.data(); + std::string output; + serializeJson(json_document, output); + return output; } -void parse_json(const std::string &data, const json_parse_t &f) { - global_json_buffer.clear(); - JsonObject &root = global_json_buffer.parseObject(data); - if (!root.success()) { +void parse_json(const std::string &data, const json_parse_t &f) { + // Here we are allocating as much heap memory as available minus 2kb to be safe + // as we can not have a true dynamic sized document. + // The excess memory is freed below with `shrinkToFit()` +#ifdef USE_ESP8266 + const size_t free_heap = ESP.getMaxFreeBlockSize() - 2048; // NOLINT(readability-static-accessed-through-instance) +#elif defined(USE_ESP32) + const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) - 2048; +#endif + + DynamicJsonDocument json_document(free_heap); + DeserializationError err = deserializeJson(json_document, data); + json_document.shrinkToFit(); + + JsonObject root = json_document.as(); + + if (err) { ESP_LOGW(TAG, "Parsing JSON failed."); return; } f(root); } -std::string build_json(const json_build_t &f) { - size_t len; - const char *c_str = build_json(f, &len); - return std::string(c_str, len); -} - -VectorJsonBuffer::String::String(VectorJsonBuffer *parent) : parent_(parent), start_(parent->size_) {} -void VectorJsonBuffer::String::append(char c) const { - char *last = static_cast(this->parent_->do_alloc(1)); - *last = c; -} -const char *VectorJsonBuffer::String::c_str() const { - this->append('\0'); - return &this->parent_->buffer_[this->start_]; -} -void VectorJsonBuffer::clear() { - for (char *block : this->free_blocks_) - free(block); // NOLINT - - this->size_ = 0; - this->free_blocks_.clear(); -} -VectorJsonBuffer::String VectorJsonBuffer::startString() { return {this}; } // NOLINT -void *VectorJsonBuffer::alloc(size_t bytes) { - // Make sure memory addresses are aligned - uint32_t new_size = round_size_up(this->size_); - this->resize(new_size); - return this->do_alloc(bytes); -} -void *VectorJsonBuffer::do_alloc(size_t bytes) { // NOLINT - const uint32_t begin = this->size_; - this->resize(begin + bytes); - return &this->buffer_[begin]; -} -void VectorJsonBuffer::resize(size_t size) { // NOLINT - if (size <= this->size_) { - this->size_ = size; - return; - } - - this->reserve(size); - this->size_ = size; -} -void VectorJsonBuffer::reserve(size_t size) { // NOLINT - if (size <= this->capacity_) - return; - - uint32_t target_capacity = this->capacity_; - if (this->capacity_ == 0) { - // lazily initialize with a reasonable size - target_capacity = JSON_OBJECT_SIZE(16); - } - while (target_capacity < size) - target_capacity *= 2; - - char *old_buffer = this->buffer_; - this->buffer_ = new char[target_capacity]; // NOLINT - if (old_buffer != nullptr && this->capacity_ != 0) { - this->free_blocks_.push_back(old_buffer); - memcpy(this->buffer_, old_buffer, this->capacity_); - } - this->capacity_ = target_capacity; -} - -size_t VectorJsonBuffer::size() const { return this->size_; } - -VectorJsonBuffer global_json_buffer; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) } // namespace json } // namespace esphome - -#endif // USE_ARDUINO diff --git a/esphome/components/json/json_util.h b/esphome/components/json/json_util.h index 577510e63a..57fe6107d8 100644 --- a/esphome/components/json/json_util.h +++ b/esphome/components/json/json_util.h @@ -1,68 +1,28 @@ #pragma once -#ifdef USE_ARDUINO - #include #include "esphome/core/helpers.h" + +#undef ARDUINOJSON_ENABLE_STD_STRING +#define ARDUINOJSON_ENABLE_STD_STRING 1 // NOLINT + #include namespace esphome { namespace json { /// Callback function typedef for parsing JsonObjects. -using json_parse_t = std::function; +using json_parse_t = std::function; /// Callback function typedef for building JsonObjects. -using json_build_t = std::function; +using json_build_t = std::function; /// Build a JSON string with the provided json build function. -const char *build_json(const json_build_t &f, size_t *length); - std::string build_json(const json_build_t &f); /// Parse a JSON string and run the provided json parse function if it's valid. void parse_json(const std::string &data, const json_parse_t &f); -class VectorJsonBuffer : public ArduinoJson::Internals::JsonBufferBase { - public: - class String { - public: - String(VectorJsonBuffer *parent); - - void append(char c) const; - - const char *c_str() const; - - protected: - VectorJsonBuffer *parent_; - uint32_t start_; - }; - - void *alloc(size_t bytes) override; - - size_t size() const; - - void clear(); - - String startString(); // NOLINT - - protected: - void *do_alloc(size_t bytes); // NOLINT - - void resize(size_t size); // NOLINT - - void reserve(size_t size); // NOLINT - - char *buffer_{nullptr}; - size_t size_{0}; - size_t capacity_{0}; - std::vector free_blocks_; -}; - -extern VectorJsonBuffer global_json_buffer; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - } // namespace json } // namespace esphome - -#endif // USE_ARDUINO diff --git a/esphome/components/light/light_json_schema.cpp b/esphome/components/light/light_json_schema.cpp index 2e07d91046..c126859076 100644 --- a/esphome/components/light/light_json_schema.cpp +++ b/esphome/components/light/light_json_schema.cpp @@ -8,7 +8,7 @@ namespace light { // See https://www.home-assistant.io/integrations/light.mqtt/#json-schema for documentation on the schema -void LightJSONSchema::dump_json(LightState &state, JsonObject &root) { +void LightJSONSchema::dump_json(LightState &state, JsonObject root) { if (state.supports_effects()) root["effect"] = state.get_effect_name(); @@ -52,7 +52,7 @@ void LightJSONSchema::dump_json(LightState &state, JsonObject &root) { if (values.get_color_mode() & ColorCapability::BRIGHTNESS) root["brightness"] = uint8_t(values.get_brightness() * 255); - JsonObject &color = root.createNestedObject("color"); + JsonObject color = root.createNestedObject("color"); if (values.get_color_mode() & ColorCapability::RGB) { color["r"] = uint8_t(values.get_color_brightness() * values.get_red() * 255); color["g"] = uint8_t(values.get_color_brightness() * values.get_green() * 255); @@ -72,7 +72,7 @@ void LightJSONSchema::dump_json(LightState &state, JsonObject &root) { } } -void LightJSONSchema::parse_color_json(LightState &state, LightCall &call, JsonObject &root) { +void LightJSONSchema::parse_color_json(LightState &state, LightCall &call, JsonObject root) { if (root.containsKey("state")) { auto val = parse_on_off(root["state"]); switch (val) { @@ -95,7 +95,7 @@ void LightJSONSchema::parse_color_json(LightState &state, LightCall &call, JsonO } if (root.containsKey("color")) { - JsonObject &color = root["color"]; + JsonObject color = root["color"]; // HA also encodes brightness information in the r, g, b values, so extract that and set it as color brightness. float max_rgb = 0.0f; if (color.containsKey("r")) { @@ -140,7 +140,7 @@ void LightJSONSchema::parse_color_json(LightState &state, LightCall &call, JsonO } } -void LightJSONSchema::parse_json(LightState &state, LightCall &call, JsonObject &root) { +void LightJSONSchema::parse_json(LightState &state, LightCall &call, JsonObject root) { LightJSONSchema::parse_color_json(state, call, root); if (root.containsKey("flash")) { diff --git a/esphome/components/light/light_json_schema.h b/esphome/components/light/light_json_schema.h index 09a372f11c..c92dd7b655 100644 --- a/esphome/components/light/light_json_schema.h +++ b/esphome/components/light/light_json_schema.h @@ -14,12 +14,12 @@ namespace light { class LightJSONSchema { public: /// Dump the state of a light as JSON. - static void dump_json(LightState &state, JsonObject &root); + static void dump_json(LightState &state, JsonObject root); /// Parse the JSON state of a light to a LightCall. - static void parse_json(LightState &state, LightCall &call, JsonObject &root); + static void parse_json(LightState &state, LightCall &call, JsonObject root); protected: - static void parse_color_json(LightState &state, LightCall &call, JsonObject &root); + static void parse_color_json(LightState &state, LightCall &call, JsonObject root); }; } // namespace light diff --git a/esphome/components/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index d677d54d23..755b0c685c 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -80,7 +80,7 @@ MQTTMessageTrigger = mqtt_ns.class_( "MQTTMessageTrigger", automation.Trigger.template(cg.std_string), cg.Component ) MQTTJsonMessageTrigger = mqtt_ns.class_( - "MQTTJsonMessageTrigger", automation.Trigger.template(cg.JsonObjectConstRef) + "MQTTJsonMessageTrigger", automation.Trigger.template(cg.JsonObjectConst) ) MQTTComponent = mqtt_ns.class_("MQTTComponent", cg.Component) MQTTConnectedCondition = mqtt_ns.class_("MQTTConnectedCondition", Condition) @@ -311,7 +311,7 @@ async def to_code(config): for conf in config.get(CONF_ON_JSON_MESSAGE, []): trig = cg.new_Pvariable(conf[CONF_TRIGGER_ID], conf[CONF_TOPIC], conf[CONF_QOS]) - await automation.build_automation(trig, [(cg.JsonObjectConstRef, "x")], conf) + await automation.build_automation(trig, [(cg.JsonObjectConst, "x")], conf) MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema( @@ -363,7 +363,7 @@ async def mqtt_publish_json_action_to_code(config, action_id, template_arg, args template_ = await cg.templatable(config[CONF_TOPIC], args, cg.std_string) cg.add(var.set_topic(template_)) - args_ = args + [(cg.JsonObjectRef, "root")] + args_ = args + [(cg.JsonObject, "root")] lambda_ = await cg.process_lambda(config[CONF_PAYLOAD], args_, return_type=cg.void) cg.add(var.set_payload(lambda_)) template_ = await cg.templatable(config[CONF_QOS], args, cg.uint8) diff --git a/esphome/components/mqtt/custom_mqtt_device.h b/esphome/components/mqtt/custom_mqtt_device.h index 9795d69304..0852a17cf1 100644 --- a/esphome/components/mqtt/custom_mqtt_device.h +++ b/esphome/components/mqtt/custom_mqtt_device.h @@ -74,9 +74,9 @@ class CustomMQTTDevice { * } * * // topic parameter can be remove if not needed: - * // e.g.: void on_json_message(JsonObject &payload) { + * // e.g.: void on_json_message(JsonObject payload) { * - * void on_json_message(const std::string &topic, JsonObject &payload) { + * void on_json_message(const std::string &topic, JsonObject payload) { * // do something with topic and payload * if (payload["number"] == 1) { * digitalWrite(5, HIGH); @@ -93,11 +93,9 @@ class CustomMQTTDevice { * @param qos The Quality of Service to subscribe with. Defaults to 0. */ template - void subscribe_json(const std::string &topic, void (T::*callback)(const std::string &, JsonObject &), - uint8_t qos = 0); + void subscribe_json(const std::string &topic, void (T::*callback)(const std::string &, JsonObject), uint8_t qos = 0); - template - void subscribe_json(const std::string &topic, void (T::*callback)(JsonObject &), uint8_t qos = 0); + template void subscribe_json(const std::string &topic, void (T::*callback)(JsonObject), uint8_t qos = 0); /** Publish an MQTT message with the given payload and QoS and retain settings. * @@ -155,7 +153,7 @@ class CustomMQTTDevice { * * ```cpp * void in_some_method() { - * publish("the/topic", [=](JsonObject &root) { + * publish("the/topic", [=](JsonObject root) { * root["the_key"] = "Hello World!"; * }, 0, false); * } @@ -174,7 +172,7 @@ class CustomMQTTDevice { * * ```cpp * void in_some_method() { - * publish("the/topic", [=](JsonObject &root) { + * publish("the/topic", [=](JsonObject root) { * root["the_key"] = "Hello World!"; * }); * } @@ -205,13 +203,13 @@ template void CustomMQTTDevice::subscribe(const std::string &topic, global_mqtt_client->subscribe(topic, f, qos); } template -void CustomMQTTDevice::subscribe_json(const std::string &topic, void (T::*callback)(const std::string &, JsonObject &), +void CustomMQTTDevice::subscribe_json(const std::string &topic, void (T::*callback)(const std::string &, JsonObject), uint8_t qos) { auto f = std::bind(callback, (T *) this, std::placeholders::_1, std::placeholders::_2); global_mqtt_client->subscribe_json(topic, f, qos); } template -void CustomMQTTDevice::subscribe_json(const std::string &topic, void (T::*callback)(JsonObject &), uint8_t qos) { +void CustomMQTTDevice::subscribe_json(const std::string &topic, void (T::*callback)(JsonObject), uint8_t qos) { auto f = std::bind(callback, (T *) this, std::placeholders::_2); global_mqtt_client->subscribe_json(topic, f, qos); } diff --git a/esphome/components/mqtt/mqtt_binary_sensor.cpp b/esphome/components/mqtt/mqtt_binary_sensor.cpp index 0a161f89a1..0bf3b751fd 100644 --- a/esphome/components/mqtt/mqtt_binary_sensor.cpp +++ b/esphome/components/mqtt/mqtt_binary_sensor.cpp @@ -29,7 +29,7 @@ MQTTBinarySensorComponent::MQTTBinarySensorComponent(binary_sensor::BinarySensor } } -void MQTTBinarySensorComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTBinarySensorComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { if (!this->binary_sensor_->get_device_class().empty()) root[MQTT_DEVICE_CLASS] = this->binary_sensor_->get_device_class(); if (this->binary_sensor_->is_status_binary_sensor()) diff --git a/esphome/components/mqtt/mqtt_binary_sensor.h b/esphome/components/mqtt/mqtt_binary_sensor.h index 0efb490367..f6579fcd19 100644 --- a/esphome/components/mqtt/mqtt_binary_sensor.h +++ b/esphome/components/mqtt/mqtt_binary_sensor.h @@ -22,7 +22,7 @@ class MQTTBinarySensorComponent : public mqtt::MQTTComponent { void dump_config() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; void set_is_status(bool status); diff --git a/esphome/components/mqtt/mqtt_button.cpp b/esphome/components/mqtt/mqtt_button.cpp index 5f3aaa1dd9..52df63093a 100644 --- a/esphome/components/mqtt/mqtt_button.cpp +++ b/esphome/components/mqtt/mqtt_button.cpp @@ -30,7 +30,7 @@ void MQTTButtonComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); } -void MQTTButtonComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTButtonComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { config.state_topic = false; if (!this->button_->get_device_class().empty()) root[MQTT_DEVICE_CLASS] = this->button_->get_device_class(); diff --git a/esphome/components/mqtt/mqtt_button.h b/esphome/components/mqtt/mqtt_button.h index 66e4b2609f..42389caecc 100644 --- a/esphome/components/mqtt/mqtt_button.h +++ b/esphome/components/mqtt/mqtt_button.h @@ -23,7 +23,7 @@ class MQTTButtonComponent : public mqtt::MQTTComponent { /// Buttons do not send a state so just return true. bool send_initial_state() override { return true; } - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; protected: /// "button" component type. diff --git a/esphome/components/mqtt/mqtt_client.cpp b/esphome/components/mqtt/mqtt_client.cpp index 43c49e9f7f..de25c5b2e3 100644 --- a/esphome/components/mqtt/mqtt_client.cpp +++ b/esphome/components/mqtt/mqtt_client.cpp @@ -1,4 +1,5 @@ #include "mqtt_client.h" +#define USE_MQTT #ifdef USE_MQTT @@ -346,7 +347,7 @@ void MQTTClientComponent::subscribe(const std::string &topic, mqtt_callback_t ca void MQTTClientComponent::subscribe_json(const std::string &topic, const mqtt_json_callback_t &callback, uint8_t qos) { auto f = [callback](const std::string &topic, const std::string &payload) { - json::parse_json(payload, [topic, callback](JsonObject &root) { callback(topic, root); }); + json::parse_json(payload, [topic, callback](JsonObject root) { callback(topic, root); }); }; MQTTSubscription subscription{ .topic = topic, @@ -416,9 +417,8 @@ bool MQTTClientComponent::publish(const MQTTMessage &message) { } bool MQTTClientComponent::publish_json(const std::string &topic, const json::json_build_t &f, uint8_t qos, bool retain) { - size_t len; - const char *message = json::build_json(f, &len); - return this->publish(topic, message, len, qos, retain); + std::string message = json::build_json(f); + return this->publish(topic, message, qos, retain); } /** Check if the message topic matches the given subscription topic diff --git a/esphome/components/mqtt/mqtt_client.h b/esphome/components/mqtt/mqtt_client.h index d6194da794..a6a7025c6f 100644 --- a/esphome/components/mqtt/mqtt_client.h +++ b/esphome/components/mqtt/mqtt_client.h @@ -20,7 +20,7 @@ namespace mqtt { * First parameter is the topic, the second one is the payload. */ using mqtt_callback_t = std::function; -using mqtt_json_callback_t = std::function; +using mqtt_json_callback_t = std::function; /// internal struct for MQTT messages. struct MQTTMessage { @@ -306,11 +306,11 @@ class MQTTMessageTrigger : public Trigger, public Component { optional payload_; }; -class MQTTJsonMessageTrigger : public Trigger { +class MQTTJsonMessageTrigger : public Trigger { public: explicit MQTTJsonMessageTrigger(const std::string &topic, uint8_t qos) { global_mqtt_client->subscribe_json( - topic, [this](const std::string &topic, JsonObject &root) { this->trigger(root); }, qos); + topic, [this](const std::string &topic, JsonObject root) { this->trigger(root); }, qos); } }; @@ -338,7 +338,7 @@ template class MQTTPublishJsonAction : public Action { TEMPLATABLE_VALUE(uint8_t, qos) TEMPLATABLE_VALUE(bool, retain) - void set_payload(std::function payload) { this->payload_ = payload; } + void set_payload(std::function payload) { this->payload_ = payload; } void play(Ts... x) override { auto f = std::bind(&MQTTPublishJsonAction::encode_, this, x..., std::placeholders::_1); @@ -349,8 +349,8 @@ template class MQTTPublishJsonAction : public Action { } protected: - void encode_(Ts... x, JsonObject &root) { this->payload_(x..., root); } - std::function payload_; + void encode_(Ts... x, JsonObject root) { this->payload_(x..., root); } + std::function payload_; MQTTClientComponent *parent_; }; diff --git a/esphome/components/mqtt/mqtt_climate.cpp b/esphome/components/mqtt/mqtt_climate.cpp index ebc708f444..f6ef3a5e8f 100644 --- a/esphome/components/mqtt/mqtt_climate.cpp +++ b/esphome/components/mqtt/mqtt_climate.cpp @@ -13,7 +13,7 @@ static const char *const TAG = "mqtt.climate"; using namespace esphome::climate; -void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTClimateComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { auto traits = this->device_->get_traits(); // current_temperature_topic if (traits.get_supports_current_temperature()) { @@ -25,7 +25,7 @@ void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryC // mode_state_topic root[MQTT_MODE_STATE_TOPIC] = this->get_mode_state_topic(); // modes - JsonArray &modes = root.createNestedArray(MQTT_MODES); + JsonArray modes = root.createNestedArray(MQTT_MODES); // sort array for nice UI in HA if (traits.supports_mode(CLIMATE_MODE_AUTO)) modes.add("auto"); @@ -83,7 +83,7 @@ void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryC // fan_mode_state_topic root[MQTT_FAN_MODE_STATE_TOPIC] = this->get_fan_mode_state_topic(); // fan_modes - JsonArray &fan_modes = root.createNestedArray("fan_modes"); + JsonArray fan_modes = root.createNestedArray("fan_modes"); if (traits.supports_fan_mode(CLIMATE_FAN_ON)) fan_modes.add("on"); if (traits.supports_fan_mode(CLIMATE_FAN_OFF)) @@ -112,7 +112,7 @@ void MQTTClimateComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryC // swing_mode_state_topic root[MQTT_SWING_MODE_STATE_TOPIC] = this->get_swing_mode_state_topic(); // swing_modes - JsonArray &swing_modes = root.createNestedArray("swing_modes"); + JsonArray swing_modes = root.createNestedArray("swing_modes"); if (traits.supports_swing_mode(CLIMATE_SWING_OFF)) swing_modes.add("off"); if (traits.supports_swing_mode(CLIMATE_SWING_BOTH)) diff --git a/esphome/components/mqtt/mqtt_climate.h b/esphome/components/mqtt/mqtt_climate.h index 40ac4c18c1..ea3e2ab3fa 100644 --- a/esphome/components/mqtt/mqtt_climate.h +++ b/esphome/components/mqtt/mqtt_climate.h @@ -14,7 +14,7 @@ namespace mqtt { class MQTTClimateComponent : public mqtt::MQTTComponent { public: MQTTClimateComponent(climate::Climate *device); - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; bool send_initial_state() override; std::string component_type() const override; void setup() override; diff --git a/esphome/components/mqtt/mqtt_component.cpp b/esphome/components/mqtt/mqtt_component.cpp index bf9f5e34b8..62dbae3bcc 100644 --- a/esphome/components/mqtt/mqtt_component.cpp +++ b/esphome/components/mqtt/mqtt_component.cpp @@ -63,7 +63,7 @@ bool MQTTComponent::send_discovery_() { return global_mqtt_client->publish_json( this->get_discovery_topic_(discovery_info), - [this](JsonObject &root) { + [this](JsonObject root) { SendDiscoveryConfig config; config.state_topic = true; config.command_topic = true; @@ -127,7 +127,7 @@ bool MQTTComponent::send_discovery_() { } } - JsonObject &device_info = root.createNestedObject(MQTT_DEVICE); + JsonObject device_info = root.createNestedObject(MQTT_DEVICE); device_info[MQTT_DEVICE_IDENTIFIERS] = get_mac_address(); device_info[MQTT_DEVICE_NAME] = node_name; device_info[MQTT_DEVICE_SW_VERSION] = "esphome v" ESPHOME_VERSION " " + App.get_compilation_time(); diff --git a/esphome/components/mqtt/mqtt_component.h b/esphome/components/mqtt/mqtt_component.h index 657ab7b608..e83523a712 100644 --- a/esphome/components/mqtt/mqtt_component.h +++ b/esphome/components/mqtt/mqtt_component.h @@ -70,7 +70,7 @@ class MQTTComponent : public Component { void call_dump_config() override; /// Send discovery info the Home Assistant, override this. - virtual void send_discovery(JsonObject &root, SendDiscoveryConfig &config) = 0; + virtual void send_discovery(JsonObject root, SendDiscoveryConfig &config) = 0; virtual bool send_initial_state() = 0; diff --git a/esphome/components/mqtt/mqtt_cover.cpp b/esphome/components/mqtt/mqtt_cover.cpp index 7e42abcd05..e5525bc0f7 100644 --- a/esphome/components/mqtt/mqtt_cover.cpp +++ b/esphome/components/mqtt/mqtt_cover.cpp @@ -63,7 +63,7 @@ void MQTTCoverComponent::dump_config() { ESP_LOGCONFIG(TAG, " Tilt Command Topic: '%s'", this->get_tilt_command_topic().c_str()); } } -void MQTTCoverComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTCoverComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { if (!this->cover_->get_device_class().empty()) root[MQTT_DEVICE_CLASS] = this->cover_->get_device_class(); diff --git a/esphome/components/mqtt/mqtt_cover.h b/esphome/components/mqtt/mqtt_cover.h index 149d46ac85..f3e6053d0b 100644 --- a/esphome/components/mqtt/mqtt_cover.h +++ b/esphome/components/mqtt/mqtt_cover.h @@ -16,7 +16,7 @@ class MQTTCoverComponent : public mqtt::MQTTComponent { explicit MQTTCoverComponent(cover::Cover *cover); void setup() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; MQTT_COMPONENT_CUSTOM_TOPIC(position, command) MQTT_COMPONENT_CUSTOM_TOPIC(position, state) diff --git a/esphome/components/mqtt/mqtt_fan.cpp b/esphome/components/mqtt/mqtt_fan.cpp index d58e3abc88..0f2eb6535f 100644 --- a/esphome/components/mqtt/mqtt_fan.cpp +++ b/esphome/components/mqtt/mqtt_fan.cpp @@ -120,7 +120,7 @@ void MQTTFanComponent::dump_config() { bool MQTTFanComponent::send_initial_state() { return this->publish_state(); } -void MQTTFanComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTFanComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { if (this->state_->get_traits().supports_oscillation()) { root[MQTT_OSCILLATION_COMMAND_TOPIC] = this->get_oscillation_command_topic(); root[MQTT_OSCILLATION_STATE_TOPIC] = this->get_oscillation_state_topic(); diff --git a/esphome/components/mqtt/mqtt_fan.h b/esphome/components/mqtt/mqtt_fan.h index a160d5366b..9d15a6cd0e 100644 --- a/esphome/components/mqtt/mqtt_fan.h +++ b/esphome/components/mqtt/mqtt_fan.h @@ -22,7 +22,7 @@ class MQTTFanComponent : public mqtt::MQTTComponent { MQTT_COMPONENT_CUSTOM_TOPIC(speed, command) MQTT_COMPONENT_CUSTOM_TOPIC(speed, state) - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) diff --git a/esphome/components/mqtt/mqtt_light.cpp b/esphome/components/mqtt/mqtt_light.cpp index 54204a9e7f..ee1cc36af7 100644 --- a/esphome/components/mqtt/mqtt_light.cpp +++ b/esphome/components/mqtt/mqtt_light.cpp @@ -18,7 +18,7 @@ std::string MQTTJSONLightComponent::component_type() const { return "light"; } const EntityBase *MQTTJSONLightComponent::get_entity() const { return this->state_; } void MQTTJSONLightComponent::setup() { - this->subscribe_json(this->get_command_topic_(), [this](const std::string &topic, JsonObject &root) { + this->subscribe_json(this->get_command_topic_(), [this](const std::string &topic, JsonObject root) { LightCall call = this->state_->make_call(); LightJSONSchema::parse_json(*this->state_, call, root); call.perform(); @@ -32,16 +32,16 @@ MQTTJSONLightComponent::MQTTJSONLightComponent(LightState *state) : MQTTComponen bool MQTTJSONLightComponent::publish_state_() { return this->publish_json(this->get_state_topic_(), - [this](JsonObject &root) { LightJSONSchema::dump_json(*this->state_, root); }); + [this](JsonObject root) { LightJSONSchema::dump_json(*this->state_, root); }); } LightState *MQTTJSONLightComponent::get_state() const { return this->state_; } -void MQTTJSONLightComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTJSONLightComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { root["schema"] = "json"; auto traits = this->state_->get_traits(); root[MQTT_COLOR_MODE] = true; - JsonArray &color_modes = root.createNestedArray("supported_color_modes"); + JsonArray color_modes = root.createNestedArray("supported_color_modes"); if (traits.supports_color_mode(ColorMode::ON_OFF)) color_modes.add("onoff"); if (traits.supports_color_mode(ColorMode::BRIGHTNESS)) @@ -66,7 +66,7 @@ void MQTTJSONLightComponent::send_discovery(JsonObject &root, mqtt::SendDiscover if (this->state_->supports_effects()) { root["effect"] = true; - JsonArray &effect_list = root.createNestedArray(MQTT_EFFECT_LIST); + JsonArray effect_list = root.createNestedArray(MQTT_EFFECT_LIST); for (auto *effect : this->state_->get_effects()) effect_list.add(effect->get_name()); effect_list.add("None"); diff --git a/esphome/components/mqtt/mqtt_light.h b/esphome/components/mqtt/mqtt_light.h index 192cba39b6..3d1e770d4d 100644 --- a/esphome/components/mqtt/mqtt_light.h +++ b/esphome/components/mqtt/mqtt_light.h @@ -21,7 +21,7 @@ class MQTTJSONLightComponent : public mqtt::MQTTComponent { void dump_config() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; bool send_initial_state() override; diff --git a/esphome/components/mqtt/mqtt_number.cpp b/esphome/components/mqtt/mqtt_number.cpp index 18e3a61417..73d37f7cd3 100644 --- a/esphome/components/mqtt/mqtt_number.cpp +++ b/esphome/components/mqtt/mqtt_number.cpp @@ -37,7 +37,7 @@ void MQTTNumberComponent::dump_config() { std::string MQTTNumberComponent::component_type() const { return "number"; } const EntityBase *MQTTNumberComponent::get_entity() const { return this->number_; } -void MQTTNumberComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTNumberComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { const auto &traits = number_->traits; // https://www.home-assistant.io/integrations/number.mqtt/ root[MQTT_MIN] = traits.get_min_value(); diff --git a/esphome/components/mqtt/mqtt_number.h b/esphome/components/mqtt/mqtt_number.h index 66622d7c29..10500c8333 100644 --- a/esphome/components/mqtt/mqtt_number.h +++ b/esphome/components/mqtt/mqtt_number.h @@ -25,7 +25,7 @@ class MQTTNumberComponent : public mqtt::MQTTComponent { void setup() override; void dump_config() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; bool send_initial_state() override; diff --git a/esphome/components/mqtt/mqtt_select.cpp b/esphome/components/mqtt/mqtt_select.cpp index b8371de00e..cb4c9c9052 100644 --- a/esphome/components/mqtt/mqtt_select.cpp +++ b/esphome/components/mqtt/mqtt_select.cpp @@ -32,10 +32,10 @@ void MQTTSelectComponent::dump_config() { std::string MQTTSelectComponent::component_type() const { return "select"; } const EntityBase *MQTTSelectComponent::get_entity() const { return this->select_; } -void MQTTSelectComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTSelectComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { const auto &traits = select_->traits; // https://www.home-assistant.io/integrations/select.mqtt/ - JsonArray &options = root.createNestedArray(MQTT_OPTIONS); + JsonArray options = root.createNestedArray(MQTT_OPTIONS); for (const auto &option : traits.get_options()) options.add(option); diff --git a/esphome/components/mqtt/mqtt_select.h b/esphome/components/mqtt/mqtt_select.h index d77d0cf513..e0d8ac2417 100644 --- a/esphome/components/mqtt/mqtt_select.h +++ b/esphome/components/mqtt/mqtt_select.h @@ -25,7 +25,7 @@ class MQTTSelectComponent : public mqtt::MQTTComponent { void setup() override; void dump_config() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; bool send_initial_state() override; diff --git a/esphome/components/mqtt/mqtt_sensor.cpp b/esphome/components/mqtt/mqtt_sensor.cpp index dd6423e8f3..303aa0e753 100644 --- a/esphome/components/mqtt/mqtt_sensor.cpp +++ b/esphome/components/mqtt/mqtt_sensor.cpp @@ -42,7 +42,7 @@ uint32_t MQTTSensorComponent::get_expire_after() const { void MQTTSensorComponent::set_expire_after(uint32_t expire_after) { this->expire_after_ = expire_after; } void MQTTSensorComponent::disable_expire_after() { this->expire_after_ = 0; } -void MQTTSensorComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTSensorComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { if (!this->sensor_->get_device_class().empty()) root[MQTT_DEVICE_CLASS] = this->sensor_->get_device_class(); diff --git a/esphome/components/mqtt/mqtt_sensor.h b/esphome/components/mqtt/mqtt_sensor.h index 22609fdfef..adc201736a 100644 --- a/esphome/components/mqtt/mqtt_sensor.h +++ b/esphome/components/mqtt/mqtt_sensor.h @@ -27,7 +27,7 @@ class MQTTSensorComponent : public mqtt::MQTTComponent { /// Disable Home Assistant value expiry. void disable_expire_after(); - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) diff --git a/esphome/components/mqtt/mqtt_switch.cpp b/esphome/components/mqtt/mqtt_switch.cpp index edaa6e7859..2e91f8e502 100644 --- a/esphome/components/mqtt/mqtt_switch.cpp +++ b/esphome/components/mqtt/mqtt_switch.cpp @@ -44,7 +44,7 @@ void MQTTSwitchComponent::dump_config() { std::string MQTTSwitchComponent::component_type() const { return "switch"; } const EntityBase *MQTTSwitchComponent::get_entity() const { return this->switch_; } -void MQTTSwitchComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTSwitchComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { if (this->switch_->assumed_state()) root[MQTT_OPTIMISTIC] = true; } diff --git a/esphome/components/mqtt/mqtt_switch.h b/esphome/components/mqtt/mqtt_switch.h index a0a7a23220..c4d3f7164c 100644 --- a/esphome/components/mqtt/mqtt_switch.h +++ b/esphome/components/mqtt/mqtt_switch.h @@ -20,7 +20,7 @@ class MQTTSwitchComponent : public mqtt::MQTTComponent { void setup() override; void dump_config() override; - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; bool send_initial_state() override; diff --git a/esphome/components/mqtt/mqtt_text_sensor.cpp b/esphome/components/mqtt/mqtt_text_sensor.cpp index 7b89915649..010364e221 100644 --- a/esphome/components/mqtt/mqtt_text_sensor.cpp +++ b/esphome/components/mqtt/mqtt_text_sensor.cpp @@ -12,7 +12,7 @@ static const char *const TAG = "mqtt.text_sensor"; using namespace esphome::text_sensor; MQTTTextSensor::MQTTTextSensor(TextSensor *sensor) : MQTTComponent(), sensor_(sensor) {} -void MQTTTextSensor::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) { +void MQTTTextSensor::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) { config.command_topic = false; } void MQTTTextSensor::setup() { diff --git a/esphome/components/mqtt/mqtt_text_sensor.h b/esphome/components/mqtt/mqtt_text_sensor.h index 83743245cc..fe53a6fefd 100644 --- a/esphome/components/mqtt/mqtt_text_sensor.h +++ b/esphome/components/mqtt/mqtt_text_sensor.h @@ -15,7 +15,7 @@ class MQTTTextSensor : public mqtt::MQTTComponent { public: explicit MQTTTextSensor(text_sensor::TextSensor *sensor); - void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override; + void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; void setup() override; diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index 1e7696edfb..4cc77da256 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -316,7 +316,7 @@ void WebServer::handle_sensor_request(AsyncWebServerRequest *request, const UrlM request->send(404); } std::string WebServer::sensor_json(sensor::Sensor *obj, float value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "sensor-" + obj->get_object_id(); std::string state = value_accuracy_to_string(value, obj->get_accuracy_decimals()); if (!obj->get_unit_of_measurement().empty()) @@ -342,7 +342,7 @@ void WebServer::handle_text_sensor_request(AsyncWebServerRequest *request, const request->send(404); } std::string WebServer::text_sensor_json(text_sensor::TextSensor *obj, const std::string &value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "text_sensor-" + obj->get_object_id(); root["state"] = value; root["value"] = value; @@ -355,7 +355,7 @@ void WebServer::on_switch_update(switch_::Switch *obj, bool state) { this->events_.send(this->switch_json(obj, state).c_str(), "state"); } std::string WebServer::switch_json(switch_::Switch *obj, bool value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "switch-" + obj->get_object_id(); root["state"] = value ? "ON" : "OFF"; root["value"] = value; @@ -410,7 +410,7 @@ void WebServer::on_binary_sensor_update(binary_sensor::BinarySensor *obj, bool s this->events_.send(this->binary_sensor_json(obj, state).c_str(), "state"); } std::string WebServer::binary_sensor_json(binary_sensor::BinarySensor *obj, bool value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "binary_sensor-" + obj->get_object_id(); root["state"] = value ? "ON" : "OFF"; root["value"] = value; @@ -431,7 +431,7 @@ void WebServer::handle_binary_sensor_request(AsyncWebServerRequest *request, con #ifdef USE_FAN void WebServer::on_fan_update(fan::FanState *obj) { this->events_.send(this->fan_json(obj).c_str(), "state"); } std::string WebServer::fan_json(fan::FanState *obj) { - return json::build_json([obj](JsonObject &root) { + return json::build_json([obj](JsonObject root) { root["id"] = "fan-" + obj->get_object_id(); root["state"] = obj->state ? "ON" : "OFF"; root["value"] = obj->state; @@ -580,7 +580,7 @@ void WebServer::handle_light_request(AsyncWebServerRequest *request, const UrlMa request->send(404); } std::string WebServer::light_json(light::LightState *obj) { - return json::build_json([obj](JsonObject &root) { + return json::build_json([obj](JsonObject root) { root["id"] = "light-" + obj->get_object_id(); root["state"] = obj->remote_values.is_on() ? "ON" : "OFF"; light::LightJSONSchema::dump_json(*obj, root); @@ -632,7 +632,7 @@ void WebServer::handle_cover_request(AsyncWebServerRequest *request, const UrlMa request->send(404); } std::string WebServer::cover_json(cover::Cover *obj) { - return json::build_json([obj](JsonObject &root) { + return json::build_json([obj](JsonObject root) { root["id"] = "cover-" + obj->get_object_id(); root["state"] = obj->is_fully_closed() ? "CLOSED" : "OPEN"; root["value"] = obj->position; @@ -659,7 +659,7 @@ void WebServer::handle_number_request(AsyncWebServerRequest *request, const UrlM request->send(404); } std::string WebServer::number_json(number::Number *obj, float value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "number-" + obj->get_object_id(); char buffer[64]; snprintf(buffer, sizeof(buffer), "%f", value); @@ -703,7 +703,7 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM request->send(404); } std::string WebServer::select_json(select::Select *obj, const std::string &value) { - return json::build_json([obj, value](JsonObject &root) { + return json::build_json([obj, value](JsonObject root) { root["id"] = "select-" + obj->get_object_id(); root["state"] = value; root["value"] = value; diff --git a/esphome/cpp_types.py b/esphome/cpp_types.py index 13d088e1cb..806a2d832c 100644 --- a/esphome/cpp_types.py +++ b/esphome/cpp_types.py @@ -27,8 +27,7 @@ Application = esphome_ns.class_("Application") optional = esphome_ns.class_("optional") arduino_json_ns = global_ns.namespace("ArduinoJson") JsonObject = arduino_json_ns.class_("JsonObject") -JsonObjectRef = JsonObject.operator("ref") -JsonObjectConstRef = JsonObjectRef.operator("const") +JsonObjectConst = arduino_json_ns.class_("JsonObjectConst") Controller = esphome_ns.class_("Controller") GPIOPin = esphome_ns.class_("GPIOPin") InternalGPIOPin = esphome_ns.class_("InternalGPIOPin", GPIOPin) diff --git a/platformio.ini b/platformio.ini index 3c0b725d65..d26b3c9c90 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,9 +27,10 @@ build_flags = [common] lib_deps = - esphome/noise-c@0.1.4 ; api - makuna/NeoPixelBus@2.6.9 ; neopixelbus - esphome/Improv@1.0.0 ; improv_serial / esp32_improv + esphome/noise-c@0.1.4 ; api + makuna/NeoPixelBus@2.6.9 ; neopixelbus + esphome/Improv@1.0.0 ; improv_serial / esp32_improv + bblanchon/ArduinoJson@6.18.5 ; json build_flags = -DESPHOME_LOG_LEVEL=ESPHOME_LOG_LEVEL_VERY_VERBOSE src_filter = @@ -42,7 +43,6 @@ extends = common lib_deps = ${common.lib_deps} ottowinter/AsyncMqttClient-esphome@0.8.6 ; mqtt - ottowinter/ArduinoJson-esphomelib@5.13.3 ; json esphome/ESPAsyncWebServer-esphome@2.1.0 ; web_server_base fastled/FastLED@3.3.2 ; fastled_base mikalhart/TinyGPSPlus@1.0.2 ; gps diff --git a/tests/unit_tests/test_codegen.py b/tests/unit_tests/test_codegen.py index 32d82b3062..3f32a117ff 100644 --- a/tests/unit_tests/test_codegen.py +++ b/tests/unit_tests/test_codegen.py @@ -68,8 +68,7 @@ from esphome import codegen as cg "optional", "arduino_json_ns", "JsonObject", - "JsonObjectRef", - "JsonObjectConstRef", + "JsonObjectConst", "Controller", "GPIOPin", ),