esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
285 stars 34 forks source link

REST API documentation is missing a parameter for lights #5750

Open dgnuff opened 2 weeks ago

dgnuff commented 2 weeks ago

The problem

The REST API documentation at https://esphome.io/web-api/index.html#light lists the following parameters for a POST call to turn on the light:

turn_on optional URL parameters:

brightness: The brightness of the light, from 0 to 255.

r: The red color channel of the light, from 0 to 255.

g: The green color channel of the light, from 0 to 255.

b: The blue color channel of the light, from 0 to 255.

white_value: The white channel of RGBW lights, from 0 to 255.

flash: Flash the color provided by the other properties for a duration in seconds.

transition: Transition to the specified color values in this duration in seconds.

effect: Set an effect for the light.

*color_temp*: Set the color temperature of the light, in mireds.

However, working with this bulb, I found that color mode calls using the "r", "g" and "b" parameters are ignored unless an additional parameter is provided: "color_mode=rgb".

This is not mentioned in the current documentation and should be added.

Steps to reproduce.

Connect an ESPHome light bulb to the local WiFi, and retrieve its IP address from the router.

Issue the following http calls:

http://XX.XX.XX.XX/light/<id>/turn_on?brightness=255&color_temp=370

Note that this turns the light on with a warm white color temp.

http://XX.XX.XX.XX/light/<id>/turn_off

This turns the light off again.

http://XX.XX.XX.XX/light/<id>/turn_on?r=255&g=0&b=0&brightness=255

Note that this turns the light on, but it does not respect the color sent, and instead turns back on warm white.

http://XX.XX.XX.XX/light/<id>/turn_off

This turns the light off again.

http://XX.XX.XX.XX/light/<id>/turn_on?color_mode=rgb&r=255&g=0&b=0&brightness=255

Note that this turns the light on, and this time it is red.

Conclusion. The "color_mode=rgb" parameter is required, and should therefore be documented as such.

Which version of ESPHome has the issue?

2023.9.1

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

Not using HA

What platform are you using?

ESP8266

Board

Kauf BLF19

Component causing the issue

rest api

Example YAML snippet

No response

Anything in the logs that might be useful for us?

When a call is made without the "color_mode" parameter, the following message is reported in the log:

19:40:15    [I] [light:473] 
'Kauf Bulb' - Using color mode RGB for call without color mode.


### Additional information

_No response_