Introduction

Quickstart

Make a key, read your device and change one zone's temperature.

This takes about five minutes. You need an Orion account with a device on it.

  1. Make an API key

    Sign in and open API keys. Create a key and give it a name you will recognise, such as home-script.

    The full key starts with os_ and is shown only once. Copy it now. If you lose it, revoke it and make a new one.

  2. Save the key in your shell

    Keep the key out of your code. Export it as an environment variable:

    export ORION_API_KEY="os_your_key_here"
    Shell

    The examples below read it from ORION_API_KEY.

  3. List your devices

    Ask for the devices on your account.

    curl https://api.orionsleep.com/v1/devices \
      -H "Authorization: Bearer $ORION_API_KEY"

    The answer, trimmed:

    {
    	"devices": [
    		{
    			"id": "3f6c2a9e-8b1d-4c57-9a0e-2d4b7f1c6e85",
    			"serial_number": "SN0012345",
    			"name": "Bedroom",
    			"zones": [
    				{ "id": "zone_a", "user": { "id": "9b2e4f10-5a7c-4d3b-8e61-0c9d2a4b7f33" } },
    				{ "id": "zone_b", "user": { "id": "c41d8e27-3f6a-4b90-a2d5-7e18f0b6c954" } }
    			],
    			"temperature_range": { "min": 10, "max": 45 },
    			"permissions": { "role": "owner" }
    		}
    	],
    	"shared_with": [{ "user": { "id": "c41d8e27-3f6a-4b90-a2d5-7e18f0b6c954" }, "is_away": false }]
    }
    JSON

    Keep the id of the device. It is the device_id in every other device request. The serial_number is for display only; requests do not take it.

  4. Read the device's live state

    Put the device id in the path.

    curl https://api.orionsleep.com/v1/devices/3f6c2a9e-8b1d-4c57-9a0e-2d4b7f1c6e85 \
      -H "Authorization: Bearer $ORION_API_KEY"

    The answer, trimmed:

    {
    	"serial_number": "SN0012345",
    	"zones": [
    		{ "id": "zone_a", "temp": 19, "on": true },
    		{ "id": "zone_b", "temp": 24, "on": true }
    	],
    	"led_brightness": 40,
    	"quiet_mode": false,
    	"status": {
    		"online": true,
    		"zones": [
    			{ "id": "zone_a", "temp": 26.8 },
    			{ "id": "zone_b", "temp": 28.1 }
    		]
    	}
    }
    JSON

    zones[].temp is the target you set. status.zones[].temp is the temperature measured in the bed.

  5. Set one zone's temperature

    Set zone_a to 20 °C. The change takes effect right away.

    curl -X PUT https://api.orionsleep.com/v1/devices/3f6c2a9e-8b1d-4c57-9a0e-2d4b7f1c6e85/zones/zone_a \
      -H "Authorization: Bearer $ORION_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{ "temp": 20 }'

    The answer lists every zone of the device after the change:

    {
    	"success": true,
    	"zones": [
    		{ "id": "zone_a", "temp": 20, "on": true },
    		{ "id": "zone_b", "temp": 24, "on": true }
    	]
    }
    JSON

Next steps