How to set bulb color by http call?

Hello may I ask for advice please? I have python script running on other server and I can access Home Assistant OS server from internet.

Is it possible to call HA service over http, that would set color of a bulb or group of bulbs to defined RGB parameters that are sent over http? Does HA core has API that can receive events from net as it receives from lovelace?

I have read about webhooks but I understand I cannot send parameters over webhook.

You can send data encoded as json with webhooks. This data can then be used in automations.

I tried this but getting error. Apparently I am unable to convert yaml structure to json:

curl -X post -H "Authorization: Bearer eyJ0e - shortened - 51Bj-fR-o" -H "Content-Type: application/json" -d '{"entity_id": "light.21800710dc4f22741488_2", "data": "rgb_color":, "- 255", "- 0", "- 0"}' http://10.0.0.54:8123/api/services/switch/turn_on

error

Bad status line ‘invalid HTTP method’

I made some corrections that worked in other posts but still getting same error:

curl -X post -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJoGD2uD6Dre8803Wz51Bj-fR-o" -H "Content-Type: application/json" -d '{"entity_id": "light.21800710dc4f22741488_2", "rgb_color": "[255,0,0]"}' http://10.0.0.54:8123/api/services/light/turn_on

It is tuya RGB light, somwehere I read that HA does not support tuya color, but I also have “Tuya Custom” integration that should solve it.

Solved it. Array [255,0,0] cannot be in quotes.

1 Like

Hi, I would like to do something like this to give someone the ability to change a light bulb color via url. Are you able to walk me through this? I don’t have a python server or know python. I know home assistant and know how to create webhooks, in theory. Is there an easy way to do this? or is it more complicated?