# Homey Compose

## File structure

The file structure when using compose looks as follows. This is an overview of all files that can be used with Homey Compose.

```
com.athom.example/
├─ .homeycompose/
│  ├─ app.json
│  ├─ capabilities/
│  │  └─ <id>.json
│  ├─ screensavers/
│  │  └─ <id>.json
│  ├─ signals/
│  │  ├─ 433/
│  │  │  └─ <id>.json
│  │  ├─ 868/
│  │  │  └─ <id>.json
│  │  └─ ir/
│  │     └─ <id>.json
│  ├─ flow/
│  │  ├─ triggers/
│  │  │  └─ <id>.json
│  │  ├─ conditions/
│  │  │  └─ <id>.json
│  │  └─ actions/
│  │     └─ <id>.json
│  ├─ discovery/
│  │  └─ <id>.json
│  ├─ drivers/
│  │  ├─ templates/
│  │  │  └─ <template_id>.json
│  │  ├─ settings/
│  │  │  └─ <setting_id>.json
│  │  └─ flow/
│  │     ├─ triggers/
│  │     │  └─ <id>.json
│  │     ├─ conditions/
│  │     │  └─ <id>.json
│  │     └─ actions/
│  │        └─ <id>.json
│  └─ locales/
│     ├─ <locale>.json
│     └─ <locale.foo>.json
└─ drivers/
   └─ <driver_id>/
      ├─ driver.compose.json
      ├─ driver.flow.compose.json
      └─ driver.settings.compose.json
```

## Templating

Compose also allows for creating driver and setting templates to share common properties, for example RF signals, assets, etc. You can create a driver template by placing the shared properties in `.homeycompose/drivers/templates/<template_id>.json`. Then extend from the template in your driver compose file by placing the template id the `$extends` property in `driver.compose.json`. Compose will copy all properties from the template to the final file. Should you want to overwrite a property, you can do so by placing it in your `driver.compose.json`.

{% code title="/.homeycompose/drivers/templates/defaults.json" %}

```javascript
{
  "images": {
    "large": "{{driverAssetsPath}}/images/large.png",
    "small": "{{driverAssetsPath}}/images/small.png"
  },
  "icon": "{{driverAssetsPath}}/icon.svg",
  "capabilities": [],
  "class": "other"
}
```

{% endcode %}

{% code title="/drivers/my\_driver/driver.compose.json" %}

```javascript
{
  "name": {
    "en": "My Driver",
    "nl": "Mijn Driver"
  },
  "$extends": ["defaults"]
}
```

{% endcode %}

By using this template, you only have to place the values that are uniqiue to a driver in the `driver.compose.json` file. All other required properties are copied over from the template.


---

# 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://apps.developer.homey.app/advanced/homey-compose.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.
