Skip to content

Commit 75bf4e2

Browse files
committed
Add EMS extension
1 parent 1a91e1b commit 75bf4e2

25 files changed

Lines changed: 6496 additions & 1 deletion

‎ems/build.gradle‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apply plugin: "groovy"
2+
apply plugin: "java-library"
3+
apply plugin: "maven-publish"
4+
apply plugin: "signing"
5+
6+
base {
7+
archivesName = "openremote-${project.name}-extension"
8+
}
9+
10+
dependencies {
11+
api "io.openremote:openremote-manager:$openremoteVersion"
12+
api "io.openremote:openremote-model:$openremoteVersion"
13+
14+
api "org.jboss.resteasy:resteasy-client-api:$resteasyVersion"
15+
implementation "org.lfenergy.shapeshifter:shapeshifter-core:$shapeshifterVersion"
16+
testImplementation "io.openremote:openremote-test:$openremoteVersion"
17+
}
18+
19+
jar {
20+
from sourceSets.main.allJava
21+
}
22+
23+
javadoc {
24+
failOnError = false
25+
}
26+
27+
java {
28+
withJavadocJar()
29+
withSourcesJar()
30+
}
31+
32+
publishing {
33+
publications {
34+
maven(MavenPublication) {
35+
group = "io.openremote.extension"
36+
artifactId = "openremote-${project.name}-extension"
37+
from components.java
38+
pom {
39+
name = 'OpenRemote EMS extension'
40+
description = 'Adds the EMS extension'
41+
url = 'https://github.com/openremote/extensions'
42+
licenses {
43+
license {
44+
name = 'GNU Affero General Public License v3.0'
45+
url = 'https://www.gnu.org/licenses/agpl-3.0.en.html'
46+
}
47+
}
48+
developers {
49+
developer {
50+
id = 'developers'
51+
name = 'Developers'
52+
email = 'developers@openremote.io'
53+
organization = 'OpenRemote'
54+
organizationUrl = 'https://openremote.io'
55+
}
56+
}
57+
scm {
58+
connection = 'scm:git:git://github.com/openremote/extensions.git'
59+
developerConnection = 'scm:git:ssh://github.com:openremote/extensions.git'
60+
url = 'https://github.com/openremote/extensions/tree/main'
61+
}
62+
}
63+
}
64+
}
65+
66+
repositories {
67+
maven {
68+
if (!version.endsWith('-LOCAL')) {
69+
credentials {
70+
username findProperty("publishUsername")
71+
password findProperty("publishPassword")
72+
}
73+
}
74+
url = version.endsWith('-LOCAL') ? layout.buildDirectory.dir('repo') : version.endsWith('-SNAPSHOT') ? findProperty("snapshotsRepoUrl") : findProperty("releasesRepoUrl")
75+
}
76+
}
77+
}
78+
79+
signing {
80+
def signingKey = findProperty("signingKey")
81+
def signingPassword = findProperty("signingPassword")
82+
if (signingKey && signingPassword) {
83+
useInMemoryPgpKeys(signingKey, signingPassword)
84+
sign publishing.publications.maven
85+
}
86+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2025, OpenRemote Inc.
3+
*
4+
* See the CONTRIBUTORS.txt file in the distribution for a
5+
* full listing of individual contributors.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.openremote.extension.ems.agent;
21+
22+
import org.openremote.model.AssetModelProvider;
23+
24+
public class EmsAgentModelProvider implements AssetModelProvider {
25+
26+
@Override
27+
public boolean useAutoScan() {
28+
return true;
29+
}
30+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright 2025, OpenRemote Inc.
3+
*
4+
* See the CONTRIBUTORS.txt file in the distribution for a
5+
* full listing of individual contributors.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.openremote.extension.ems.agent;
21+
22+
import jakarta.persistence.Entity;
23+
import org.openremote.model.asset.Asset;
24+
import org.openremote.model.asset.AssetDescriptor;
25+
import org.openremote.model.attribute.MetaItem;
26+
import org.openremote.model.value.AbstractNameValueHolder;
27+
import org.openremote.model.value.AttributeDescriptor;
28+
import org.openremote.model.value.MetaItemType;
29+
import org.openremote.model.value.ValueType;
30+
31+
import java.util.Optional;
32+
33+
import static org.openremote.model.Constants.*;
34+
35+
@Entity
36+
public class EmsDayAheadAsset extends Asset<EmsDayAheadAsset> {
37+
38+
public static final AttributeDescriptor<String> COLLECT_TIME_FORECASTS = new AttributeDescriptor<>("collectTimeForecasts", ValueType.TEXT);
39+
40+
public static final AttributeDescriptor<String> LAST_UPDATE_FORECASTS = new AttributeDescriptor<>("lastUpdateForecasts", ValueType.TEXT,
41+
new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7),
42+
new MetaItem<>(MetaItemType.READ_ONLY),
43+
new MetaItem<>(MetaItemType.STORE_DATA_POINTS)
44+
);
45+
46+
public static final AttributeDescriptor<Double> TARIFF_EXPORT_DAY_AHEAD = new AttributeDescriptor<>("tariffExportDayAheadForecast", ValueType.NUMBER,
47+
new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7),
48+
new MetaItem<>(MetaItemType.READ_ONLY),
49+
new MetaItem<>(MetaItemType.STORE_DATA_POINTS)
50+
).withUnits("EUR", UNITS_PER, UNITS_KILO, UNITS_WATT, UNITS_HOUR);
51+
52+
public static final AttributeDescriptor<Double> TARIFF_IMPORT_DAY_AHEAD = new AttributeDescriptor<>("tariffImportDayAheadForecast", ValueType.NUMBER,
53+
new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7),
54+
new MetaItem<>(MetaItemType.READ_ONLY),
55+
new MetaItem<>(MetaItemType.STORE_DATA_POINTS)
56+
).withUnits("EUR", UNITS_PER, UNITS_KILO, UNITS_WATT, UNITS_HOUR);
57+
58+
public static final AttributeDescriptor<Boolean> USE_TARIFF_DAY_AHEAD_FORECASTS = new AttributeDescriptor<>("useTariffDayAheadForecasts", ValueType.BOOLEAN);
59+
60+
61+
public static final AssetDescriptor<EmsDayAheadAsset> DESCRIPTOR = new AssetDescriptor<>("calendar-clock", "000000", EmsDayAheadAsset.class);
62+
63+
protected EmsDayAheadAsset() {
64+
}
65+
66+
public EmsDayAheadAsset(String name) {
67+
super(name);
68+
}
69+
70+
71+
public Optional<String> getCollectTimeForecasts() {
72+
return getAttribute(COLLECT_TIME_FORECASTS).flatMap(AbstractNameValueHolder::getValue);
73+
}
74+
75+
public Optional<String> getLastUpdateForecasts() {
76+
return getAttribute(LAST_UPDATE_FORECASTS).flatMap(AbstractNameValueHolder::getValue);
77+
}
78+
79+
public Optional<Boolean> getUseTariffDayAheadForecasts() {
80+
return getAttribute(USE_TARIFF_DAY_AHEAD_FORECASTS).flatMap(AbstractNameValueHolder::getValue);
81+
}
82+
83+
84+
public EmsDayAheadAsset setCollectTimeForecasts(String value) {
85+
getAttributes().getOrCreate(COLLECT_TIME_FORECASTS).setValue(value);
86+
return this;
87+
}
88+
89+
public EmsDayAheadAsset setUseTariffDayAheadForecasts(Boolean value) {
90+
getAttributes().getOrCreate(USE_TARIFF_DAY_AHEAD_FORECASTS).setValue(value);
91+
return this;
92+
}
93+
94+
}

0 commit comments

Comments
 (0)