{"__v":3,"_id":"55f28173f9f3991900f38a1f","category":{"__v":3,"_id":"55f28172f9f3991900f38a16","pages":["55f28173f9f3991900f38a1d","55f28173f9f3991900f38a1e","55f28173f9f3991900f38a1f","55f28173f9f3991900f38a20","55f28173f9f3991900f38a21","55f28173f9f3991900f38a22","55f28173f9f3991900f38a23","55f28173f9f3991900f38a24","55f28173f9f3991900f38a25","55f28173f9f3991900f38a26","55f28173f9f3991900f38a27","55f63d46fe4cce21005c785e","55f65cc16be5ea0d00bbbf4c"],"project":"54ebb40d6423300d003672c0","version":"55f28172f9f3991900f38a13","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-06-17T05:23:31.147Z","from_sync":false,"order":2,"slug":"api-endpoints","title":"API Endpoints"},"editedParams":true,"editedParams2":true,"project":"54ebb40d6423300d003672c0","user":"5580f88e8625220d00429b74","version":{"__v":2,"_id":"55f28172f9f3991900f38a13","project":"54ebb40d6423300d003672c0","createdAt":"2015-09-11T07:23:30.065Z","releaseDate":"2015-09-11T07:23:30.065Z","categories":["55f28172f9f3991900f38a14","55f28172f9f3991900f38a15","55f28172f9f3991900f38a16","55f66acb297b37170058accb"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":["56bf854cd0e91b0d007239c5"],"next":{"pages":[],"description":""},"createdAt":"2015-09-07T00:57:22.407Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"curl -X PUT \"https://api.lifx.com/v1/lights/all/state\" \\\n     -H \"Authorization: Bearer [[app:Token]]\" \\\n     -d \"power=on\"","language":"curl","name":"cURL"},{"code":"<?php\n\n$link = \"https://api.lifx.com/v1/lights/all/state\";\n$authToken = \"[[app:Token]]\";\n\n$headers = array('Authorization: Bearer ' . $authToken);\n\n$data = 'power=on';\n\n$ch = curl_init($link);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"PUT\");\n$response = curl_exec($ch);\n\n?>","language":"php"},{"code":"import requests\n\ntoken = \"[[app:Token]]\"\n\nheaders = {\n    \"Authorization\": \"Bearer %s\" % token,\n}\n\npayload = {\n    \"power\": \"on\",\n}\n\nresponse = requests.put('https://api.lifx.com/v1/lights/all/state', data=payload, headers=headers)","language":"python"},{"code":"package main\n\nimport (\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tbody := strings.NewReader(`power=on`)\n\treq, err := http.NewRequest(\"PUT\", \"https://api.lifx.com/v1/lights/all/state\", body)\n\tif err != nil {\n\t\t// handle err\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer [[app:Token]]\")\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\t// handle err\n\t}\n\tdefer resp.Body.Close()\n\n}\n","language":"go"}]},"results":{"codes":[{"status":"2XX","language":"json","code":"{\n  \"results\": [\n    {\n      \"id\": \"d3b2f2d97452\",\n      \"label\": \"Left Lamp\",\n      \"status\": \"ok\"\n    }\n  ]\n}","name":""}]},"settings":"","auth":"required","params":[{"_id":"55810ef004ae5b0d00262877","ref":"","in":"path","required":true,"desc":"The [selector](doc:selectors) to limit which lights are controlled.","default":"","type":"string","name":"selector"},{"_id":"55810f5504ae5b0d0026287b","ref":"","in":"body","required":false,"desc":"The power state you want to set on the selector. `on` or `off`","default":"","type":"string","name":"power"},{"_id":"55ece0f254a67b1700edcf46","ref":"","in":"body","required":false,"desc":"The [color](doc:colors) to set the light to.","default":"","type":"string","name":"color"},{"_id":"55ece0f254a67b1700edcf45","ref":"","in":"body","required":false,"desc":"The brightness level from 0.0 to 1.0. Overrides any brightness set in `color` (if any).","default":"","type":"double","name":"brightness"},{"_id":"55810f5504ae5b0d0026287a","ref":"","in":"body","required":false,"desc":"How long in seconds you want the power action to take. Range: `0.0` – `3155760000.0` (100 years)","default":"1.0","type":"double","name":"duration"},{"_id":"5823fc3a0c90d02d00fe65cf","ref":"","in":"body","required":false,"desc":"The maximum brightness of the infrared channel.","default":"","type":"double","name":"infrared"}],"url":"/lights/:selector/state"},"isReference":false,"order":2,"body":"Sets the state of the lights within the selector. All parameters (except for the selector) are optional. If you don't supply a parameter, the API will leave that value untouched.\n\nFor example, if you want to turn the light on to a pale blue at 50% brightness over 5 seconds, you'd send:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// PUT /v1/lights/all/state\\n{\\n  \\\"power\\\": \\\"on\\\",\\n  \\\"color\\\": \\\"blue saturation:0.5\\\",\\n  \\\"brightness\\\": 0.5,\\n  \\\"duration\\\": 5,\\n\\n  \\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Infrared\"\n}\n[/block]\nIf you want to set Infrared to maximum brightness and shutdown the visible bands, you would send:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// PUT /v1/lights/all/state\\n{\\n  \\\"power\\\": \\\"off\\\",\\n  \\\"infrared\\\": 1.0, \\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"set-state","type":"put","title":"Set State"}

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

selector:
required
string
The [selector](doc:selectors) to limit which lights are controlled.

Body Params

power:
string
The power state you want to set on the selector. `on` or `off`
color:
string
The [color](doc:colors) to set the light to.
brightness:
double
The brightness level from 0.0 to 1.0. Overrides any brightness set in `color` (if any).
duration:
double1.0
How long in seconds you want the power action to take. Range: `0.0` – `3155760000.0` (100 years)
infrared:
double
The maximum brightness of the infrared channel.

Examples


Result Format


Documentation

Sets the state of the lights within the selector. All parameters (except for the selector) are optional. If you don't supply a parameter, the API will leave that value untouched. For example, if you want to turn the light on to a pale blue at 50% brightness over 5 seconds, you'd send: [block:code] { "codes": [ { "code": "// PUT /v1/lights/all/state\n{\n \"power\": \"on\",\n \"color\": \"blue saturation:0.5\",\n \"brightness\": 0.5,\n \"duration\": 5,\n\n \n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Infrared" } [/block] If you want to set Infrared to maximum brightness and shutdown the visible bands, you would send: [block:code] { "codes": [ { "code": "// PUT /v1/lights/all/state\n{\n \"power\": \"off\",\n \"infrared\": 1.0, \n}", "language": "json" } ] } [/block]

User Information

Try It Out

put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}