Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci_cd/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# CI/CD workflow files

This directory follows the same structure as the main [OpenRemote repo](https://github.com/openremote/openremote/tree/master/.ci_cd).
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://editorconfig.org/
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
20 changes: 10 additions & 10 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
# Push excluding tags and workflow changes
push:
branches:
- 'main'
- "main"
tags-ignore:
- '*.*'
- "*.*"
paths-ignore:
- '.github/**'
- '.ci_cd/**'
- '**/*.md'
- ".github/**"
- ".ci_cd/**"
- "**/*.md"

# PR
pull_request:
Expand All @@ -24,16 +24,16 @@ on:
workflow_dispatch:
inputs:
ENVIRONMENT:
description: 'Environment to use (if any)'
description: "Environment to use (if any)"
CLEAN_INSTALL:
description: 'Delete data before starting'
description: "Delete data before starting"
type: boolean
COMMIT:
description: 'Repo branch or commit SHA to checkout'
description: "Repo branch or commit SHA to checkout"
OR_HOSTNAME:
description: 'Host to deploy to (e.g. demo.openremote.app)'
description: "Host to deploy to (e.g. demo.openremote.app)"
OR_ADMIN_PASSWORD:
description: 'Admin password override'
description: "Admin password override"

# Un-comment to monitor manager docker image tags for changes and trigger a redeploy when they change (see .ci_cd/README.md)
# schedule:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ console/iOS/Pods
manager/.factorypath/
Pods/
node_modules/
.eslintcache
.pnp.*
.yarn/*
!.yarn/patches
Expand Down
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ This repository is a template for custom projects; showing the recommended proje

**[You can find the documentation here](https://docs.openremote.io/docs/user-guide/deploying/custom-deployment/)**.


---

# (PROJECT_NAME)

*(Please describe, in a short summary, the context of the project.)*
_(Please describe, in a short summary, the context of the project.)_
<!-- For example:
OpenRemote produces sensors for monitoring the power production of solar panels.
They use ESP32 hardware that auto provisions in the OpenRemote platform through the cloud.
This hardware gets delivered to end consumers in their homes, where they can use a dedicated app for monitoring their solar panels.
-->

> This repository is set up using the [Custom Project template](https://github.com/openremote/custom-project/). This repository uses the same standards and folder structure. More information about how to use this repository as a template to develop your own agents, services, model classes, setup tasks, tests, and new UI apps can be found in the [OpenRemote documentation](https://docs.openremote.io/docs/developer-guide/creating-a-custom-project).

<!-- If different from "normal custom projects", you can replace or add information here. For example, note additional folders, or source code outside this repository. -->

## Project context

### Features
*(Please insert a bullet point list with features specific to this custom project.)*

_(Please insert a bullet point list with features specific to this custom project.)_
<!-- For example:
- Custom app for end users to access their solar panel data.
- Custom agent for communicating with the ESP32 devices.
Expand All @@ -32,13 +33,15 @@ This hardware gets delivered to end consumers in their homes, where they can use
-->

### Vocabulary / common terms
*(Please insert a bullet point list with common terms in this project, with a short explanation.)*

_(Please insert a bullet point list with common terms in this project, with a short explanation.)_
<!-- For example:
- **Manager UI**: The end-user UI deployed on `https://<url>/manager/` for monitoring devices.
-->

### Company background
*(If applicable, write context about the company this custom project is meant for.)*

_(If applicable, write context about the company this custom project is meant for.)_
<!-- For example:
- What kind of company they are (installer, manufacturer)
- What kind of team we're working with
Expand All @@ -48,14 +51,17 @@ This hardware gets delivered to end consumers in their homes, where they can use
- If they have their own outside repository, etc. -->

## Architecture
*(Please insert, preferably a diagram, or a short explanation of the high level architecture)*

_(Please insert, preferably a diagram, or a short explanation of the high level architecture)_
<!-- For example, what systems are there, and how do they interact with each other. -->

### Keycloak setup

The identity provider in place is [Keycloak](https://github.com/openremote/keycloak), running in its own container. The default configuration from the repository ([link](https://github.com/openremote/keycloak)) is used.
<!-- If the identity provider setup is different, or a custom configuration is used, please specify. -->

### Proxy setup

All requests from and towards running services go through the [HAProxy](https://github.com/openremote/proxy) container. The default configuration from the repository ([haproxy.cfg](https://github.com/openremote/proxy/blob/main/haproxy.cfg)) is used.
<!-- If the proxy setup is different, or a custom configuration is used, please specify. -->

Expand All @@ -64,21 +70,24 @@ All requests from and towards running services go through the [HAProxy](https://
## Developer Guide

### Quickstart

Before starting, make sure you have cloned the Git repository locally, as this is required.
Follow the initial guides on the OpenRemote documentation on [preparing the environment](https://docs.openremote.io/docs/developer-guide/preparing-the-environment), [installing and using Docker](https://docs.openremote.io/docs/developer-guide/installing-and-using-docker), and on [setting up an IDE](https://docs.openremote.io/docs/developer-guide/setting-up-an-ide).

*(Please describe the steps necessary to run this custom project locally.)*
_(Please describe the steps necessary to run this custom project locally.)_

### Docker Compose files

In the `profile` directory you can find different Docker Compose files, each serving a different purpose. To be able to use them, you'll need to download a copy of the `deploy.yml` file from the main OpenRemote repository and place it in the `openremote/profile` directory, to ensure you always have the latest version of the file:

```bash
mkdir -p openremote/profile && curl -L https://github.com/openremote/openremote/raw/refs/heads/master/profile/deploy.yml -o openremote/profile/deploy.yml
```

### Environment variables

| Key | Containers | Description | Default |
|----------------------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------|----------|
| -------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `OR_HOSTNAME` | All services | **(REQUIRED)** FQDN hostname of where this instance will be exposed (localhost, IP address or public domain) | - |
| `OR_ADMIN_PASSWORD` | `keycloak`, `manager` | **(REQUIRED)** Initial admin user password | - |
| `DEPLOYMENT_VERSION` | `deployment` | **(REQUIRED)** The custom project version in use. This tag is used for building and deploying the artifacts from this repository. | - |
Expand All @@ -95,19 +104,31 @@ This custom project is deployed by OpenRemote on their managed infrastructure. I
<!-- If applicable, specify otherwise -->

The list of available environments:

### `staging`

Used by OpenRemote to test new functionality and bugfixes before publishing them to production. Important practices and agreements to be aware of:

- This environment is only used for development purposes, so can be offline at any time.
- There is no guarantee that this data will be persisted in the long-term.

<!-- If applicable, you can provide additional practices such as "Devices in the field are connected to this" or "Be aware that an external company has API access" -->

- **OpenRemote Manager:** https://(staging.CUSTOM_HOSTNAME).com/manager
- **Custom app:** https://(staging.CUSTOM_HOSTNAME).com/custom

<!-- If applicable, add additional URLs to other services or apps -->

### `production`

Used for the live system with devices in the field, with a guarantee of stability and data persistence. Important practices and agreements to be aware of:

- There is a daily backup active for this instance.
- This deployment is **manually updated**, and should be communicated with stakeholders.

<!-- If applicable, you can provide additional practices, such as "Auto deploys when making a new release through GitHub", or "It updates every 1st day of the month" -->

- **OpenRemote Manager:** https://(CUSTOM_HOSTNAME).com/manager
- **Custom app:** https://(CUSTOM_HOSTNAME).com/custom
<!-- If applicable, add additional URLs to other services or apps -->

<!-- If applicable, add additional URLs to other services or apps -->
8 changes: 4 additions & 4 deletions agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'java-library'
id 'java-library'
}

dependencies {
api project(":model")
api libs.openremote.agent
api project(":model")
api libs.openremote.agent
}

tasks.register('installDist') {
dependsOn jar
dependsOn jar
}
83 changes: 41 additions & 42 deletions agent/src/main/java/org/openremote/agent/custom/CustomAgent.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Copyright 2017, OpenRemote Inc.
*
* See the CONTRIBUTORS.txt file in the distribution for a
* full listing of individual contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
Expand All @@ -15,69 +12,71 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package org.openremote.agent.custom;

import jakarta.persistence.Entity;
import java.util.Optional;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.agent.Agent;
import org.openremote.model.asset.agent.AgentDescriptor;
import org.openremote.model.asset.agent.DefaultAgentLink;
import org.openremote.model.value.AttributeDescriptor;
import org.openremote.model.value.ValueDescriptor;

import jakarta.persistence.Entity;
import java.util.Optional;

/**
* This is an example of a custom {@link Agent} type; this must be registered via an
* {@link org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom {@link Asset}s and
* in addition the following requirements:
* This is an example of a custom {@link Agent} type; this must be registered via an {@link
* org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom
* {@link Asset}s and in addition the following requirements:
*
* <ul>
* <li>Optionally add a custom {@link org.openremote.model.asset.agent.AgentLink} (the {@link Class#getSimpleName} must
* be unique compared to all other registered {@link org.openremote.model.asset.agent.AgentLink}s)
* <li>Must define a {@link org.openremote.model.asset.agent.Protocol} implementation that corresponds to this {@link Agent}
* <li>Must have a public static final {@link org.openremote.model.asset.agent.AgentDescriptor} rather than an
* {@link org.openremote.model.asset.AssetDescriptor}
* <li>Optionally add a custom {@link org.openremote.model.asset.agent.AgentLink} (the {@link
* Class#getSimpleName} must be unique compared to all other registered {@link
* org.openremote.model.asset.agent.AgentLink}s)
* <li>Must define a {@link org.openremote.model.asset.agent.Protocol} implementation that
* corresponds to this {@link Agent}
* <li>Must have a public static final {@link org.openremote.model.asset.agent.AgentDescriptor}
* rather than an {@link org.openremote.model.asset.AssetDescriptor}
* </ul>
*/
@Entity
public class CustomAgent extends Agent<CustomAgent, CustomProtocol, DefaultAgentLink> {

public enum Option {
ONE,
TWO,
THREE
};
public enum Option {
ONE,
TWO,
THREE
};

public static final ValueDescriptor<Option> OPTION_VALUE_DESCRIPTOR = new ValueDescriptor<>("customAgentOption", Option.class);
public static final ValueDescriptor<Option> OPTION_VALUE_DESCRIPTOR =
new ValueDescriptor<>("customAgentOption", Option.class);

public static final AttributeDescriptor<Option> OPTION_ATTRIBUTE_DESCRIPTOR = new AttributeDescriptor<>("option", OPTION_VALUE_DESCRIPTOR);
public static final AttributeDescriptor<Option> OPTION_ATTRIBUTE_DESCRIPTOR =
new AttributeDescriptor<>("option", OPTION_VALUE_DESCRIPTOR);

public static final AgentDescriptor<CustomAgent, CustomProtocol, DefaultAgentLink> DESCRIPTOR = new AgentDescriptor<>(
CustomAgent.class, CustomProtocol.class, DefaultAgentLink.class
);
public static final AgentDescriptor<CustomAgent, CustomProtocol, DefaultAgentLink> DESCRIPTOR =
new AgentDescriptor<>(CustomAgent.class, CustomProtocol.class, DefaultAgentLink.class);

protected CustomAgent() {
}
protected CustomAgent() {}

public CustomAgent(String name) {
super(name);
}
public CustomAgent(String name) {
super(name);
}

@Override
public CustomProtocol getProtocolInstance() {
return new CustomProtocol(this);
}
@Override
public CustomProtocol getProtocolInstance() {
return new CustomProtocol(this);
}

public Optional<Option> getOption() {
return getAttributes().getValue(OPTION_ATTRIBUTE_DESCRIPTOR);
}
public Optional<Option> getOption() {
return getAttributes().getValue(OPTION_ATTRIBUTE_DESCRIPTOR);
}

public CustomAgent setOption(Option value) {
getAttributes().getOrCreate(OPTION_ATTRIBUTE_DESCRIPTOR).setValue(value);
return this;
}
public CustomAgent setOption(Option value) {
getAttributes().getOrCreate(OPTION_ATTRIBUTE_DESCRIPTOR).setValue(value);
return this;
}
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Copyright 2021, OpenRemote Inc.
*
* See the CONTRIBUTORS.txt file in the distribution for a
* full listing of individual contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
Expand All @@ -15,17 +12,18 @@
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

package org.openremote.agent.custom;

import org.openremote.model.AssetModelProvider;

public class CustomAgentModelProvider implements AssetModelProvider {

@Override
public boolean useAutoScan() {
return true;
}
@Override
public boolean useAutoScan() {
return true;
}
}
Loading
Loading