mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	update createNestedObject
This commit is contained in:
		| @@ -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); | ||||||
|   | |||||||
| @@ -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; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user