> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/2-8-0/unified-namespace/set-up-a-unified-namespace.md). Agents can also search and read this documentation through its [MCP server](https://docs.cybus.io/~gitbook/mcp).

# Set Up a Unified Namespace

Install a namespace, a model, and an asset from one service commissioning file, then connect machine data to the asset.

By the end of this page, the pump `pump01` publishes its temperature on `factory/pump01/temperature`. Its `$meta` topic tells any MQTT client what the pump is.

## Prerequisites

To set up the namespace, you will need the following:

* A Connectware user who can install services.
* An MQTT client that connects to Connectware with read access to the new topics, such as MQTT Explorer. See [Connecting an MQTT Client to Publish and Subscribe Data](https://docs.cybus.io/2-8-0/guides/machine-connectivity/gateways-generic-protocols/connecting-an-mqtt-client-to-publish-and-subscribe-data.md).
* A device that the S7 connector can read, such as a Siemens S7 PLC.

## Install the Namespace and Connect the Pump

{% stepper %}
{% step %}

### Write the Service Commissioning File

Create a service commissioning file with the following resources:

* A namespace with the root `factory` and no tree.
* A model `Pump` with one data property, `temperature`.
* An asset `pump01` that follows the model.
* A mount that places the asset at the root of the namespace.

The resource ID `pump01` is the asset ID. The mount uses it as the topic segment of the asset.

{% code title="unsexample.yml" lineNumbers="true" %}

```yaml
description: Smallest Unified Namespace example

metadata:
  name: unsexample
  version: 1.0.0

resources:
  plantNamespace:
    type: Cybus::Namespace
    properties:
      root: factory

  pumpModel:
    type: Cybus::Model
    properties:
      modelId: Pump
      version: 1
      data:
        temperature:
          type: number
          unit: Cel

  pump01:
    type: Cybus::Asset
    properties:
      model: !ref pumpModel

  pump01Mount:
    type: Cybus::Mount
    properties:
      asset: !ref pump01
      at: 'uns:factory'
```

{% endcode %}
{% endstep %}

{% step %}

### Install the Service

Install the service commissioning file. See [Installing Services](https://docs.cybus.io/2-8-0/data-flows/services/managing/installing.md).

Then enable the service. See [Enabling Services](https://docs.cybus.io/2-8-0/data-flows/services/managing/enabling.md). The namespace, the asset, and its `$meta` topic become active only while the service is enabled.

If a name breaks a rule, the installation fails. The error names the resource and the rule. For example, the default naming policy allows only lowercase letters, digits, `_`, and `-` in topic segments. So an asset with the resource ID `Pump01` fails the installation. See [Naming Rules](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-namespace.md#naming-rules).
{% endstep %}

{% step %}

### Connect the Pump

Add a connection and an endpoint to the `resources` section of the service commissioning file. Instead of a `topic`, the endpoint references the data property with `asset: pump01.temperature`. Connectware replaces the reference with `factory/pump01/temperature` when you install the service.

{% code lineNumbers="true" %}

```yaml
s7Connection:
  type: Cybus::Connection
  properties:
    protocol: S7
    targetState: connected
    connection:
      host: 192.168.1.100
      port: 102
      rack: 0
      slot: 1

pump01Temperature:
  type: Cybus::Endpoint
  properties:
    protocol: S7
    connection: !ref s7Connection
    asset: pump01.temperature
    subscribe:
      address: DB10,REAL0
```

{% endcode %}

Replace `host`, `rack`, `slot`, and the `address` with the values of your PLC. See [Siemens SIMATIC S7](https://docs.cybus.io/2-8-0/connectors/shop-floor-connectors/siemens-simatic-s7.md). Then update the service. See [Updating Services](https://docs.cybus.io/2-8-0/data-flows/services/managing/updating.md).
{% endstep %}
{% endstepper %}

## Verification

The mount places `pump01` at the root `factory`, so the asset has the base topic `factory/pump01`. To check the namespace, use one of the following:

* **MQTT**: Subscribe to `factory/#`. You receive the retained `factory/pump01/$meta` message right away, followed by the temperature values on `factory/pump01/temperature`. The `$meta` message lists the model, the attributes, and the topic of each data property. See [The $meta Topic](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-asset.md#the-usdmeta-topic).
* **API**: Request `GET /api/v2/uns/namespaces/factory/tree`. The response lists the nodes of the namespace and the assets with their base topics. See [Topic Explorer API](https://docs.cybus.io/2-8-0/reference/api-reference/topic-explorer-api.md).

## Next Steps

* Add a tree of nodes, such as halls and lines, and policies to the namespace. See [Cybus::Namespace](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-namespace.md).
* Bring a device with a fixed topic into the namespace with a [mapping](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-mapping.md) that publishes to `asset: pump01.temperature`.
* Split the resources across services, so that one team owns the namespace and the models. Each machine service then declares its own asset. See [Example Factory](https://docs.cybus.io/2-8-0/unified-namespace/example-factory.md).
* Bring an existing UNS design into Connectware. See [Map Your Unified Namespace to Connectware](https://docs.cybus.io/2-8-0/unified-namespace/map-your-unified-namespace-to-connectware.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cybus.io/2-8-0/unified-namespace/set-up-a-unified-namespace.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
