Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Simulator agent scheduling config and inserting predicted datapoints (#2118)

Koena05c46dc6093
diff --git a/agent/build.gradle b/agent/build.gradle
index adb60ecf0..1ccfe8183 100644
--- a/agent/build.gradle
+++ b/agent/build.gradle
@@ -44,6 +44,10 @@ dependencies {
implementation "org.eclipse.angus:angus-mail:$jakartaMailVersion"
implementation "org.jdom:jdom2:$jdomVersion"
+
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}
base {
diff --git a/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedDatapointService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedDatapointService.java
index cd62a785b..2d5b1d275 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedDatapointService.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolPredictedDatapointService.java
@@ -21,12 +21,18 @@ package org.openremote.agent.protocol;
import org.openremote.model.ContainerService;
import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.datapoint.ValueDatapoint;
import java.time.LocalDateTime;
+import java.util.List;
public interface ProtocolPredictedDatapointService extends ContainerService {
void updateValue(AttributeRef attributeRef, Object value, LocalDateTime timestamp);
void updateValue(String assetId, String attributeName, Object value, LocalDateTime timestamp);
+
+ void updateValues(String assetId, String attributeName, List<ValueDatapoint<?>> valuesAndTimestamps);
+
+ void purgeValues(String assetId, String attributeName);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorAgentLink.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorAgentLink.java
index 06037da3e..8c8d37926 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorAgentLink.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorAgentLink.java
@@ -19,18 +19,36 @@
*/
package org.openremote.agent.protocol.simulator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
+import net.fortuna.ical4j.model.Recur;
import org.openremote.model.asset.agent.AgentLink;
+import org.openremote.model.calendar.CalendarEvent;
import org.openremote.model.simulator.SimulatorReplayDatapoint;
+import java.time.*;
+import java.time.chrono.ChronoLocalDateTime;
+import java.util.Date;
+import java.util.List;
import java.util.Optional;
public class SimulatorAgentLink extends AgentLink<SimulatorAgentLink> {
- @JsonPropertyDescription("Used to store 24h dataset of values that should be replayed (i.e. written to the" +
- " linked attribute) in a continuous loop.")
+ @JsonPropertyDescription("Used to store a dataset of values that should be replayed (i.e. written to the" +
+ " linked attribute) in a continuous loop based on a schedule (by default replays every 24h)." +
+ " Predicted datapoints can be added by configuring 'Store predicted datapoints' which will insert the datapoints" +
+ " immediately as determined by the schedule.")
protected SimulatorReplayDatapoint[] replayData;
+ // TODO: consider implementing @JsonSchemaFormat("calendar-event") to reuse the `or-rule-validity` component.
+ // Current generator cannot handle injecting custom type and description at the same time
+ @JsonPropertyDescription("When defined overwrites the possible dataset length and when it is replayed." +
+ " This could be once when only a start- (and end) date are defined," +
+ " or a recurring event following the RFC 5545 RRULE format." +
+ " If not provided defaults to 24 hours. If the replay data contains datapoints scheduled after the" +
+ " default 24 hours or the recurrence rule the datapoints will be ignored.")
+ protected SimulatorProtocol.Schedule schedule;
+
// For Hydrators
protected SimulatorAgentLink() {
}
@@ -47,4 +65,13 @@ public class SimulatorAgentLink extends AgentLink<SimulatorAgentLink> {
this.replayData = replayData;
return this;
}
+
+ public Optional<SimulatorProtocol.Schedule> getSchedule() {
+ return Optional.ofNullable(schedule);
+ }
+
+ public SimulatorAgentLink setSchedule(SimulatorProtocol.Schedule schedule) {
+ this.schedule = schedule;
+ return this;
+ }
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
index 1b8376be8..d0b4e0ec5 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
@@ -19,17 +19,31 @@
*/
package org.openremote.agent.protocol.simulator;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyDescription;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.util.StdConverter;
+import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaFormat;
+import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject;
+import net.fortuna.ical4j.model.Recur;
import org.openremote.agent.protocol.AbstractProtocol;
import org.openremote.model.Container;
import org.openremote.model.asset.agent.ConnectionStatus;
import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.AttributeEvent;
import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.simulator.SimulatorReplayDatapoint;
import org.openremote.model.syslog.SyslogCategory;
+import org.openremote.model.util.JSONSchemaUtil;
+import org.openremote.model.value.AbstractNameValueHolder;
+import java.io.Serializable;
import java.time.LocalDateTime;
-import java.time.temporal.ChronoField;
+import java.time.ZoneOffset;
+import java.time.chrono.ChronoLocalDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
@@ -38,6 +52,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;
+import static org.openremote.model.value.MetaItemType.HAS_PREDICTED_DATA_POINTS;
public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, SimulatorAgentLink> {
@@ -45,6 +60,7 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
public static final String PROTOCOL_DISPLAY_NAME = "Simulator";
protected final Map<AttributeRef, ScheduledFuture<?>> replayMap = new ConcurrentHashMap<>();
+ protected final Map<AttributeRef, PredictedDatapointWindow> predictedDatapointWindowMap = new ConcurrentHashMap<>();
public SimulatorProtocol(SimulatorAgent agent) {
super(agent);
@@ -84,7 +100,13 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
.ifPresent(simulatorReplayDatapoints -> {
LOG.info("Simulator replay data found for linked attribute: " + attribute);
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
- ScheduledFuture<?> updateValueFuture = scheduleReplay(attributeRef, simulatorReplayDatapoints);
+ predictedDatapointWindowMap.put(attributeRef, PredictedDatapointWindow.BOTH);
+
+ // Sorting so we can assume positioning
+ SimulatorReplayDatapoint[] sorted = Arrays.stream(simulatorReplayDatapoints)
+ .sorted(Comparator.comparingLong(SimulatorReplayDatapoint::getTimestamp))
+ .toArray(SimulatorReplayDatapoint[]::new);
+ ScheduledFuture<?> updateValueFuture = scheduleReplay(attributeRef, sorted);
if (updateValueFuture != null) {
replayMap.put(attributeRef, updateValueFuture);
} else {
@@ -102,6 +124,9 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
if (updateValueFuture != null) {
updateValueFuture.cancel(true);
}
+
+ // Purge previously configured predicted datapoints
+ predictedDatapointService.purgeValues(attributeRef.getId(), attribute.getName());
}
@Override
@@ -134,17 +159,38 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
updateLinkedAttribute(attributeRef, value, timestamp);
}
+ public void updateLinkedAttributePredictedDataPoints(AttributeRef attributeRef, List<ValueDatapoint<?>> values) {
+ Attribute<?> attribute = linkedAttributes.get(attributeRef);
+
+ if (attribute == null) {
+ LOG.log(Level.WARNING, () -> "Update linked attribute predicted data points called for un-linked attribute: " + attributeRef);
+ return;
+ }
+
+ predictedDatapointService.updateValues(attributeRef.getId(), attribute.getName(), values);
+ }
+
public Map<AttributeRef, ScheduledFuture<?>> getReplayMap() {
return replayMap;
}
protected ScheduledFuture<?> scheduleReplay(AttributeRef attributeRef, SimulatorReplayDatapoint[] simulatorReplayDatapoints) {
+ Attribute<?> attribute = linkedAttributes.get(attributeRef);
+ SimulatorAgentLink agentLink = this.agent.getAgentLink(attribute);
+
LOG.finest("Scheduling linked attribute replay update");
- long now = LocalDateTime.now().get(ChronoField.SECOND_OF_DAY);
+ Optional<SimulatorProtocol.Schedule> schedule = agentLink.getSchedule();
+
+ long defaultReplayLoopDuration = 86400; // 1 day in seconds
+ long now = timerService.getNow().getEpochSecond(); // UTC
+
+ long timeSinceOccurrenceStarted = schedule.map(s -> s.advanceToNextOccurrence(now))
+ .orElse(now % defaultReplayLoopDuration); // Remainder since 00:00
+ // Find datapoint with timestamp after the current occurrence
SimulatorReplayDatapoint nextDatapoint = Arrays.stream(simulatorReplayDatapoints)
- .filter(replaySimulatorDatapoint -> replaySimulatorDatapoint.timestamp > now)
+ .filter(replaySimulatorDatapoint -> replaySimulatorDatapoint.timestamp > timeSinceOccurrenceStarted)
.findFirst()
.orElse(simulatorReplayDatapoints[0]);
@@ -152,22 +198,260 @@ public class SimulatorProtocol extends AbstractProtocol<SimulatorAgent, Simulato
LOG.warning("Next datapoint not found so replay cancelled: " + attributeRef);
return null;
}
- long nextRun = nextDatapoint.timestamp;
- if (nextRun <= now) { //now is after so nextRun is next day
- nextRun += 86400; //day in seconds
+
+ OptionalLong nextRun = getDelay(nextDatapoint.timestamp, timeSinceOccurrenceStarted, schedule.orElse(null));
+ if (nextRun.isEmpty()) {
+ LOG.warning("Replay schedule has ended for: " + attributeRef);
+ return null;
}
- long nextRunRelative = nextRun - now;
- LOG.fine("Next update for asset " + attributeRef.getId() + " for attribute " + attributeRef.getName() + " in " + nextRunRelative + " second(s)");
+ if (attribute.getMeta().get(HAS_PREDICTED_DATA_POINTS).flatMap(AbstractNameValueHolder::getValue).orElse(false)) {
+ PredictedDatapointWindow status = predictedDatapointWindowMap.get(attributeRef);
+ List<ValueDatapoint<?>> predictedDatapoints =
+ calculatePredictedDatapoints(simulatorReplayDatapoints, schedule, status, timeSinceOccurrenceStarted, now);
+ try {
+ updateLinkedAttributePredictedDataPoints(attributeRef, predictedDatapoints);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Exception thrown when updating value: %s", e);
+ }
+ if (status.equals(PredictedDatapointWindow.BOTH) || status.equals(PredictedDatapointWindow.NEXT)) {
+ predictedDatapointWindowMap.put(attributeRef, PredictedDatapointWindow.NONE);
+ } else if (simulatorReplayDatapoints[simulatorReplayDatapoints.length - 1] == nextDatapoint) {
+ predictedDatapointWindowMap.put(attributeRef, PredictedDatapointWindow.NEXT);
+ }
+ }
+
+ LOG.fine("Next update for asset " + attributeRef.getId() + " for attribute " + attributeRef.getName() + " in " + nextRun + " second(s)");
return scheduledExecutorService.schedule(() -> {
LOG.fine("Updating asset " + attributeRef.getId() + " for attribute " + attributeRef.getName() + " with value " + nextDatapoint.value.toString());
try {
updateLinkedAttribute(attributeRef, nextDatapoint.value);
} catch (Exception e) {
LOG.log(Level.SEVERE, "Exception thrown when updating value: %s", e);
- } finally {
- replayMap.put(attributeRef, scheduleReplay(attributeRef, simulatorReplayDatapoints));
}
- }, nextRunRelative, TimeUnit.SECONDS);
+
+ ScheduledFuture<?> future = scheduleReplay(attributeRef, simulatorReplayDatapoints);
+ if (future != null) {
+ replayMap.put(attributeRef, future);
+ } else {
+ replayMap.remove(attributeRef);
+ }
+ }, nextRun.getAsLong(), TimeUnit.SECONDS);
+ }
+
+ public List<ValueDatapoint<?>> calculatePredictedDatapoints(
+ SimulatorReplayDatapoint[] simulatorReplayDatapoints,
+ Optional<Schedule> schedule,
+ PredictedDatapointWindow status,
+ long timeSinceOccurrenceStarted,
+ long now
+ ) {
+ List<ValueDatapoint<?>> predictedDatapoints = new ArrayList<>();
+ if (status.equals(PredictedDatapointWindow.NONE)) return predictedDatapoints;
+
+ long occurrenceDuration = 0;
+ boolean isSingleOccurrence = schedule.map(Schedule::getIsSingleOccurrence).orElse(false);
+ if (!isSingleOccurrence) occurrenceDuration = getOccurrenceDuration(schedule.orElse(null));
+
+ for (SimulatorReplayDatapoint d : simulatorReplayDatapoints) {
+ OptionalLong delay = getDelay(d.timestamp, timeSinceOccurrenceStarted, schedule.orElse(null));
+ if (delay.isEmpty()) return predictedDatapoints;
+ long timestamp = delay.getAsLong() + now;
+
+ if (status.equals(PredictedDatapointWindow.BOTH)) {
+ predictedDatapoints.add(new SimulatorReplayDatapoint(timestamp*1000, d.value).toValueDatapoint());
+ }
+ if (!isSingleOccurrence
+ && (status.equals(PredictedDatapointWindow.BOTH)
+ || status.equals(PredictedDatapointWindow.NEXT))
+ ) {
+ predictedDatapoints.add(new SimulatorReplayDatapoint((timestamp+occurrenceDuration)*1000, d.value).toValueDatapoint());
+ }
+ }
+ return predictedDatapoints;
+ }
+
+ public static class Schedule implements Serializable {
+
+ @JsonPropertyDescription("Set a start date, if not provided, starts immediately." +
+ " When the replay datapoint timestamp is 0 it will insert it at 00:00.")
+ @JsonSchemaFormat("date-time")
+ @JsonSchemaInject(jsonSupplierViaLookup = JSONSchemaUtil.SCHEMA_SUPPLIER_NAME_STRING_TYPE)
+ protected Date start;
+
+ @JsonPropertyDescription("Not implemented, within the recurrence rule you can specify an end date.")
+ @JsonSchemaFormat("date-time")
+ @JsonSchemaInject(jsonSupplierViaLookup = JSONSchemaUtil.SCHEMA_SUPPLIER_NAME_STRING_TYPE)
+ protected Date end;
+
+ @JsonPropertyDescription("The recurrence schedule follows the RFC 5545 RRULE format.")
+ @JsonSchemaInject(merge = false, jsonSupplierViaLookup = JSONSchemaUtil.SCHEMA_SUPPLIER_NAME_STRING_TYPE)
+ @JsonSerialize(converter = RecurStringConverter.class)
+ protected Recur<LocalDateTime> recurrence;
+
+ public static class RecurStringConverter extends StdConverter<Recur<?>, String> {
+
+ @Override
+ public String convert(Recur<?> value) {
+ return value.toString();
+ }
+ }
+
+ @JsonCreator
+ public Schedule(@JsonProperty("start") Date start, @JsonProperty("end") Date end, @JsonProperty("recurrence") String recurrence) {
+ Recur<LocalDateTime> recur = null;
+
+ try {
+ recur = new Recur<>(recurrence);
+ } catch (Exception ignored) {}
+
+ this.start = start;
+ this.end = end;
+ this.recurrence = recur;
+ this.startTime = start.getTime() / 1000;
+ }
+
+ public Date getStart() {
+ return start;
+ }
+
+ public Date getEnd() {
+ return end;
+ }
+
+ public Recur<LocalDateTime> getRecurrence() {
+ return recurrence;
+ }
+
+ @JsonIgnore
+ private final long startTime;
+ @JsonIgnore
+ private long count;
+ @JsonIgnore
+ private long currentOccurrence;
+
+ /**
+ * Advance to next occurrence relative to the current epoch time.
+ * <p>
+ * An occurrence can be a single event or part of a recurring event. If no recurrence rule has been configured,
+ * the start time is used, or if the occurrence hasn't started yet.
+ * <p>
+ * If a recurrence rule has been configured, the start of the current occurrence is used. If the recurrence rule
+ * specifies {@code UNTIL} or {@code COUNT} the previous occurrence start time is used.
+ *
+ * @param epoch Seconds since the epoch
+ * @return Seconds since the occurrence started
+ */
+ public long advanceToNextOccurrence(long epoch) {
+ Recur<LocalDateTime> recurrence = getRecurrence();
+
+ if (recurrence == null || epoch < startTime) {
+ currentOccurrence = startTime;
+ return epoch - startTime;
+ }
+
+ LocalDateTime start = LocalDateTime.ofEpochSecond(startTime, 0, ZoneOffset.UTC);
+ LocalDateTime prev = LocalDateTime.ofEpochSecond(currentOccurrence, 0, ZoneOffset.UTC);
+ LocalDateTime now = LocalDateTime.ofEpochSecond(epoch, 0, ZoneOffset.UTC);
+
+ List<LocalDateTime> dates = recurrence.getDates(start, prev, now);
+ if ((recurrence.getUntil() != null && now.isAfter(ChronoLocalDateTime.from(recurrence.getUntil()))) || count == recurrence.getCount()) {
+ return epoch - currentOccurrence;
+ }
+ if (dates.size() > 1 || count == 0) count++;
+
+ currentOccurrence = dates.getLast().toEpochSecond(ZoneOffset.UTC);
+ return epoch - currentOccurrence;
+ }
+
+ /**
+ * Gets the time until the next occurrence starts.
+ *
+ * @param timeSinceOccurrenceStarted Seconds since the current occurrence started
+ * @return Seconds until the next occurrence starts.
+ * <p>
+ * If this is a one-time event, or if the recurrence rule has ended returns {@code null} instead.
+ */
+ protected OptionalLong getTimeUntilNextOccurrence(long timeSinceOccurrenceStarted) {
+ Recur<LocalDateTime> recurrence = getRecurrence();
+
+ // Single event schedule has ended
+ if (recurrence == null) {
+ return OptionalLong.empty();
+ }
+
+ LocalDateTime start = LocalDateTime.ofEpochSecond(startTime, 0, ZoneOffset.UTC);
+ LocalDateTime current = LocalDateTime.ofEpochSecond(currentOccurrence, 0, ZoneOffset.UTC);
+ LocalDateTime next = recurrence.getNextDate(start, current);
+
+ // Recurring event schedule has ended
+ if (next == null) {
+ return OptionalLong.empty();
+ }
+
+ long duration = next.toEpochSecond(ZoneOffset.UTC) - currentOccurrence;
+ return OptionalLong.of(duration - timeSinceOccurrenceStarted);
+ }
+
+ public boolean getIsSingleOccurrence() {
+ return Optional.ofNullable(start).map(s -> recurrence == null).orElse(false);
+ }
+ }
+
+ /**
+ * Calculates the delay in seconds until the {@link SimulatorReplayDatapoint} should be played.
+ *
+ * @param point The {@link SimulatorReplayDatapoint#timestamp} to calculate the delay for.
+ * @param timeSinceOccurrenceStarted The time since the occurrence started in seconds.
+ * @return The delay in seconds until the {@link SimulatorReplayDatapoint} should be replayed.
+ * <p>
+ * If this is a one-time event, or if the recurrence rule has ended returns {@code null} instead.
+ */
+ public static OptionalLong getDelay(long point, long timeSinceOccurrenceStarted, Schedule schedule) {
+ if (point <= timeSinceOccurrenceStarted) {
+ return getTimeUntilNextOccurrence(timeSinceOccurrenceStarted, schedule)
+ .stream()
+ .map(n -> point + n)
+ .findFirst();
+ }
+ return OptionalLong.of(point - timeSinceOccurrenceStarted);
+ }
+
+ public static long getOccurrenceDuration(Schedule schedule) {
+ if (schedule == null) {
+ return 86400;
+ }
+
+ LocalDateTime start = LocalDateTime.ofEpochSecond(schedule.startTime, 0, ZoneOffset.UTC);
+ LocalDateTime current = LocalDateTime.ofEpochSecond(schedule.currentOccurrence, 0, ZoneOffset.UTC);
+ LocalDateTime next = schedule.getRecurrence().getNextDate(start, current);
+
+ return next.toEpochSecond(ZoneOffset.UTC) - schedule.currentOccurrence;
+ }
+
+ /**
+ * Calculates the time in seconds until the next occurrence starts.
+ * <p>
+ * If no schedule has been defined uses the default 1-day schedule.
+ *
+ * @param timeSinceOccurrenceStarted The time since the occurrence started in seconds.
+ * @return The delay in seconds until the {@link SimulatorReplayDatapoint} should be replayed.
+ * <p>
+ * If this is a one-time event, or if the recurrence rule has ended returns {@code null} instead.
+ */
+ public static OptionalLong getTimeUntilNextOccurrence(long timeSinceOccurrenceStarted, Schedule schedule) {
+ if (schedule != null) {
+ return schedule.getTimeUntilNextOccurrence(timeSinceOccurrenceStarted);
+ }
+ return OptionalLong.of(86400L - timeSinceOccurrenceStarted);
+ }
+
+ /**
+ * Determines for what occurrence window to create predicted datapoints
+ */
+ public enum PredictedDatapointWindow {
+ BOTH,
+ NONE,
+ NEXT
}
}
diff --git a/agent/src/test/java/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.java b/agent/src/test/java/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.java
new file mode 100644
index 000000000..a50591c39
--- /dev/null
+++ b/agent/src/test/java/org/openremote/agent/protocol/simulator/SimulatorAgentProtocolScheduleTest.java
@@ -0,0 +1,104 @@
+package org.openremote.agent.protocol.simulator;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.Instant;
+import java.util.Date;
+import java.util.OptionalLong;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class SimulatorAgentProtocolScheduleTest {
+
+ @Test
+ public void advanceToNextOccurrence() {
+ SimulatorProtocol.Schedule schedule = new SimulatorProtocol.Schedule(new Date(3600_000), new Date(3600_000*3), null);
+
+ assertEquals(-3600, schedule.advanceToNextOccurrence(0));
+ assertEquals(0, schedule.advanceToNextOccurrence(3600));
+ assertEquals(400, schedule.advanceToNextOccurrence(4000));
+
+ schedule = new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("2000-01-01T00:00:00.000Z")),
+ null,
+ "FREQ=DAILY;"
+ );
+
+ var now = Instant.parse("2000-01-01T00:00:00.000Z").getEpochSecond();
+
+ assertEquals(0, schedule.advanceToNextOccurrence(now));
+ assertEquals(3600, schedule.advanceToNextOccurrence(now + 3600));
+ assertEquals(0, schedule.advanceToNextOccurrence(now + 86400));
+ assertEquals(0, schedule.advanceToNextOccurrence(now + 86400*2));
+ assertEquals(0, schedule.advanceToNextOccurrence(now + 86400*3));
+ assertEquals(0, schedule.advanceToNextOccurrence(now + 86400*4));
+ assertEquals(1, schedule.advanceToNextOccurrence(now + 86400*4+1));
+ assertEquals(86400-1, schedule.advanceToNextOccurrence(now + 86400*5-1));
+
+ schedule = new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("2000-01-01T00:00:00.000Z")),
+ null,
+ "FREQ=DAILY;COUNT=2"
+ );
+ assertEquals(0, schedule.advanceToNextOccurrence(now));
+ assertEquals(3600, schedule.advanceToNextOccurrence(now + 3600));
+ assertEquals(0, schedule.advanceToNextOccurrence(now + 86400));
+ // Surpassed
+ assertEquals(86400, schedule.advanceToNextOccurrence(now + 86400*2));
+ }
+
+ @Test
+ public void getDelayInfiniteCustomRecurring() {
+ SimulatorProtocol.Schedule schedule = new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("2000-01-01T00:00:00.000Z")),
+ null,
+ "FREQ=HOURLY;"
+ );
+
+ long now = Instant.parse("2000-01-01T00:00:00.000Z").getEpochSecond();
+ long timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(100, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T00:01:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(40, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T00:02:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(3580, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+ }
+
+ @Test
+ public void getDelayCustomRecurringWithEndDate() {
+ SimulatorProtocol.Schedule schedule = new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("2000-01-01T00:00:00.000Z")),
+ null,
+ "FREQ=HOURLY;COUNT=2"
+ );
+
+ long now = Instant.parse("2000-01-01T00:00:00.000Z").getEpochSecond();
+ long timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(100, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T00:01:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(40, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T00:02:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(3580, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T01:00:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(100, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T01:01:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(40, SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule).getAsLong());
+
+ now = Instant.parse("2000-01-01T01:02:00.000Z").getEpochSecond();
+ timeSinceOccurrenceStarted = schedule.advanceToNextOccurrence(now);
+ assertEquals(OptionalLong.empty(), SimulatorProtocol.getDelay(100, timeSinceOccurrenceStarted, schedule));
+ }
+}
diff --git a/container/src/main/java/org/openremote/container/timer/TimerService.java b/container/src/main/java/org/openremote/container/timer/TimerService.java
index c504dd2b4..73c7f207c 100644
--- a/container/src/main/java/org/openremote/container/timer/TimerService.java
+++ b/container/src/main/java/org/openremote/container/timer/TimerService.java
@@ -63,6 +63,11 @@ public class TimerService implements ContainerService, RulesClock {
// NOOP
}
+ @Override
+ public void stopAtTime(long time) {
+ // NOOP
+ }
+
@Override
public void start() {
// NOOP
@@ -104,6 +109,12 @@ public class TimerService implements ContainerService, RulesClock {
}
}
+ @Override
+ public void stopAtTime(long time) {
+ stopTime = time;
+ LOG.info("Clock stopped at: " + (stopTime) + "/" + new Date(stopTime));
+ }
+
@Override
public void start() {
stopTime = null;
@@ -120,6 +131,7 @@ public class TimerService implements ContainerService, RulesClock {
public abstract void init();
public abstract long getCurrentTimeMillis();
public abstract void stop();
+ public abstract void stopAtTime(long time);
public abstract void start();
public abstract void reset();
public abstract long advanceTime(long amount, TimeUnit unit);
diff --git a/model/src/main/java/org/openremote/model/calendar/CalendarEvent.java b/model/src/main/java/org/openremote/model/calendar/CalendarEvent.java
index 2e68d4f8b..99c21254e 100644
--- a/model/src/main/java/org/openremote/model/calendar/CalendarEvent.java
+++ b/model/src/main/java/org/openremote/model/calendar/CalendarEvent.java
@@ -21,10 +21,15 @@ package org.openremote.model.calendar;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.databind.util.StdConverter;
+import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaFormat;
+import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject;
import net.fortuna.ical4j.model.Recur;
import org.openremote.model.asset.Asset;
+import org.openremote.model.util.JSONSchemaUtil;
import org.openremote.model.util.Pair;
import java.io.Serializable;
@@ -79,8 +84,10 @@ import java.util.List;
* }</pre></blockquote>
*/
public class CalendarEvent implements Serializable {
+
protected Date start;
protected Date end;
+
@JsonSerialize(converter = RecurStringConverter.class)
protected Recur<LocalDateTime> recurrence;
diff --git a/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java b/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java
index e1ca1585d..b5639d6d5 100644
--- a/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java
+++ b/model/src/main/java/org/openremote/model/simulator/SimulatorReplayDatapoint.java
@@ -20,6 +20,8 @@
package org.openremote.model.simulator;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaTitle;
+import org.openremote.model.datapoint.ValueDatapoint;
+
import java.io.Serializable;
import java.util.Optional;
@@ -42,11 +44,15 @@ public class SimulatorReplayDatapoint implements Serializable {
this.value = value;
}
- public Optional<Long> getTimestamp() {
- return Optional.of(timestamp);
+ public long getTimestamp() {
+ return timestamp;
}
public Optional<Object> getValue() {
return Optional.ofNullable(value);
}
+
+ public ValueDatapoint<Object> toValueDatapoint() {
+ return new ValueDatapoint<>(timestamp, value);
+ }
}
diff --git a/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java b/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java
index 900696420..4bb537fc2 100644
--- a/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java
+++ b/model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java
@@ -41,10 +41,13 @@ public class JSONSchemaUtil {
static class PatternPropertiesSimpleKeyAnyType {}
@JsonSchemaInject(jsonSupplierViaLookup = JSONSchemaUtil.SCHEMA_SUPPLIER_NAME_ANY_TYPE)
static class AnyType {}
+ @JsonSchemaInject(jsonSupplierViaLookup = JSONSchemaUtil.SCHEMA_SUPPLIER_NAME_STRING_TYPE)
+ static class StringType {}
private JSONSchemaUtil() {}
public static final String SCHEMA_SUPPLIER_NAME_ANY_TYPE = "anyType";
+ public static final String SCHEMA_SUPPLIER_NAME_STRING_TYPE = "stringType";
public static final String SCHEMA_SUPPLIER_NAME_PATTERN_PROPERTIES_ANY_KEY_ANY_TYPE = "patternPropertiesAnyKeyAnyType";
public static final String SCHEMA_SUPPLIER_NAME_PATTERN_PROPERTIES_SIMPLE_KEY_ANY_TYPE = "patternPropertiesSimpleKeyAnyType";
public static final String PATTERN_PROPERTIES_MATCH_ANY = ".+";
@@ -120,6 +123,7 @@ public class JSONSchemaUtil {
),
Map.of(
SCHEMA_SUPPLIER_NAME_ANY_TYPE, () -> getSchemaType(true, TYPES_ALL),
+ SCHEMA_SUPPLIER_NAME_STRING_TYPE, () -> getSchemaType(true, TYPE_STRING),
SCHEMA_SUPPLIER_NAME_PATTERN_PROPERTIES_ANY_KEY_ANY_TYPE, JSONSchemaUtil::getSchemaPatternPropertiesAnyKeyAnyType,
SCHEMA_SUPPLIER_NAME_PATTERN_PROPERTIES_SIMPLE_KEY_ANY_TYPE, JSONSchemaUtil::getSchemaPatternPropertiesSimpleKeyAnyType
),
diff --git a/model/src/main/java/org/openremote/model/util/TimeUtil.java b/model/src/main/java/org/openremote/model/util/TimeUtil.java
index b67e0707a..b0c96e277 100644
--- a/model/src/main/java/org/openremote/model/util/TimeUtil.java
+++ b/model/src/main/java/org/openremote/model/util/TimeUtil.java
@@ -16,7 +16,10 @@
package org.openremote.model.util;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.util.StdConverter;
import org.openremote.model.Constants;
+import org.openremote.model.value.impl.PeriodAndDuration;
import java.time.*;
import java.time.format.DateTimeFormatter;
@@ -107,4 +110,36 @@ public class TimeUtil {
}
return zonedDateTime.toInstant();
}
+
+ public static class ExtendedPeriodAndDuration extends PeriodAndDuration {
+ public ExtendedPeriodAndDuration(String str) {
+ super(str);
+ if (!SIMPLE.matcher(str).matches()) {
+ throw new IllegalArgumentException("Invalid ISO 8601 format");
+ }
+ }
+
+ public long toMillis() {
+ Period period = (getPeriod() != null ? getPeriod() : Period.ZERO);
+ Duration duration = (getDuration() != null ? getDuration() : Duration.ZERO);
+ return duration.plus(durationFromPeriod(period)).toMillis();
+ }
+
+ public Duration durationFromPeriod(Period period) {
+ Duration years = ChronoUnit.YEARS.getDuration().multipliedBy(period.getYears());
+ Duration months = ChronoUnit.MONTHS.getDuration().multipliedBy(period.getMonths());
+ Duration days = ChronoUnit.DAYS.getDuration().multipliedBy(period.getDays());
+ return years.plus(months).plus(days);
+ }
+ }
+
+ public static class PeriodAndDurationConverter extends StdConverter<JsonNode, ExtendedPeriodAndDuration> {
+ @Override
+ public ExtendedPeriodAndDuration convert(JsonNode value) {
+ if (value.isTextual()) {
+ return new ExtendedPeriodAndDuration(value.asText());
+ }
+ return null;
+ }
+ }
}
diff --git a/model/src/main/java/org/openremote/model/value/ForecastConfigurationWeightedExponentialAverage.java b/model/src/main/java/org/openremote/model/value/ForecastConfigurationWeightedExponentialAverage.java
index 888e9311c..ee7395e2a 100644
--- a/model/src/main/java/org/openremote/model/value/ForecastConfigurationWeightedExponentialAverage.java
+++ b/model/src/main/java/org/openremote/model/value/ForecastConfigurationWeightedExponentialAverage.java
@@ -22,20 +22,13 @@ package org.openremote.model.value;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-import com.fasterxml.jackson.databind.util.StdConverter;
-import org.openremote.model.Constants;
-import org.openremote.model.value.impl.PeriodAndDuration;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
-import java.time.Duration;
-import java.time.Period;
-import java.time.temporal.ChronoUnit;
-import java.util.regex.Pattern;
+import org.openremote.model.util.TimeUtil;
import static org.openremote.model.value.ForecastConfigurationWeightedExponentialAverage.TYPE;
@@ -44,25 +37,23 @@ public class ForecastConfigurationWeightedExponentialAverage extends ForecastCon
public static final String TYPE = "wea";
- protected static final Pattern iso8601Pattern = Pattern.compile(Constants.ISO8601_DURATION_REGEXP);
-
@NotNull
@JsonSerialize(using = ToStringSerializer.class)
- @JsonDeserialize(converter = PeriodAndDurationConverter.class)
- protected ForecastConfigurationWeightedExponentialAverage.ExtendedPeriodAndDuration pastPeriod;
+ @JsonDeserialize(converter = TimeUtil.PeriodAndDurationConverter.class)
+ protected TimeUtil.ExtendedPeriodAndDuration pastPeriod;
@NotNull
@Positive
protected Integer pastCount;
@NotNull
@JsonSerialize(using = ToStringSerializer.class)
- @JsonDeserialize(converter = PeriodAndDurationConverter.class)
- protected ForecastConfigurationWeightedExponentialAverage.ExtendedPeriodAndDuration forecastPeriod;
+ @JsonDeserialize(converter = TimeUtil.PeriodAndDurationConverter.class)
+ protected TimeUtil.ExtendedPeriodAndDuration forecastPeriod;
@NotNull
@Positive
protected Integer forecastCount;
@JsonCreator
- public ForecastConfigurationWeightedExponentialAverage(@JsonProperty("pastPeriod") ExtendedPeriodAndDuration pastPeriod, @JsonProperty("pastCount") Integer pastCount, @JsonProperty("forecastPeriod") ExtendedPeriodAndDuration forecastPeriod, @JsonProperty("forecastCount") Integer forecastCount) {
+ public ForecastConfigurationWeightedExponentialAverage(@JsonProperty("pastPeriod") TimeUtil.ExtendedPeriodAndDuration pastPeriod, @JsonProperty("pastCount") Integer pastCount, @JsonProperty("forecastPeriod") TimeUtil.ExtendedPeriodAndDuration forecastPeriod, @JsonProperty("forecastCount") Integer forecastCount) {
super(TYPE);
this.pastPeriod = pastPeriod;
this.pastCount = pastCount;
@@ -78,7 +69,7 @@ public class ForecastConfigurationWeightedExponentialAverage extends ForecastCon
forecastPeriod != null && forecastPeriod.toMillis() > 0;
}
- public ExtendedPeriodAndDuration getPastPeriod() {
+ public TimeUtil.ExtendedPeriodAndDuration getPastPeriod() {
return pastPeriod;
}
@@ -86,43 +77,11 @@ public class ForecastConfigurationWeightedExponentialAverage extends ForecastCon
return pastCount;
}
- public ExtendedPeriodAndDuration getForecastPeriod() {
+ public TimeUtil.ExtendedPeriodAndDuration getForecastPeriod() {
return forecastPeriod;
}
public Integer getForecastCount() {
return forecastCount;
}
-
- public static class ExtendedPeriodAndDuration extends PeriodAndDuration {
- public ExtendedPeriodAndDuration(String str) {
- super(str);
- if (!iso8601Pattern.matcher(str).matches()) {
- throw new IllegalArgumentException("Invalid ISO 8601 format");
- }
- }
-
- public long toMillis() {
- Period period = (getPeriod() != null ? getPeriod() : Period.ZERO);
- Duration duration = (getDuration() != null ? getDuration() : Duration.ZERO);
- return duration.plus(durationFromPeriod(period)).toMillis();
- }
-
- private Duration durationFromPeriod(Period period) {
- Duration years = ChronoUnit.YEARS.getDuration().multipliedBy(period.getYears());
- Duration months = ChronoUnit.MONTHS.getDuration().multipliedBy(period.getMonths());
- Duration days = ChronoUnit.DAYS.getDuration().multipliedBy(period.getDays());
- return years.plus(months).plus(days);
- }
- }
-
- public static class PeriodAndDurationConverter extends StdConverter<JsonNode, ExtendedPeriodAndDuration> {
- @Override
- public ExtendedPeriodAndDuration convert(JsonNode value) {
- if (value.isTextual()) {
- return new ExtendedPeriodAndDuration(value.asText());
- }
- return null;
- }
- }
}
diff --git a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
index 969e8b484..c31191fbe 100644
--- a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
+++ b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy
@@ -80,6 +80,14 @@ trait ManagerContainerTrait extends ContainerTrait {
withClockOf(container) { it.stop() }
}
+ void resetPseudoClockAt() {
+ withClockOf(container) { it.reset() }
+ }
+
+ void stopPseudoClockAt(long amount) {
+ withClockOf(container) { it.stopAtTime(amount) }
+ }
+
void startPseudoClock() {
withClockOf(container) { it.start() }
}
diff --git a/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy b/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
index abe580be6..a1ab6b79c 100644
--- a/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/ForecastServiceTest.groovy
@@ -13,6 +13,7 @@ import org.openremote.model.attribute.AttributeRef
import org.openremote.model.attribute.MetaItem
import org.openremote.model.datapoint.AssetPredictedDatapoint
import org.openremote.model.datapoint.ValueDatapoint
+import org.openremote.model.util.TimeUtil
import org.openremote.model.value.ForecastConfigurationWeightedExponentialAverage
import org.openremote.setup.integration.ManagerTestSetup
import org.openremote.test.ManagerContainerTrait
@@ -47,9 +48,9 @@ class ForecastServiceTest extends Specification implements ManagerContainerTrait
static TimerService timerService
@Shared
static ForecastConfigurationWeightedExponentialAverage forecastConfig = new ForecastConfigurationWeightedExponentialAverage(
- new ForecastConfigurationWeightedExponentialAverage.ExtendedPeriodAndDuration("P7D"),
+ new TimeUtil.ExtendedPeriodAndDuration("P7D"),
3,
- new ForecastConfigurationWeightedExponentialAverage.ExtendedPeriodAndDuration("PT1H"),
+ new TimeUtil.ExtendedPeriodAndDuration("PT1H"),
4
)
@Shared
diff --git a/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy
new file mode 100644
index 000000000..9c28dd8fd
--- /dev/null
+++ b/test/src/test/groovy/org/openremote/test/protocol/simulator/SimulatorProtocolTest.groovy
@@ -0,0 +1,595 @@
+/*
+ * 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
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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/>.
+ */
+package org.openremote.test.protocol.simulator
+
+import org.openremote.agent.protocol.simulator.SimulatorAgent
+import org.openremote.agent.protocol.simulator.SimulatorAgentLink
+import org.openremote.agent.protocol.simulator.SimulatorProtocol
+import org.openremote.manager.agent.AgentService
+import org.openremote.manager.asset.AssetStorageService
+import org.openremote.manager.datapoint.AssetDatapointService
+import org.openremote.manager.datapoint.AssetPredictedDatapointService
+import org.openremote.model.Constants
+import org.openremote.model.asset.agent.Agent
+import org.openremote.model.asset.agent.ConnectionStatus
+import org.openremote.model.asset.impl.ThingAsset
+import org.openremote.model.attribute.Attribute
+import org.openremote.model.attribute.AttributeRef
+import org.openremote.model.attribute.MetaItem
+import org.openremote.model.datapoint.query.AssetDatapointAllQuery
+import org.openremote.model.simulator.SimulatorReplayDatapoint
+import org.openremote.model.value.ValueType
+import org.openremote.test.ManagerContainerTrait
+import spock.lang.Shared
+import spock.lang.Specification
+import spock.util.concurrent.PollingConditions
+
+import java.time.Instant
+import java.time.ZoneId
+import java.time.temporal.ChronoUnit
+import java.util.concurrent.ScheduledExecutorService
+import java.util.concurrent.ScheduledFuture
+import java.util.concurrent.TimeUnit
+
+import static java.util.concurrent.TimeUnit.DAYS
+import static java.util.concurrent.TimeUnit.HOURS
+import static org.openremote.model.value.MetaItemType.AGENT_LINK
+import static org.openremote.model.value.MetaItemType.HAS_PREDICTED_DATA_POINTS
+
+class SimulatorProtocolTest extends Specification implements ManagerContainerTrait {
+
+ private final static long HOUR = 3600;
+ private final static long DAY = HOUR * 24;
+ private final static long WEEK = DAY * 7;
+
+ static final PollingConditions conditions = new PollingConditions(timeout: 10, delay: 0.2)
+
+ @Shared
+ AssetStorageService assetStorageService
+
+ @Shared
+ AssetDatapointService assetDatapointService
+
+ @Shared
+ AssetPredictedDatapointService assetPredictedDatapointService
+
+ @Shared
+ AgentService agentService
+
+ @Shared
+ SimulatorAgent agent
+
+ @Shared
+ ThingAsset asset
+
+ @Shared
+ ScheduledFuture<?> future = Mock(ScheduledFuture)
+
+ // Mock executor and rely on the delay argument to determine schedule
+ @Shared
+ ScheduledExecutorService executor = Mock(ScheduledExecutorService)
+
+ @Shared
+ SimulatorProtocol protocol
+
+ @Shared
+ Long delay
+
+ def setupSpec() {
+ given: "environment is setup"
+ startContainer(defaultConfig(), defaultServices())
+
+ // Setup services
+ assetStorageService = container.getService(AssetStorageService.class)
+ assetDatapointService = container.getService(AssetDatapointService.class)
+ assetPredictedDatapointService = container.getService(AssetPredictedDatapointService.class)
+ agentService = container.getService(AgentService.class)
+
+ // Create and link asset to agent
+ agent = new SimulatorAgent("Test agent").setRealm(Constants.MASTER_REALM)
+ agent = assetStorageService.merge(agent)
+ }
+
+ def setup() {
+ resetPseudoClockAt()
+ stopPseudoClockAt(Instant.parse("1970-01-01T00:00:00.000Z").toEpochMilli())
+
+ future = Mock(ScheduledFuture)
+ executor = Mock(ScheduledExecutorService)
+
+ asset = new ThingAsset("Test asset").setRealm(Constants.MASTER_REALM)
+ asset = assetStorageService.merge(asset)
+
+ // Must use boxed Long type in Spock closures, so avoiding parameter expansion so it doesn't silently fail.
+ executor.schedule(_ as Runnable, _ as Long, _ as TimeUnit) >> { args ->
+ delay = args[1] as Long
+ // Mock get method on ScheduledFuture to resolve the future manually
+ future.get() >> {
+ (args[0] as Runnable).run()
+ return true
+ }
+ return future
+ }
+
+
+ protocol = (SimulatorProtocol) agentService.protocolInstanceMap.get(agent.getId())
+ protocol.scheduledExecutorService = executor
+ }
+
+ def cleanup() {
+ assetStorageService.delete(List.of(asset.getId()))
+ conditions.eventually {
+ protocol.linkedAttributes.size() == 0
+ }
+ }
+
+ private getDataPoints = {
+ def now = Instant
+ .ofEpochMilli(getClockTimeOf(container)).atZone(ZoneId.of("UTC")).toLocalDateTime();
+ new AssetDatapointAllQuery(
+ now.minus(1, ChronoUnit.HOURS),
+ now.plus(1, ChronoUnit.HOURS),
+ ) }
+
+ private long getDatapointTimestamp(Attribute attribute) {
+ return Math.round(assetDatapointService.queryDatapoints(
+ asset.getId(),
+ attribute.getName(),
+ getDataPoints.call()
+ ).get(0).getTimestamp() / 1000)
+ }
+
+ def "Check Simulator Agent protocol without replay"() {
+ when: "nothing is configured"
+ asset.addOrReplaceAttributes(new Attribute<>("test1", ValueType.TEXT)
+ .addMeta(new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId())))
+ )
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test1").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ and: "nothing happens"
+ assetDatapointService.getDatapoints(attributeRef).size() == 0
+ }
+
+ def "Check Simulator Agent protocol with replay"() {
+ when: "replayData is configured to add a datapoint in 1hr, 12hrs, and 24hrs every day"
+ asset.addOrReplaceAttributes(new Attribute<>("test2", ValueType.TEXT)
+ .addMeta(new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+ new SimulatorReplayDatapoint(HOUR, "test"),
+ new SimulatorReplayDatapoint(HOUR * 12, "test"),
+ new SimulatorReplayDatapoint(HOUR * 24, "test"))))
+ )
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test2").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ (0..1).each { i ->
+ def days = i * HOUR * 24 // Starts at 0 days, increments with 1 days
+
+ then: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == days + HOUR
+ }
+
+ and: "the delay is 11 hours"
+ conditions.eventually {
+ delay == HOUR * 11
+ }
+
+ when: "fast forward 11 hours"
+ advancePseudoClock(11, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == days + HOUR * 12
+ }
+
+ and: "the delay is 12 hours"
+ conditions.eventually {
+ delay == HOUR * 12
+ }
+
+ when: "fast forward 12 hour"
+ advancePseudoClock(12, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoints are present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == days + HOUR * 24
+ }
+ }
+ }
+
+ // Won't work because the mocks will overwrite each other
+// def "Check Simulator Agent protocol adds predicted datapoints for multiple attributes"() {
+// when: "replayData is configured for both attributes to add a datapoint in 1hr every day"
+// def attribute1 = asset.getAttribute(ThingAsset.NOTES).get()
+// attribute1.addOrReplaceMeta(
+// new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+// new SimulatorReplayDatapoint(HOUR, "test"),
+// ))
+// )
+// def attribute2 = asset.getAttribute("test").get()
+// attribute2.addOrReplaceMeta(
+// new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+// new SimulatorReplayDatapoint(HOUR * 2, "test"),
+// ))
+// )
+// assetStorageService.merge(asset)
+//
+// then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+// conditions.eventually {
+// assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+// protocol.linkedAttributes.size() == 1
+// }
+//
+// (0..1).each { i ->
+// def days = i * HOUR * 24 // Starts at 0 days, increments with 1 days
+//
+// then: "the delay is 1 hour for attribute 1"
+// conditions.eventually {
+// delay == HOUR
+// }
+//
+// when: "fast forward 1 hour"
+// advancePseudoClock(1, HOURS, container)
+// future.get() // resolve future manually, because we surpassed the delay
+//
+// then: "datapoint is present"
+// conditions.eventually {
+// getDatapointTimestamp(attribute1) == days + HOUR
+// }
+//
+// and: "the delay is 1 more hour for attribute 2"
+// conditions.eventually {
+// delay == HOUR
+// }
+//
+// when: "fast forward 1 hour"
+// advancePseudoClock(1, HOURS, container)
+// future.get() // resolve future manually, because we surpassed the delay
+//
+// then: "datapoint is present"
+// conditions.eventually {
+// getDatapointTimestamp(attribute2) == days + HOUR * 2
+// }
+//
+// when: "fast forward 22 hours"
+// advancePseudoClock(22, HOURS, container)
+// }
+// then: ""
+// }
+
+ def "Check Simulator Agent protocol with replay startDate"() {
+ when: "replayData is configured to replay in 1day and 1hr"
+ asset.addOrReplaceAttributes(new Attribute<>("test3", ValueType.TEXT)
+ .addMeta(new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+ new SimulatorReplayDatapoint(HOUR, "test"),
+ new SimulatorReplayDatapoint(HOUR * 25, "test"),
+ new SimulatorReplayDatapoint(HOUR * 49, "test")
+ ).setSchedule(new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("1970-01-02T00:00:00.000Z")),
+ null,
+ null
+ ))
+ )))
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test3").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ and: "the delay is 25 hours"
+ conditions.eventually {
+ delay == DAY + HOUR
+ }
+
+ when: "fast forward 1 day and 1 hour"
+ advancePseudoClock(1, DAYS, container)
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == DAY + HOUR
+ }
+
+ // Starting at 2 days, because start date + first datapoint = 2 days since epoch
+ (2..3).each { i ->
+ def days = i * DAY // Starts at 0 days, increments with 1 day
+
+ and: "the delay is 24 hours"
+ conditions.eventually {
+ delay == HOUR * 24
+ }
+
+ when: "fast forward 24 hours"
+ advancePseudoClock(24, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == days + HOUR
+ }
+ }
+
+ and: "attribute is removed from replay map"
+ conditions.eventually {
+ protocol.replayMap.get(attributeRef) == null
+ }
+ }
+
+ def "Check Simulator Agent protocol with custom recurrence schedule"() {
+ when: "replayData is configured to add a datapoint in 1hr, and 2hrs weekly on Mondays"
+ asset.addOrReplaceAttributes(new Attribute<>("test5", ValueType.TEXT).addMeta(
+ new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+ new SimulatorReplayDatapoint(HOUR, "test"),
+ new SimulatorReplayDatapoint(HOUR * 2, "test")
+ ).setSchedule(new SimulatorProtocol.Schedule(
+ // First day should be 1970-01-05 (in 4 days) a Monday
+ Date.from(Instant.parse("1970-01-05T00:00:00.000Z")),
+ null,
+ // Recur every Monday until 1970-01-31
+ "FREQ=WEEKLY;UNTIL=19700131T000000Z;BYDAY=MO"
+ ))
+ )))
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test5").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ then: "the delay is 4 days and 1 hour"
+ conditions.eventually {
+ delay == 4 * DAY + HOUR
+ }
+
+ when: "fast forward 4 days and 1 hour"
+ advancePseudoClock(4, DAYS, container)
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == 4 * DAY + HOUR
+ }
+
+ and: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == 4 * DAY + 2 * HOUR
+ }
+
+ (1..3).each { i ->
+ def weeks = i * WEEK // Starts at 0 weeks, increments with 1 week
+ def firstWeekOffset = 4 * DAY;
+
+ and: "the delay is 1 week and -1 hour"
+ conditions.eventually {
+ delay == WEEK - HOUR
+ }
+
+ when: "fast forward 1 week and -1 hour"
+ advancePseudoClock(7, DAYS, container)
+ advancePseudoClock(-1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == firstWeekOffset + weeks + HOUR
+ }
+
+ and: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == firstWeekOffset + weeks + HOUR * 2
+ }
+ }
+
+ and: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ when: "fast forward past the end date"
+ advancePseudoClock(1000, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "the attributeRef is removed from the replayMap"
+ conditions.eventually {
+ protocol.replayMap.get(attributeRef) == null
+ }
+ }
+
+ def "Check Simulator Agent protocol adds predicted datapoints for the current and next occurrence"() {
+ when: "replayData is configured for both attributes to add a datapoint in 1 and 2 hours every day"
+ asset.addOrReplaceAttributes(new Attribute<>("test6", ValueType.TEXT).addMeta(
+ new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+ new SimulatorReplayDatapoint(HOUR, "test"),
+ new SimulatorReplayDatapoint(HOUR * 2, "test"),
+ )),
+ new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
+ )
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test6").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ (1..2).each { i ->
+ and: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ and: "the predicted datapoints are present"
+ conditions.eventually {
+ def datapoints = assetPredictedDatapointService.getDatapoints(attributeRef)
+ datapoints.size() == 4
+ datapoints.get(3).getTimestamp() / 1000 == HOUR * 1
+ datapoints.get(2).getTimestamp() / 1000 == HOUR * 2
+ datapoints.get(1).getTimestamp() / 1000 == HOUR * 25
+ datapoints.get(0).getTimestamp() / 1000 == HOUR * 26
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == i * HOUR
+ }
+ }
+
+ and: "the delay is 1 day and -1 hour"
+ conditions.eventually {
+ delay == DAY - HOUR
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, DAYS, container)
+ advancePseudoClock(-1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "datapoint is present"
+ conditions.eventually {
+ getDatapointTimestamp(attribute) == DAY + HOUR
+ }
+
+ and: "the predicted datapoints are present"
+ def datapoints1 = assetPredictedDatapointService.getDatapoints(attributeRef)
+ datapoints1.size() == 6
+ datapoints1.get(5).getTimestamp()/1000 == HOUR * 1
+ datapoints1.get(4).getTimestamp()/1000 == HOUR * 2
+ datapoints1.get(3).getTimestamp()/1000 == HOUR * 25
+ datapoints1.get(2).getTimestamp()/1000 == HOUR * 26
+ datapoints1.get(1).getTimestamp()/1000 == HOUR * 49
+ datapoints1.get(0).getTimestamp()/1000 == HOUR * 50
+
+ when: "reset agentLink"
+ attribute.addOrReplaceMeta(
+ new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId())),
+ )
+ assetStorageService.merge(asset)
+
+ then: "purge datapoints"
+ conditions.eventually {
+ assetPredictedDatapointService.getDatapoints(attributeRef).size() == 0
+ }
+ }
+
+ def "Check Simulator Agent protocol adds predicted datapoints for one-time occurrence"() {
+ when: "replayData is configured for both attributes to add a datapoint in 1 and 2 hours"
+ asset.addOrReplaceAttributes(new Attribute<>("test7", ValueType.TEXT).addMeta(
+ new MetaItem<>(AGENT_LINK, new SimulatorAgentLink(agent.getId()).setReplayData(
+ new SimulatorReplayDatapoint(HOUR, "test"),
+ new SimulatorReplayDatapoint(HOUR * 2, "test"),
+ ).setSchedule(new SimulatorProtocol.Schedule(
+ Date.from(Instant.parse("1970-01-01T00:00:00.000Z")),
+ null, null
+ ))),
+ new MetaItem<>(HAS_PREDICTED_DATA_POINTS, true))
+ )
+ asset = assetStorageService.merge(asset)
+ def attribute = asset.getAttribute("test7").get()
+ def attributeRef = new AttributeRef(asset.getId(), attribute.getName())
+
+ then: "the agent status should become CONNECTED and the attribute linked to the protocol"
+ conditions.eventually {
+ assetStorageService.find(agent.getId(), Agent.class).getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED
+ protocol.linkedAttributes.get(attributeRef) == attribute
+ }
+
+ and: "the delay is 1 hour"
+ conditions.eventually {
+ delay == HOUR
+ }
+
+ and: "the predicted datapoints are present"
+ conditions.eventually {
+ def datapoints = assetPredictedDatapointService.getDatapoints(attributeRef)
+ datapoints.get(1).getTimestamp()/1000 == HOUR * 1
+ datapoints.get(0).getTimestamp()/1000 == HOUR * 2
+ }
+
+ when: "fast forward 1 hour"
+ advancePseudoClock(1, HOURS, container)
+ future.get() // resolve future manually, because we surpassed the delay
+
+ then: "the predicted datapoints are present"
+ conditions.eventually {
+ def datapoints = assetPredictedDatapointService.getDatapoints(attributeRef)
+ datapoints.get(1).getTimestamp()/1000 == HOUR * 1
+ datapoints.get(0).getTimestamp()/1000 == HOUR * 2
+ }
+ }
+}
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index b3929bd65..6acebb23b 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -173,7 +173,7 @@ export const jsonFormsInputTemplateProvider: (fallback: ValueInputProvider) => V
if (!schema) {
// TODO: Load agent link schema from AssetModelUtil - For now run AssetModelTest in debug and copy paste the result of def schema = ValueUtil.getSchema(AgentLink.class)
- schema = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","title":"Agent Link","oneOf":[{"$ref":"#/definitions/SNMPAgentLink"},{"$ref":"#/definitions/DefaultAgentLink"},{"$ref":"#/definitions/HTTPAgentLink"},{"$ref":"#/definitions/MockAgentLink"},{"$ref":"#/definitions/WebsocketAgentLink"},{"$ref":"#/definitions/ZWaveAgentLink"},{"$ref":"#/definitions/ModbusAgentLink"},{"$ref":"#/definitions/StorageSimulatorAgentLink"},{"$ref":"#/definitions/BluetoothMeshAgentLink"},{"$ref":"#/definitions/MQTTAgentLink"},{"$ref":"#/definitions/KNXAgentLink"},{"$ref":"#/definitions/SimulatorAgentLink"},{"$ref":"#/definitions/MailAgentLink"},{"$ref":"#/definitions/VelbusAgentLink"}],"definitions":{"SNMPAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["SNMPAgentLink"],"default":"SNMPAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"oid":{"type":"string"}},"title":"SNMPAgentLink","required":["type","oid"]},"regex":{"type":"object","additionalProperties":true,"title":"Regex","properties":{"type":{"type":"string","enum":["regex"],"default":"regex"},"pattern":{"type":"string"},"matchGroup":{"type":"integer"},"matchIndex":{"type":"integer"}},"required":["type"]},"substring":{"type":"object","additionalProperties":true,"title":"Substring","properties":{"type":{"type":"string","enum":["substring"],"default":"substring"},"beginIndex":{"type":"integer"},"endIndex":{"type":"integer"}},"required":["type","beginIndex"]},"jsonPath":{"type":"object","additionalProperties":true,"title":"JSON Path","properties":{"type":{"type":"string","enum":["jsonPath"],"default":"jsonPath"},"path":{"type":"string"},"returnFirst":{"type":"boolean"},"returnLast":{"type":"boolean"}},"required":["type","path","returnFirst","returnLast"]},"mathExpression":{"type":"object","additionalProperties":true,"title":"Mathematical Expression","properties":{"type":{"type":"string","enum":["mathExpression"],"default":"mathExpression"},"expression":{"type":"string"}},"required":["type"]},"AnyType":{"type":["null","number","integer","boolean","string","array","object"],"additionalProperties":true,"properties":{}},"StringPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for string values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["string"],"default":"string"},"match":{"type":"string","enum":["EXACT","BEGIN","END","CONTAINS"]},"caseSensitive":{"type":"boolean"},"value":{"type":"string"},"negate":{"type":"boolean"}},"title":"string","required":["predicateType","caseSensitive","negate"]},"BooleanPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for boolean values; will evaluate the value as a boolean and match against this predicates value, any value that is not a boolean will not match","properties":{"predicateType":{"type":"string","enum":["boolean"],"default":"boolean"},"value":{"type":"boolean"}},"title":"boolean","required":["predicateType","value"]},"DateTimePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for date time values; provided values should be valid ISO 8601 datetime strings (e.g. yyyy-MM-dd\'T\'HH:mm:ssZ or yyyy-MM-dd\'T\'HH:mm:ss±HH:mm), offset and time are optional, if no offset information is supplied then UTC is assumed.","properties":{"predicateType":{"type":"string","enum":["datetime"],"default":"datetime"},"value":{"type":"string"},"rangeValue":{"type":"string"},"operator":{"type":"string","enum":["EQUALS","GREATER_THAN","GREATER_EQUALS","LESS_THAN","LESS_EQUALS","BETWEEN"]},"negate":{"type":"boolean"}},"title":"datetime","required":["predicateType","negate"]},"NumberPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for number values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["number"],"default":"number"},"value":{"type":"number"},"rangeValue":{"type":"number"},"operator":{"type":"string","enum":["EQUALS","GREATER_THAN","GREATER_EQUALS","LESS_THAN","LESS_EQUALS","BETWEEN"]},"negate":{"type":"boolean"}},"title":"number","required":["predicateType","negate"]},"RadialGeofencePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for GEO JSON point values; will return true if the point is within the specified radius of the specified latitude and longitude unless negated.","title":"Radial geofence","properties":{"predicateType":{"type":"string","enum":["radial"],"default":"radial"},"radius":{"type":"integer"},"lat":{"type":"number"},"lng":{"type":"number"},"negated":{"type":"boolean"}},"required":["predicateType","radius","lat","lng","negated"]},"RectangularGeofencePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for GEO JSON point values; will return true if the point is within the specified rectangle specified as latitude and longitude values of two corners unless negated.","title":"Rectangular geofence","properties":{"predicateType":{"type":"string","enum":["rect"],"default":"rect"},"latMin":{"type":"number"},"lngMin":{"type":"number"},"latMax":{"type":"number"},"lngMax":{"type":"number"},"negated":{"type":"boolean"}},"required":["predicateType","latMin","lngMin","latMax","lngMax","negated"]},"ArrayPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for array values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["array"],"default":"array"},"value":{"$ref":"#/definitions/AnyType"},"index":{"type":"integer"},"lengthEquals":{"type":"integer"},"lengthGreaterThan":{"type":"integer"},"lengthLessThan":{"type":"integer"},"negated":{"type":"boolean"}},"title":"array","required":["predicateType","negated"]},"ValueAnyPredicate":{"type":"object","additionalProperties":true,"description":"Predicate that matches any value including null.","title":"Any value","properties":{"predicateType":{"type":"string","enum":["value-any"],"default":"value-any"}},"required":["predicateType"]},"ValueEmptyPredicate":{"type":"object","additionalProperties":true,"description":"Predicate that matches any empty/null value; unless negated.","title":"Empty value","properties":{"predicateType":{"type":"string","enum":["value-empty"],"default":"value-empty"},"negate":{"type":"boolean"}},"required":["predicateType","negate"]},"CalendarEventPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for calendar event values; will match based on whether the calendar event is active for the specified time.","title":"Calendar","properties":{"predicateType":{"type":"string","enum":["calendar-event"],"default":"calendar-event"},"timestamp":{"type":"integer","format":"utc-millisec"}},"required":["predicateType"]},"DefaultAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["DefaultAgentLink"],"default":"DefaultAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"DefaultAgentLink","required":["type"]},"HTTPAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["HTTPAgentLink"],"default":"HTTPAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"headers":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"A JSON object of headers to be added to HTTP request; the key represents the name of the header and for each string value supplied a new header will be added with the key name and specified string value"},"queryParameters":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"A JSON object of query parameters to be added to HTTP request URL; the key represents the name of the query parameter and for each string value supplied a new query parameter will be added with the key name and specified string value (e.g. \'https://..../?test=1&test=2\')"},"pollingMillis":{"type":"integer","description":"Indicates that this HTTP request is used to update the linked attribute; this value indicates how frequently the HTTP request is made in order to update the linked attribute value"},"pagingMode":{"type":"boolean","description":"Indicates that the HTTP server supports pagination using the standard Link header mechanism"},"path":{"type":"string","description":"The URL path to append to the agents Base URL when making requests for this linked attribute"},"method":{"type":"string","enum":["GET","POST","PUT","DELETE","OPTIONS","PATCH"],"description":"The HTTP method to use when making requests for this linked attribute"},"contentType":{"type":"string","description":"The content type header value to use when making requests for this linked attribute (shortcut alternative to using headers parameter)"},"pollingAttribute":{"type":"string","description":"Allows the polled response to be written to another attribute with the specified name on the same asset as the linked attribute"},"messageConvertBinary":{"type":"boolean","description":"Indicates that the HTTP response is binary and should be converted to binary string representation"},"messageConvertHex":{"type":"boolean","description":"Indicates that the HTTP response is binary and should be converted to hexadecimal string representation"}},"title":"HTTPAgentLink","required":["type","messageConvertBinary","messageConvertHex"]},"MockAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MockAgentLink"],"default":"MockAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"requiredValue":{"type":"string"}},"title":"MockAgentLink","required":["type"]},"WebsocketAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["WebsocketAgentLink"],"default":"WebsocketAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"websocketSubscriptions":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/websocket"},{"$ref":"#/definitions/http"}]}}},"title":"WebsocketAgentLink","required":["type"]},"websocket":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["websocket"],"default":"websocket"},"body":{"$ref":"#/definitions/AnyType"}},"title":"websocket","required":["type"]},"http":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["http"],"default":"http"},"body":{"$ref":"#/definitions/AnyType"},"method":{"type":"string","enum":["GET","PUT","POST"]},"contentType":{"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},"uri":{"type":"string"}},"title":"http","required":["type"]},"ZWaveAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["ZWaveAgentLink"],"default":"ZWaveAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"deviceNodeId":{"type":"integer"},"deviceEndpoint":{"type":"integer"},"deviceValue":{"type":"string"}},"title":"ZWaveAgentLink","required":["type"]},"ModbusAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["ModbusAgentLink"],"default":"ModbusAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"pollingMillis":{"type":"integer","description":"Poll interval in milliseconds"},"readMemoryArea":{"type":"string","enum":["COIL","DISCRETE","HOLDING","INPUT"],"description":"Memory area to read from during read request"},"readValueType":{"type":"string","enum":["BOOL","SINT","USINT","BYTE","INT","UINT","WORD","DINT","UDINT","DWORD","LINT","ULINT","LWORD","REAL","LREAL","CHAR","WCHAR"],"description":"Type to convert the returned data to. As specified by the PLC4X Modbus data types."},"readAddress":{"type":"integer","description":"Zero based address from which the value is read from"},"writeMemoryArea":{"type":"string","enum":["COIL","HOLDING"],"description":"Memory area to write to. \\"HOLDING\\" or \\"COIL\\" allowed."},"writeAddress":{"type":"integer","description":"Zero-based address to which the value sent is written to"},"readRegistersAmount":{"type":"integer","description":"Set amount of registers to read. If left empty or less than 1, will use the default size for the corresponding data-type."}},"title":"ModbusAgentLink","required":["type","pollingMillis","readMemoryArea","readValueType","readAddress"]},"StorageSimulatorAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["StorageSimulatorAgentLink"],"default":"StorageSimulatorAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"StorageSimulatorAgentLink","required":["type"]},"BluetoothMeshAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["BluetoothMeshAgentLink"],"default":"BluetoothMeshAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"appKeyIndex":{"type":"integer","minimum":0,"maximum":2147483647},"address":{"type":"string","pattern":"^([0-9A-Fa-f]{4})$"},"modelName":{"type":"string","pattern":"^.*\\\\S+.*$","minLength":1}},"title":"BluetoothMeshAgentLink","required":["type","appKeyIndex","modelName"]},"MQTTAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MQTTAgentLink"],"default":"MQTTAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"subscriptionTopic":{"type":"string","description":"An MQTT topic to subscribe to, any received payload will be pushed into the attribute; use value filter(s) to extract values from string payloads and/or value converters to do simple value mapping, complex processing may require a rule or a custom MQTT agent"},"publishTopic":{"type":"string","description":"An MQTT topic to publish attribute events to, any received payload will be pushed into the attribute; use write value converter and/or write value to do any processing, complex processing may require a rule or a custom MQTT agent"},"qos":{"type":"integer","minimum":0,"maximum":2,"description":"QoS level to use for publish/subscribe (default is 0 if unset)"}},"title":"MQTTAgentLink","required":["type"]},"KNXAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["KNXAgentLink"],"default":"KNXAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"dpt":{"type":"string","pattern":"^\\\\d{1,3}\\\\.\\\\d{1,3}$"},"actionGroupAddress":{"type":"string","pattern":"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$"},"statusGroupAddress":{"type":"string","pattern":"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$"}},"title":"KNXAgentLink","required":["type","dpt"]},"SimulatorAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["SimulatorAgentLink"],"default":"SimulatorAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"replayData":{"type":"array","items":{"$ref":"#/definitions/SimulatorReplayDatapoint"},"description":"Used to store 24h dataset of values that should be replayed (i.e. written to the linked attribute) in a continuous loop."}},"title":"SimulatorAgentLink","required":["type"]},"SimulatorReplayDatapoint":{"type":"object","additionalProperties":true,"title":"Data point","properties":{"timestamp":{"type":"integer"},"value":{"$ref":"#/definitions/AnyType"}},"required":["timestamp"]},"MailAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MailAgentLink"],"default":"MailAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"subjectMatchPredicate":{"$ref":"#/definitions/StringPredicate","description":"The predicate to apply to incoming mail message subjects to determine if the message is intended for the linked attribute. This must be defined to enable attributes to be updated by the linked agent."},"fromMatchPredicate":{"$ref":"#/definitions/StringPredicate","description":"The predicate to apply to incoming mail message from address(es) to determine if the message is intended for the linked attribute. This must be defined to enable attributes to be updated by the linked agent."},"useSubject":{"type":"boolean","description":"Use the subject as value instead of the body"}},"title":"MailAgentLink","required":["type"]},"VelbusAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["VelbusAgentLink"],"default":"VelbusAgentLink"},"id":{"type":"string","format":"or-agent-id"},"deviceAddress":{"type":"integer","minimum":1,"maximum":255},"deviceValueLink":{"type":"string","pattern":"^.*\\\\S+.*$","minLength":1},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"VelbusAgentLink","required":["type","deviceAddress","deviceValueLink"]}}}');
+ schema = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","title":"Agent Link","oneOf":[{"$ref":"#/definitions/SNMPAgentLink"},{"$ref":"#/definitions/DefaultAgentLink"},{"$ref":"#/definitions/HTTPAgentLink"},{"$ref":"#/definitions/MockAgentLink"},{"$ref":"#/definitions/WebsocketAgentLink"},{"$ref":"#/definitions/ZWaveAgentLink"},{"$ref":"#/definitions/ModbusAgentLink"},{"$ref":"#/definitions/StorageSimulatorAgentLink"},{"$ref":"#/definitions/BluetoothMeshAgentLink"},{"$ref":"#/definitions/MQTTAgentLink"},{"$ref":"#/definitions/KNXAgentLink"},{"$ref":"#/definitions/SimulatorAgentLink"},{"$ref":"#/definitions/MailAgentLink"},{"$ref":"#/definitions/VelbusAgentLink"}],"definitions":{"SNMPAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["SNMPAgentLink"],"default":"SNMPAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"oid":{"type":"string"}},"title":"SNMPAgentLink","required":["type","oid"]},"regex":{"type":"object","additionalProperties":true,"title":"Regex","properties":{"type":{"type":"string","enum":["regex"],"default":"regex"},"pattern":{"type":"string"},"matchGroup":{"type":"integer"},"matchIndex":{"type":"integer"}},"required":["type"]},"substring":{"type":"object","additionalProperties":true,"title":"Substring","properties":{"type":{"type":"string","enum":["substring"],"default":"substring"},"beginIndex":{"type":"integer"},"endIndex":{"type":"integer"}},"required":["type","beginIndex"]},"jsonPath":{"type":"object","additionalProperties":true,"title":"JSON Path","properties":{"type":{"type":"string","enum":["jsonPath"],"default":"jsonPath"},"path":{"type":"string"},"returnFirst":{"type":"boolean"},"returnLast":{"type":"boolean"}},"required":["type","path","returnFirst","returnLast"]},"mathExpression":{"type":"object","additionalProperties":true,"title":"Mathematical Expression","properties":{"type":{"type":"string","enum":["mathExpression"],"default":"mathExpression"},"expression":{"type":"string"}},"required":["type"]},"AnyType":{"type":["null","number","integer","boolean","string","array","object"],"additionalProperties":true,"properties":{}},"StringPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for string values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["string"],"default":"string"},"match":{"type":"string","enum":["EXACT","BEGIN","END","CONTAINS"]},"caseSensitive":{"type":"boolean"},"value":{"type":"string"},"negate":{"type":"boolean"}},"title":"string","required":["predicateType","caseSensitive","negate"]},"BooleanPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for boolean values; will evaluate the value as a boolean and match against this predicates value, any value that is not a boolean will not match","properties":{"predicateType":{"type":"string","enum":["boolean"],"default":"boolean"},"value":{"type":"boolean"}},"title":"boolean","required":["predicateType","value"]},"DateTimePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for date time values; provided values should be valid ISO 8601 datetime strings (e.g. yyyy-MM-dd\'T\'HH:mm:ssZ or yyyy-MM-dd\'T\'HH:mm:ss±HH:mm), offset and time are optional, if no offset information is supplied then UTC is assumed.","properties":{"predicateType":{"type":"string","enum":["datetime"],"default":"datetime"},"value":{"type":"string"},"rangeValue":{"type":"string"},"operator":{"type":"string","enum":["EQUALS","GREATER_THAN","GREATER_EQUALS","LESS_THAN","LESS_EQUALS","BETWEEN"]},"negate":{"type":"boolean"}},"title":"datetime","required":["predicateType","negate"]},"NumberPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for number values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["number"],"default":"number"},"value":{"type":"number"},"rangeValue":{"type":"number"},"operator":{"type":"string","enum":["EQUALS","GREATER_THAN","GREATER_EQUALS","LESS_THAN","LESS_EQUALS","BETWEEN"]},"negate":{"type":"boolean"}},"title":"number","required":["predicateType","negate"]},"RadialGeofencePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for GEO JSON point values; will return true if the point is within the specified radius of the specified latitude and longitude unless negated.","title":"Radial geofence","properties":{"predicateType":{"type":"string","enum":["radial"],"default":"radial"},"radius":{"type":"integer"},"lat":{"type":"number"},"lng":{"type":"number"},"negated":{"type":"boolean"}},"required":["predicateType","radius","lat","lng","negated"]},"RectangularGeofencePredicate":{"type":"object","additionalProperties":true,"description":"Predicate for GEO JSON point values; will return true if the point is within the specified rectangle specified as latitude and longitude values of two corners unless negated.","title":"Rectangular geofence","properties":{"predicateType":{"type":"string","enum":["rect"],"default":"rect"},"latMin":{"type":"number"},"lngMin":{"type":"number"},"latMax":{"type":"number"},"lngMax":{"type":"number"},"negated":{"type":"boolean"}},"required":["predicateType","latMin","lngMin","latMax","lngMax","negated"]},"ArrayPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for array values; will match based on configured options.","properties":{"predicateType":{"type":"string","enum":["array"],"default":"array"},"value":{"$ref":"#/definitions/AnyType"},"index":{"type":"integer"},"lengthEquals":{"type":"integer"},"lengthGreaterThan":{"type":"integer"},"lengthLessThan":{"type":"integer"},"negated":{"type":"boolean"}},"title":"array","required":["predicateType","negated"]},"ValueAnyPredicate":{"type":"object","additionalProperties":true,"description":"Predicate that matches any value including null.","title":"Any value","properties":{"predicateType":{"type":"string","enum":["value-any"],"default":"value-any"}},"required":["predicateType"]},"ValueEmptyPredicate":{"type":"object","additionalProperties":true,"description":"Predicate that matches any empty/null value; unless negated.","title":"Empty value","properties":{"predicateType":{"type":"string","enum":["value-empty"],"default":"value-empty"},"negate":{"type":"boolean"}},"required":["predicateType","negate"]},"CalendarEventPredicate":{"type":"object","additionalProperties":true,"description":"Predicate for calendar event values; will match based on whether the calendar event is active for the specified time.","title":"Calendar","properties":{"predicateType":{"type":"string","enum":["calendar-event"],"default":"calendar-event"},"timestamp":{"type":"integer","format":"utc-millisec"}},"required":["predicateType"]},"DefaultAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["DefaultAgentLink"],"default":"DefaultAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"DefaultAgentLink","required":["type"]},"HTTPAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["HTTPAgentLink"],"default":"HTTPAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"headers":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"A JSON object of headers to be added to HTTP request; the key represents the name of the header and for each string value supplied a new header will be added with the key name and specified string value"},"queryParameters":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"A JSON object of query parameters to be added to HTTP request URL; the key represents the name of the query parameter and for each string value supplied a new query parameter will be added with the key name and specified string value (e.g. \'https://..../?test=1&test=2\')"},"pollingMillis":{"type":"integer","description":"Indicates that this HTTP request is used to update the linked attribute; this value indicates how frequently the HTTP request is made in order to update the linked attribute value"},"pagingMode":{"type":"boolean","description":"Indicates that the HTTP server supports pagination using the standard Link header mechanism"},"path":{"type":"string","description":"The URL path to append to the agents Base URL when making requests for this linked attribute"},"method":{"type":"string","enum":["GET","POST","PUT","DELETE","OPTIONS","PATCH"],"description":"The HTTP method to use when making requests for this linked attribute"},"contentType":{"type":"string","description":"The content type header value to use when making requests for this linked attribute (shortcut alternative to using headers parameter)"},"pollingAttribute":{"type":"string","description":"Allows the polled response to be written to another attribute with the specified name on the same asset as the linked attribute"},"messageConvertBinary":{"type":"boolean","description":"Indicates that the HTTP response is binary and should be converted to binary string representation"},"messageConvertHex":{"type":"boolean","description":"Indicates that the HTTP response is binary and should be converted to hexadecimal string representation"}},"title":"HTTPAgentLink","required":["type","messageConvertBinary","messageConvertHex"]},"MockAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MockAgentLink"],"default":"MockAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"requiredValue":{"type":"string"}},"title":"MockAgentLink","required":["type"]},"WebsocketAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["WebsocketAgentLink"],"default":"WebsocketAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"websocketSubscriptions":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/websocket"},{"$ref":"#/definitions/http"}]}}},"title":"WebsocketAgentLink","required":["type"]},"websocket":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["websocket"],"default":"websocket"},"body":{"$ref":"#/definitions/AnyType"}},"title":"websocket","required":["type"]},"http":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["http"],"default":"http"},"body":{"$ref":"#/definitions/AnyType"},"method":{"type":"string","enum":["GET","PUT","POST"]},"contentType":{"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},"uri":{"type":"string"}},"title":"http","required":["type"]},"ZWaveAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["ZWaveAgentLink"],"default":"ZWaveAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"deviceNodeId":{"type":"integer"},"deviceEndpoint":{"type":"integer"},"deviceValue":{"type":"string"}},"title":"ZWaveAgentLink","required":["type"]},"ModbusAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["ModbusAgentLink"],"default":"ModbusAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"pollingMillis":{"type":"integer","description":"Poll interval in milliseconds"},"readMemoryArea":{"type":"string","enum":["COIL","DISCRETE","HOLDING","INPUT"],"description":"Memory area to read from during read request"},"readValueType":{"type":"string","enum":["BOOL","SINT","USINT","BYTE","INT","UINT","WORD","DINT","UDINT","DWORD","LINT","ULINT","LWORD","REAL","LREAL","CHAR","WCHAR"],"description":"Type to convert the returned data to. As specified by the PLC4X Modbus data types."},"readAddress":{"type":"integer","description":"Zero based address from which the value is read from"},"writeMemoryArea":{"type":"string","enum":["COIL","HOLDING"],"description":"Memory area to write to. \\"HOLDING\\" or \\"COIL\\" allowed."},"writeAddress":{"type":"integer","description":"Zero-based address to which the value sent is written to"},"readRegistersAmount":{"type":"integer","description":"Set amount of registers to read. If left empty or less than 1, will use the default size for the corresponding data-type."}},"title":"ModbusAgentLink","required":["type","pollingMillis","readMemoryArea","readValueType","readAddress"]},"StorageSimulatorAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["StorageSimulatorAgentLink"],"default":"StorageSimulatorAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"StorageSimulatorAgentLink","required":["type"]},"BluetoothMeshAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["BluetoothMeshAgentLink"],"default":"BluetoothMeshAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"appKeyIndex":{"type":"integer","minimum":0,"maximum":2147483647},"address":{"type":"string","pattern":"^([0-9A-Fa-f]{4})$"},"modelName":{"type":"string","pattern":"^.*\\\\S+.*$","minLength":1}},"title":"BluetoothMeshAgentLink","required":["type","appKeyIndex","modelName"]},"MQTTAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MQTTAgentLink"],"default":"MQTTAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"subscriptionTopic":{"type":"string","description":"An MQTT topic to subscribe to, any received payload will be pushed into the attribute; use value filter(s) to extract values from string payloads and/or value converters to do simple value mapping, complex processing may require a rule or a custom MQTT agent"},"publishTopic":{"type":"string","description":"An MQTT topic to publish attribute events to, any received payload will be pushed into the attribute; use write value converter and/or write value to do any processing, complex processing may require a rule or a custom MQTT agent"},"qos":{"type":"integer","minimum":0,"maximum":2,"description":"QoS level to use for publish/subscribe (default is 0 if unset)"}},"title":"MQTTAgentLink","required":["type"]},"KNXAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["KNXAgentLink"],"default":"KNXAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"dpt":{"type":"string","pattern":"^\\\\d{1,3}\\\\.\\\\d{1,3}$"},"actionGroupAddress":{"type":"string","pattern":"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$"},"statusGroupAddress":{"type":"string","pattern":"^\\\\d{1,3}/\\\\d{1,3}/\\\\d{1,3}$"}},"title":"KNXAgentLink","required":["type","dpt"]},"SimulatorAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["SimulatorAgentLink"],"default":"SimulatorAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"replayData":{"type":"array","items":{"$ref":"#/definitions/SimulatorReplayDatapoint"},"description":"Used to store a dataset of values that should be replayed (i.e. written to the linked attribute) in a continuous loop based on a schedule (by default replays every 24h). Predicted datapoints can be added by configuring \'Store predicted datapoints\' which will insert the datapoints immediately as determined by the schedule."},"schedule":{"$ref":"#/definitions/Schedule","description":"When defined overwrites the possible dataset length and when it is replayed. This could be once when only a start- (and end) date are defined, or a recurring event following the RFC 5545 RRULE format. If not provided defaults to 24 hours. If the replay data contains datapoints scheduled after the default 24 hours or the recurrence rule the datapoints will be ignored."}},"title":"SimulatorAgentLink","required":["type"]},"SimulatorReplayDatapoint":{"type":"object","additionalProperties":true,"title":"Data point","properties":{"timestamp":{"type":"integer"},"value":{"$ref":"#/definitions/AnyType"}},"required":["timestamp"]},"Schedule":{"type":"object","additionalProperties":true,"properties":{"start":{"type":"string","format":"date-time","description":"Set a start date, if not provided, starts immediately. When the replay datapoint timestamp is 0 it will insert it at 00:00."},"end":{"type":"string","format":"date-time","description":"Not implemented, within the recurrence rule you can specify an end date."},"recurrence":{"type":"string"}}},"Recur(LocalDateTime)":{"type":"object","additionalProperties":true,"properties":{"frequency":{"type":"string","enum":["SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"]},"skip":{"type":"string","enum":["OMIT","BACKWARD","FORWARD"]},"until":{"$ref":"#/definitions/TemporalAdapter(LocalDateTime)"},"rscale":{"type":"string","enum":["JAPANESE","BUDDHIST","ROC","ISLAMIC","ISO8601","CHINESE","ETHIOPIC","HEBREW","GREGORIAN"]},"count":{"type":"integer"},"interval":{"type":"integer"},"secondList":{"type":"array","items":{"type":"integer"}},"minuteList":{"type":"array","items":{"type":"integer"}},"hourList":{"type":"array","items":{"type":"integer"}},"dayList":{"type":"array","items":{"$ref":"#/definitions/WeekDay"}},"monthDayList":{"type":"array","items":{"type":"integer"}},"yearDayList":{"type":"array","items":{"type":"integer"}},"weekNoList":{"type":"array","items":{"type":"integer"}},"monthList":{"type":"array","items":{"$ref":"#/definitions/Month"}},"setPosList":{"type":"array","items":{"type":"integer"}},"weekStartDay":{"$ref":"#/definitions/WeekDay"},"experimentalValues":{"type":"object","additionalProperties":{"type":"string"}},"calIncField":{"$ref":"#/definitions/TemporalUnit"}}},"TemporalAdapter(LocalDateTime)":{"type":"object","additionalProperties":true,"properties":{"valueString":{"type":"string"},"tzId":{"$ref":"#/definitions/TzId"}}},"TzId":{"type":"object","additionalProperties":true,"properties":{"name":{"type":"string"},"value":{"type":"string"}}},"WeekDay":{"type":"object","additionalProperties":true,"properties":{"day":{"type":"string","enum":["SU","MO","TU","WE","TH","FR","SA"]},"offset":{"type":"integer"}},"required":["offset"]},"Month":{"type":"object","additionalProperties":true,"properties":{"monthOfYear":{"type":"integer"},"leapMonth":{"type":"boolean"}},"required":["monthOfYear","leapMonth"]},"TemporalUnit":{"type":"object","additionalProperties":true,"properties":{"durationEstimated":{"type":"boolean"},"duration":{"type":"integer","format":"utc-millisec"},"timeBased":{"type":"boolean"},"dateBased":{"type":"boolean"}},"required":["durationEstimated","timeBased","dateBased"]},"MailAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["MailAgentLink"],"default":"MailAgentLink"},"id":{"type":"string","format":"or-agent-id"},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"},"subjectMatchPredicate":{"$ref":"#/definitions/StringPredicate","description":"The predicate to apply to incoming mail message subjects to determine if the message is intended for the linked attribute. This must be defined to enable attributes to be updated by the linked agent."},"fromMatchPredicate":{"$ref":"#/definitions/StringPredicate","description":"The predicate to apply to incoming mail message from address(es) to determine if the message is intended for the linked attribute. This must be defined to enable attributes to be updated by the linked agent."},"useSubject":{"type":"boolean","description":"Use the subject as value instead of the body"}},"title":"MailAgentLink","required":["type"]},"VelbusAgentLink":{"type":"object","additionalProperties":true,"properties":{"type":{"type":"string","enum":["VelbusAgentLink"],"default":"VelbusAgentLink"},"id":{"type":"string","format":"or-agent-id"},"deviceAddress":{"type":"integer","minimum":1,"maximum":255},"deviceValueLink":{"type":"string","pattern":"^.*\\\\S+.*$","minLength":1},"valueFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"Defines ValueFilters to apply to an incoming value before it is written to a protocol linked attribute; this is particularly useful for generic protocols. The message should pass through the filters in array order"},"valueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValueConverter":{"type":"object","patternProperties":{".+":{"type":["null","number","integer","boolean","string","array","object"]}}},"writeValue":{"type":"string","format":"or-multiline","description":"String to be used for attribute writes and can contain dynamic placeholders to allow dyanmic value and/or time injection with formatting (see documentation for details) into the string or alternatively write the string through to the protocol as is (static string)"},"messageMatchPredicate":{"oneOf":[{"$ref":"#/definitions/StringPredicate"},{"$ref":"#/definitions/BooleanPredicate"},{"$ref":"#/definitions/DateTimePredicate"},{"$ref":"#/definitions/NumberPredicate"},{"$ref":"#/definitions/RadialGeofencePredicate"},{"$ref":"#/definitions/RectangularGeofencePredicate"},{"$ref":"#/definitions/ArrayPredicate"},{"$ref":"#/definitions/ValueAnyPredicate"},{"$ref":"#/definitions/ValueEmptyPredicate"},{"$ref":"#/definitions/CalendarEventPredicate"}],"description":"The predicate to apply to incoming messages to determine if the message is intended for the linked attribute; the value used in the predicate can be filtered using the message match filters. This must be defined to enable attributes to be updated by the linked agent."},"messageMatchFilters":{"type":"array","items":{"oneOf":[{"$ref":"#/definitions/regex"},{"$ref":"#/definitions/substring"},{"$ref":"#/definitions/jsonPath"},{"$ref":"#/definitions/mathExpression"}]},"description":"ValueFilters to apply to incoming messages prior to comparison with the messageMatchPredicate"},"updateOnWrite":{"type":"boolean","description":"Don\'t expect a response from the protocol just update the attribute immediately on write"}},"title":"VelbusAgentLink","required":["type","deviceAddress","deviceValueLink"]}}}');
}
loadedAgents = await loadAgents();