# Configuration

Most aspects of POCS are controlled via a configuration file that is stored in `$HOME/conf_files/pocs.yaml`. Most of this file will work for your system by default, but there are a few changes that need to be made manually first.

## Configuration

### Initial setup command

Most of the basic configuration items can be changed with the `pocs config setup` command. You will be prompted to continue before proceeding so you don't accidentaly change any items. The current item in the config will apepar as the default (e.g. `[/home/panoptes/pocs]` and you can hit Enter to accept the default).&#x20;

```bash
> pocs config setup
Setting up configuration for your PANOPTES unit.
This will overwrite any existing configuration. Proceed? [y/N]: y
Enter the base directory for POCS [/home/panoptes/pocs]: 
Enter the user-friendly name for this unit [Generic PANOPTES Unit]: Alcyone
Enter the PANOPTES ID for this unit. If you don't have one yet just use the default. [PAN000]: PAN021
Enter the latitude for this unit, e.g. "19.5 deg" [19.54 deg]: 
Enter the longitude for this unit, e.g. "-154.12 deg" [-155.58 deg]: 
Enter the elevation for this unit. Use " ft" or " m" for units, e.g. "3400 m" or "12000 ft" [3400.0 m]: 
Enter the timezone for this unit [Pacific/Honolulu]: 
Enter the GMT offset for this unit [-600]: 
```

### Getting and setting config entries

You can use `pocs config get <key>` and `pocs config get <key> <value>` to get and set items in the configuration.

The `<key>` corresponds to the entries in the YAML configuration file (see below for manually editing and viewing the file).&#x20;

```bash
> pocs config get name
'Alcyone'
```

One note is that YAML can be "nested", so a value for a given key could be another key. For instance, if you look at the `location` config item you will see something like:

```bash
> pocs config get location
{'elevation': <Quantity 3400. m>,
 'flat_horizon': <Quantity -6. deg>,
 'focus_horizon': <Quantity -12. deg>,
 'gmt_offset': -600,
 'horizon': <Quantity 30. deg>,
 'latitude': <Quantity 19.54 deg>,
 'longitude': <Quantity -155.58 deg>,
 'name': 'Mauna Loa Observatory',
 'observe_horizon': <Quantity -18. deg>,
 'obstructions': [],
 'timezone': 'Pacific/Honolulu'}
```

Here the `latitude`, `longitude`, `elevation`, and other items are all nested underneath the main `location` keyword.  To access these individual keys you use a "dot-notation" for each nested level. This is especially useful when you want to `set` a new entry  For instance:

```bash
> pocs config get location.latitude
<Quantity 19.54 deg>

> pocs config get location.name
'Mauna Loa Observatory'bas

> pocs config set location.name "My Observatory"
{'location.name': 'Mauna Loa Observatory'}
```

In the above example the `location.latitude` has some units and so it returns what is called a `Quantity` (from `astropy` - don't worry about it).

To set a new value with a quantity you can use the abbreviated unit name, e.g. `deg` for degree or `m` for meter.

```bash
> pocs config set location.latitude "19.55 deg"
{'location.latitude': <Quantity 19.55 deg>}
```

{% hint style="info" %}
Note that we recommend using the `pocs config setup` command for the basic details as it will do some intelligent checking of the values.
{% endhint %}

The nested entries can be as deep as needed. For instance, the mount appears as follows:

<pre class="language-bash"><code class="lang-bash"><strong>> pocs config get mount
</strong>{'brand': 'ioptron',
 'commands_file': 'ioptron/v310',
 'driver': 'panoptes.pocs.mount.ioptron.cem40',
 'model': 'cem40',
 'serial': {'baudrate': 115200, 'port': '/dev/ttyUSB0', 'timeout': 0.0},
 'settings': {'max_tracking_threshold': 99999,
              'min_tracking_threshold': 100,
              'non_sidereal_available': True,
              'park': {'dec_direction': 'north',
                       'dec_seconds': 15,
                       'ra_direction': 'west',
                       'ra_seconds': 15},
              'update_tracking': False}}

> pocs config get mount.serial.port
'/dev/ttyUSB0'

> pocs config set mount.serial.port "/dev/ioptron"
{'mount.serial.port': '/dev/ioptron'}
</code></pre>

### Manual editing

All configuration changes are made to the `$HOME/conf_files/pocs_local.yaml` file, which can be edited in a number of ways.

#### Via Jupyter

You can open the configuration file in the Jupyter environment simply by clicking on it in the file browser. After making the changes make sure to restart the config server with `pocs config restart`.

#### Via shell

{% hint style="info" %}
See [Command Line & The Shell](/build/software/appendix/command-line-and-the-shell.md#getting-a-shell) for instructions on how to open a shell and get a command line prompt.
{% endhint %}

The configuration file can be editing via a text editor. If you are using the command line (the default), a good option is `nano`.  At the command line prompt, type:

```bash
nano $HOME/conf_files/pocs_local.yaml
```

{% hint style="info" %}
You can type `Ctrl-X` to save and exit `nano`
{% endhint %}

You should see a file with a lot of keywords and values, each separated by a colon (`:`).&#x20;

After making any changes be sure to restart the config server with `pocs config restart`, and check with `pocs config get` that the changes have been applied.

{% hint style="danger" %} <mark style="color:red;">**Troubleshooting:**</mark>**&#x20;what if the changes are not applied ?**

* Check $HOME/logs/config-server.log for warning or error message: `tail $HOME/logs/config-server.log`
* If you see warning that another instance was already running, find its PID, kill it and try again. Use `sudo lsof -i -P -n | grep 6563` to check if any process is using port number 6563 that pocs config server is using
* If a process is using port 6563, kill it with the `kill` command
* Then run `pocs config restart` and check again that the changes have been applied
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.projectpanoptes.org/build/software/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
