Antodis

Seshat Java SDK

TR | EN

Java SDK

Fluent FindOptions, typed IoT models, resilient streaming fallback.

Install

implementation files('libs/seshat-java-sdk.jar')

Downloads

Fetching latest version info…

Initialize Client

SeshatClient client = new SeshatClient(SeshatClientOptions.builder()
  .host("localhost") // seshat host
  .apiKey("")
  .secret("")
  .company("")
  .build());

Sensors

var fo = client.sensors.findOpts().name("temp").tag("critical").all(true);
client.sensors.findEachPage(fo, page -> {
  // page.json, page.page, page.limit
  return true;
});

Functions overview: find performs a single page fetch returning sensors and total count. findEachPage iterates sequential pages invoking your handler with items + pagination until all pages consumed or handler returns false. findHandler (not shown) lets you inspect pagination metadata only (total/page/limit) across pages when all(true) is set—useful for progress reporting before calling findEachPage. All filters combine with AND semantics; null/empty values are omitted from the query string. Errors halt iteration immediately.

Returns

Find / findEachPage callbacks return sensor models and pagination info.

Sensor fields (Java)

SensorValue

FindOptions parameters

Notes: filters combine with AND; server may cap page size; same options also apply to the Machines service.

IoTQueryOptions (Java) – fluent setters

IoT Data

// Query last values by sensor with filters
var q = SensorsService.IoTQueryOptions.create()
  .perPage(100)
  .sortByDateDesc()
  .start("2024-01-01T00:00:00Z")
  .end("2024-01-02T00:00:00Z");
var resp = client.sensors.getIoTData("sensor-1", q);
// Changes endpoint
var changes = client.sensors.getIoTDataChanges("sensor-1", q);
if (resp != null && resp.items != null) {
  resp.items.forEach(rec -> {
    // rec.timestamp, rec.value, rec.metadata
  });
}

Returns

IoTDataRecord (Java)

IoTDataMetadata
IoTDataChangeMeta

Machines Listing

var mo = new com.seshat.sdk.services.MachinesService.FindOptions().tag("production");
var res = client.machines.find(mo);
if (res != null) {
  var list = res.data; var total = res.total;
}

Machines functions parallel Sensors: single find() for one page; paging helpers (if exposed) follow the same page iteration semantics. Filters combine via AND; empty values omitted. Use to collect inventory of machine IDs prior to sensor queries.

FindOptions summary

Order and behavior match Sensors FindOptions.

Returns

Machine struct fields (Java)

Live

// Basic live streaming (simple stream)
client.live.addListener(new com.seshat.sdk.live.SensorsLiveStream.Listener(){
  @Override public void onValue(seshat.v1.Seshat.ReadValueResponse v){
    System.out.println(v.getSensorId()+" -> type="+v.getType());
  }
  @Override public void onError(Throwable t){ t.printStackTrace(); }
  @Override public void onCompleted(){ System.out.println("live completed"); }
});
client.live.start(java.util.List.of("sensor123", "sensor456"));

Data Types (type id → Java value)

The type argument in the live callback maps to deserialized Java values:

Unsigned numeric types are widened; if you require exact unsigned semantics, treat them as raw JSON and convert manually.

Connections

Each sensor is linked to a connection. The endpoints a sensor reads from or writes to are called connections (for example an MQTT client or a PostgreSQL database). To publish data to an MQTT connection, you can use advanced write to set payload type and parameters like topic.

// Advanced: boolean write with 'topic' parameter
var adv = new com.seshat.sdk.services.ConnectionsService.AdvancedItem();
adv.anyValue = java.util.Map.of("value", true); // original object (also serialized)
adv.typeOverride = 16; // bool
var p = new com.seshat.sdk.services.ConnectionsService.Parameter();
p.key = "topic"; p.value = "67333c8d615f8c6cd6f07c38/67333c8d615f8c6cd6f07c39".getBytes();
adv.parameters = java.util.List.of(p);
client.connections.writeAdvanced("mqtt://0.0.0.0:8888", java.util.List.of(adv));

// Restart connection
client.connections.restart("mqtt://0.0.0.0:8888");

Events

var resp = client.events.trigger("rebuild-cache", java.util.Map.of("fast", true));
var list = client.events.list();

Error handling

try {
  var fo = client.sensors.findOpts().name("temp");
  var res = client.sensors.find(fo);
} catch (IOException e) {
  // log + retry/backoff
}

try {
  var q = SensorsService.IoTQueryOptions.create().perPage(100).sortByDateDesc();
  var data = client.sensors.getIoTData("sensor123", q);
} catch (IOException e) {
  // network / server error
}