Changing LIFX status directly via HTTP

Hi, I’ve been hitting a brick wall for an hour with this.

I’ve created a logicblock where the positive result is to turn my LIFX light on. Using this page LIFX Developer Zone - Set State I can successfully control my light, however I don’t understand how to pass the right values into apilio.

I’m using Method PUT and URL https://api.lifx.com/v1/lights/label:Halo/state (my light is called Halo) as that’s what works for the “selector” string on the LIFX dev page. Not sure if it transfers to a URL though?

I’ve then got Parameters “power” “on” and “colour” “red” just to test. Do I need anything in the body?
I assume I need to use the Header for an authorization? What is the format? I’ve tried Key: Authorization Value: Bearer [token] but that gives me a 401 Error - Bad access token. I briefly managed to get a 207 Error - Multi-Status but can’t remember how. I’m using the token generated from cloud.lifx Personal Access Token. The LIFX Dev Zone - Authentication page has cURL, PHP and Python but I don’t know how apilio can use that code.

Am I missing something basic or is this not possible?

1 Like

Hi @kaptainkitteh,
just to confirm: you only need to send a command from Apilio to LIFX, not the other way round. Correct?

1 Like

Hi @pebneter , yes that’s correct. I just want to turn the light on and change colours, I don’t need any info back from the light.

1 Like

I don’t have a LIFX account to test, but that’s how I’d try it:

1 Like

Thanks, that solved the access token for me! I think I must have dropped a colon after Bearer or something. I also realised I wasn’t using the American spelling for “color”. However the code in the Body didn’t work. I removed it and tried using Parameters and the light responded correctly, but for some reason apilio still says “HTTP action ‘Turn lights on’ sent by Apilio failed. Http response code was 207”. In any case, the light turns on, so that’s good enough for me. Thanks for your help!

1 Like

Thanks for the feedback.
We will implement a correction so that status 207 is not interpreted as failure anymore.

1 Like

Hi @kaptainkitteh ,
The request with the reponse code 207 should now be also reported as successful.

1 Like