[OH4] Formlabs SLA printer via HTTP binding

In October Formlabs released self-hostable server software (PreFormServer) which communicates with Formlabs printers on the same network and allows other devices to interrogate the printers via a REST API. Further detail and software downloads can be found here.

Assuming the server software is running, obtaining basic information about the printers via JSON is relatively easy with the HTTP binding. Below is an example JSON data package provided by the API during a print:

{
    "cartridge_data": {
        "4c-0000005bfccc": {
            "cartridgeEstimatedVolumeDispensed_mL": 3.3,
            "cartridgeMaterialCode": "FLTO2001",
            "cartridgeOriginalVolume_mL": 1000
        }
    },
    "connection_type": "WIFI",
    "estimated_print_time_remaining_ms": 12540660.950245794,
    "firmware_version": "2.4.0-2216",
    "form_auto_status": "",
    "id": "ColdKoala",
    "ip_address": "192.168.1.14",
    "is_connected": true,
    "is_remote_print_enabled": false,
    "product_name": "Form 3+",
    "ready_to_print_now": false,
    "status": "Printing",
    "tank_id": "4c-000000b42564",
    "tank_material_code": "FLTO2001"
}

Note that status can have the following values (that we have experienced so far):

  • Printing
  • Idle - not printing, but also not ready to print. Shown when a print has finished.
  • Ready to print - when the printer is available to receive a print and start printing automatically

Prerequisites

  • Formlabs PreFormServer background application running inside the same network as openHAB
  • openHAB with
    • HTTP Binding
    • JSONPATH and MAP Transformation Services

Things

  • Ensure that the IP address in baseURL is that of the device that is running PreFormServer, not the IP address of the printer.
  • Within the same URL, ensure that the name of the printer is correctly capitalised.
UID: http:url:ColdKoalaData
label: Cold Koala Data
thingTypeUID: http:url
configuration:
  authMode: DIGEST
  ignoreSSLErrors: true
  baseURL: http://192.168.1.200:44388/devices/ColdKoala
  delay: 0
  stateMethod: GET
  refresh: 30
  userAgent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:133.0) Gecko/20100101
    Firefox/133.0
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
channels:
  - id: last-failure
    channelTypeUID: http:request-date-time
    label: Last Failure
    configuration: {}
  - id: last-success
    channelTypeUID: http:request-date-time
    label: Last Success
    configuration: {}
  - id: status
    channelTypeUID: http:string
    label: Status
    description: ""
    configuration:
      stateTransformation: JSONPATH:$.status
  - id: product_name
    channelTypeUID: http:string
    label: Product name
    description: ""
    configuration:
      stateTransformation: JSONPATH:$.product_name
  - id: estimated_print_time_remaining_ms
    channelTypeUID: http:number
    label: Estimated print time remaining
    description: ""
    configuration:
      stateTransformation: JSONPATH:$.estimated_print_time_remaining_ms
  - id: id
    channelTypeUID: http:string
    label: ID
    description: ""
    configuration:
      stateTransformation: JSONPATH:$.id
  - id: tank_material_code
    channelTypeUID: http:string
    label: Tank material code
    description: ""
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.tank_material_code

Transform

Save the below MAP Transform, and use it as a Profile on the link between the tank_material_code Channel and an Item.

FLGPCL04=Clear V4
FLGPWH04=White V4
FLGPGR04=Grey V4
FLGPBL04=Black V4
FLGPCB01=Color V4
FLDRBL01=Draft V1
FLPRGR01=Grey Pro V1
FLRGWH01=Rigid V1
FLTO2001=Tough 2000 V1
FLTO1501=Tough 1500 V1
FLDUCL02=Durable V2
FLFLGR02=Flexible V2
FLFLGR02=High Temp V2
FLELCL01=Elastic V1
FLDMBE02=Model Resin V2
FLSGAM01=Surgical Guide V1
FLDLCL01=Dental LT Clear V1
FLDTA201=Denture Base V1
FLDBLP01=Denture Teeth V1
FLCWPU01=Castable Wax V1
FLCABL02=Castable V2
FLCEWH01=Ceramic V1
FLRBBL01=Rebound V1
FLHTAM02=High Temp V1
FLRG1001=Rigid 10K V1
NONE=Missing tank
=Unknown

Limitations

  • The server and API is very new, and constantly changing
  • As far as we have found, error states are not transmitted via the API. If a print is automatically stopped due to some error (tank isn’t filling, or resin ran out, for example), the status remains Printing! We have implemented a rule which checks the Item linked to the estimated_print_time_remaining_ms Channel, and if this hasn’t changed within 5 minutes an alert is created.
  • Unlike more open source FDM printers, there doesn’t seem to be a way to interrogate temperatures, nor find out the name of the model that is currently printing.
1 Like

It would be cleaner to chain the transform to the JSONPATH instead of needing to apply a transdorm and a Profile. JSONPATH:$.tank_material_code∩MAP:nameoffile.map. Depending on the OH version you may be able to use , between the transforms instead of . That was a relatively recent addition.