update createNestedObject

This commit is contained in:
Kevin Ahrendt 2025-05-20 14:19:54 +00:00
parent 8040c7cd92
commit ef072eb655
2 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ void LightJSONSchema::dump_json(LightState &state, JsonObject root) {
if (values.get_color_mode() & ColorCapability::BRIGHTNESS) if (values.get_color_mode() & ColorCapability::BRIGHTNESS)
root["brightness"] = uint8_t(values.get_brightness() * 255); root["brightness"] = uint8_t(values.get_brightness() * 255);
JsonObject color = root.createNestedObject("color"); JsonObject color = root["color"].to<JsonObject>();
if (values.get_color_mode() & ColorCapability::RGB) { if (values.get_color_mode() & ColorCapability::RGB) {
color["r"] = uint8_t(values.get_color_brightness() * values.get_red() * 255); color["r"] = uint8_t(values.get_color_brightness() * values.get_red() * 255);
color["g"] = uint8_t(values.get_color_brightness() * values.get_green() * 255); color["g"] = uint8_t(values.get_color_brightness() * values.get_green() * 255);

View File

@ -155,7 +155,7 @@ bool MQTTComponent::send_discovery_() {
} }
std::string node_area = App.get_area(); std::string node_area = App.get_area();
JsonObject device_info = root.createNestedObject(MQTT_DEVICE); JsonObject device_info = root[MQTT_DEVICE].to<JsonObject>();
const auto mac = get_mac_address(); const auto mac = get_mac_address();
device_info[MQTT_DEVICE_IDENTIFIERS] = mac; device_info[MQTT_DEVICE_IDENTIFIERS] = mac;
device_info[MQTT_DEVICE_NAME] = node_friendly_name; device_info[MQTT_DEVICE_NAME] = node_friendly_name;