### Release Priority Level (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This example demonstrates how to release a priority level for a writable point by writing a null value. This effectively relinquishes control at that specific priority. ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who @thermostat.tempSp,N,8,"Alice"' ``` -------------------------------- ### Haystack HTTP API: Read Operation (Filter Query - Bash and Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt Illustrates querying Haystack entities using filter expressions via the HTTP API's 'Read' operation. Shows cURL examples for GET and POST requests with different filter criteria and serialization formats (JSON and Zinc), along with example filter expressions. ```bash # Query all sites curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/json" # Query points with specific conditions curl -X GET "https://server/haystack/read?filter=point%20and%20temp%20and%20sensor" \ -H "Accept: application/json" # POST request with filter and limit (Zinc format) curl -X POST "https://server/haystack/read" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0"\nfilter,limit\n"equip and hvac and siteRef==@site-123",100' # Response (Zinc) ver:"3.0" id,dis,equip,hvac,ahu,siteRef @ahu-1,"AHU-1",M,M,M,@site-123 @ahu-2,"AHU-2",M,M,M,@site-123 # Filter expression examples site // Has site marker tag equip and hvac // Has both equip AND hvac tags point and not temp // Has point but NOT temp tag curVal > 75 // curVal greater than 75 curVal >= 72°F // With unit (must match exactly) geoCity == "Chicago" // String equality siteRef->geoCity == "Chicago" // Dereference ref to check nested value ``` -------------------------------- ### Read Point Write Priority Array (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This example demonstrates how to read the current priority array state for a writable point. The request specifies the point ID, and the response details the values and sources at each priority level. ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" id @thermostat.tempSp' ``` -------------------------------- ### Create Real-time Watch Subscription (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This example shows how to create a real-time subscription to monitor point value changes using the watchSub operation. It specifies the Haystack version, a display name for the watch, a lease duration, and the IDs of the points to monitor. The response includes a watchId for subsequent operations. ```bash curl -X POST "https://server/haystack/watchSub" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" watchDis:"MyApp Monitor" lease:5min id @vav-101.zoneTemp @vav-101.damperCmd @vav-102.zoneTemp' ``` -------------------------------- ### Haystack Filter Query Language Examples Source: https://context7.com/project-haystack/haystack-defs/llms.txt Demonstrates the declarative filter language used in Haystack for querying entities. It supports tag presence/absence, equality and numeric comparisons (with units), logical operators, and reference traversal. ```text // Tag presence (has tag) site // All entities with site marker equip // All equipment point and sensor // Points that are sensors // Tag absence not temp // Missing temp tag point and not his // Points without history // Equality comparisons geoCity == "Chicago" // Exact string match kind == "Number" // Match kind value curStatus == "ok" // Status check // Numeric comparisons (unit must match exactly) curVal > 75 // Greater than (unitless) curVal >= 72°F // With unit curVal < 100kW // Less than area <= 50000ft² // Less or equal // Logical operators site or equip // Either tag equip and hvac // Both tags equip and hvac and not ahu // Complex logic (temp or humidity) and sensor // Parentheses for grouping // Reference traversal (dereference) siteRef->geoCity == "Chicago" // Follow ref, check nested value equipRef->siteRef->dis == "HQ" // Multi-level traversal siteRef->weatherStationRef->tz == "New_York" // Deep path // Combining patterns point and sensor and siteRef->geoCity == "Chicago" and curVal > 70 equip and elec and meter and siteRef == @main-site ``` -------------------------------- ### Serialize Grids with JSON Format Source: https://context7.com/project-haystack/haystack-defs/llms.txt Serializes grids using JSON, preserving full type fidelity through the `_kind` discriminator pattern. This example demonstrates a grid representing equipment with metadata and typed values. ```json { "_kind": "grid", "meta": { "ver": "3.0", "database": "production", "dis": "Equipment List" }, "cols": [ { "name": "dis", "meta": { "dis": "Display Name" } }, { "name": "equip" }, { "name": "siteRef", "meta": { "dis": "Site" } }, { "name": "installed" } ], "rows": [ { "dis": "RTU-1", "equip": { "_kind": "marker" }, "siteRef": { "_kind": "ref", "val": "site-a", "dis": "HQ" }, "installed": { "_kind": "date", "val": "2005-06-01" } }, { "dis": "RTU-2", "equip": { "_kind": "marker" }, "siteRef": { "_kind": "ref", "val": "site-a", "dis": "HQ" }, "installed": { "_kind": "date", "val": "1999-07-12" } }, { "dis": "Chiller-1", "equip": { "_kind": "marker" }, "siteRef": { "_kind": "ref", "val": "site-b", "dis": "Branch" }, "installed": { "_kind": "date", "val": "2010-03-15" } } ] } ``` -------------------------------- ### Haystack HTTP API: About Operation (Bash and JSON) Source: https://context7.com/project-haystack/haystack-defs/llms.txt Demonstrates how to query basic server information using the Haystack HTTP API's 'About' operation. Includes a cURL command for a GET request and the expected JSON response structure containing server metadata. ```bash # GET request (no authentication shown for brevity) curl -X GET "https://server/haystack/about" \ -H "Accept: application/json" # Response (JSON) { "_kind": "grid", "meta": { "ver": "3.0" }, "cols": [ { "name": "haystackVersion" }, { "name": "tz" }, { "name": "serverName" }, { "name": "serverTime" }, { "name": "productName" }, { "name": "productVersion" } ], "rows": [{ "haystackVersion": "4.0", "tz": "New_York", "serverName": "Demo Server", "serverTime": { "_kind": "dateTime", "val": "2024-01-15T10:30:00-05:00", "tz": "New_York" }, "productName": "Acme Haystack Server", "productVersion": "2.1.0" }] } ``` -------------------------------- ### Site Entity Model (JSON) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This example shows the equivalent of the Trio Site entity definition, but represented in JSON format. It uses Haystack's JSON encoding for entities, including nested objects for references, numbers with units, and coordinates. ```json { "id": { "_kind": "ref", "val": "whitehouse", "dis": "White House" }, "dis": "White House", "site": { "_kind": "marker" }, "area": { "_kind": "number", "val": 55000, "unit": "ft²" }, "tz": "New_York", "weatherStationRef": { "_kind": "ref", "val": "weather.washington" }, "yearBuilt": 1792, "geoAddr": "1600 Pennsylvania Avenue NW, Washington, DC", "geoCity": "Washington D.C.", "geoCountry": "US", "geoCoord": { "_kind": "coord", "lat": 38.898, "lng": -77.037 } } ``` -------------------------------- ### Serialize Grids with Zinc Format Source: https://context7.com/project-haystack/haystack-defs/llms.txt Serializes tabular data using Zinc, a typed CSV format that supports metadata at grid and column levels. Examples include basic grids, nested structures, sparse data, error responses, and incomplete data. ```zinc // Basic grid with metadata ver:"3.0" database:"production" dis:"Equipment List" dis dis:"Display Name",equip,siteRef dis:"Site",installed "RTU-1",M,@site-a "HQ",2005-06-01 "RTU-2",M,@site-a "HQ",1999-07-12 "Chiller-1",M,@site-b "Branch",2010-03-15 // Grid with nested structures ver:"3.0" type,val "list",[1,2,3] "dict",{dis:"Example" foo bar:123} "nested grid",<< ver:"3.0" a,b 1,2 3,4 >> // Sparse data with nulls ver:"3.0" id,dis,curVal,curStatus @point-1,"Temp Sensor",72.5°F,"ok" @point-2,"Humidity",N,"fault" @point-3,"Pressure",29.92inHg,N // Error grid response ver:"3.0" err dis:"Cannot resolve id: badId" errTrace:"UnknownRecErr: badId\n at Server.read..." empty // Incomplete data response (throttled) ver:"3.0" incomplete:{dis:"Request timeout exceeded!" timeout:1min} ts,val 2024-01-15T00:00:00-05:00 New_York,72.1°F 2024-01-15T00:15:00-05:00 New_York,72.3°F ``` -------------------------------- ### Read Operation (Filter Query) Source: https://context7.com/project-haystack/haystack-defs/llms.txt Queries entities using filter expressions. This operation supports tag presence checks, comparison operators, and logical operators (and, or, not). It can be used with GET or POST requests. ```APIDOC ## GET /haystack/read (Filter Query) ## POST /haystack/read (Filter Query) ### Description Query entities using filter expressions. Supports tag presence checks, comparison operators, and logical operators (and, or, not). ### Method GET or POST ### Endpoint /haystack/read ### Parameters #### Query Parameters (for GET requests) - **filter** (string) - Required - The filter expression to select entities. - **limit** (number) - Optional - The maximum number of results to return. #### Request Body (for POST requests) - **filter** (string) - Required - The filter expression to select entities. - **limit** (number) - Optional - The maximum number of results to return. ### Request Example ```bash # GET request to query all sites curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/json" # GET request to query points with specific conditions curl -X GET "https://server/haystack/read?filter=point%20and%20temp%20and%20sensor" \ -H "Accept: application/json" # POST request with filter and limit (Zinc format) curl -X POST "https://server/haystack/read" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" filter,limit "equip and hvac and siteRef==@site-123",100' ``` ### Response #### Success Response (200) - The response format depends on the `Accept` header (e.g., JSON, Zinc). - Returns a grid of entities matching the filter criteria. - **id** (Ref) - The unique identifier of the entity. - **dis** (Str) - The display name of the entity. - Other columns represent tags present on the matched entities. #### Response Example (Zinc) ```zinc ver:"3.0" id,dis,equip,hvac,ahu,siteRef @ahu-1,"AHU-1",M,M,M,@site-123 @ahu-2,"AHU-2",M,M,M,@site-123 ``` ### Filter Expression Examples - `site` - `equip and hvac` - `point and not temp` - `curVal > 75` - `curVal >= 72°F` - `geoCity == "Chicago"` - `siteRef->geoCity == "Chicago"` ``` -------------------------------- ### HisRead Operation - Single Point (GET/POST) Source: https://context7.com/project-haystack/haystack-defs/llms.txt Reads time-series history data for a single point. Supports various range formats including 'today', 'yesterday', specific dates, and datetime ranges. Can be performed via GET or POST requests, with Zinc being a common format for POST. ```bash # GET request for yesterday's data curl -X GET "https://server/haystack/hisRead?id=@outsideAirTemp&range=yesterday" \ -H "Accept: application/json" ``` ```bash # POST request with date range (Zinc) curl -X POST "https://server/haystack/hisRead" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" id,range @sensor-123,"2024-01-01,2024-01-02"' ``` ```zinc ver:"3.0" id:@sensor-123 hisStart:2024-01-01T00:00:00-05:00 New_York hisEnd:2024-01-02T00:00:00-05:00 New_York ts,val 2024-01-01T00:15:00-05:00 New_York,68.2°F 2024-01-01T00:30:00-05:00 New_York,68.5°F 2024-01-01T00:45:00-05:00 New_York,69.1°F 2024-01-01T01:00:00-05:00 New_York,69.4°F ``` -------------------------------- ### Haystack Defs, Ops, Filetypes, and Libs Operations Source: https://context7.com/project-haystack/haystack-defs/llms.txt Demonstrates API calls to query ontology definitions (defs), operations (ops), available file types, and library information from a Haystack server. These operations are crucial for understanding the server's capabilities and data semantics. ```bash # Query all defs curl -X GET "https://server/haystack/defs" \ -H "Accept: text/zinc" # Query specific def by filter curl -X POST "https://server/haystack/defs" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" filter "def==^point"' # Response ver:"3.0" def,lib,is,mandatory,docTaxonomy,doc ^point,^lib:phIoT,[^entity],M,M,"Data point such as a sensor or actuator." # Query ops definitions curl -X GET "https://server/haystack/ops" \ -H "Accept: application/json" # Query available file types curl -X GET "https://server/haystack/filetypes" \ -H "Accept: application/json" # Query library definitions curl -X GET "https://server/haystack/libs" \ -H "Accept: application/json" ``` -------------------------------- ### About Operation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Retrieves basic server information, including version, timezone, and product details. This operation returns a single-row grid containing server metadata. ```APIDOC ## GET /haystack/about ### Description Query basic server information including version, timezone, and product details. Returns a single-row grid with server metadata. ### Method GET ### Endpoint /haystack/about ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://server/haystack/about" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **_kind** (string) - Indicates the response is a grid. - **meta** (object) - Contains metadata about the grid, including version. - **cols** (array) - An array of column definitions. - **rows** (array) - An array containing a single row with server metadata. - **haystackVersion** (string) - The version of Haystack supported. - **tz** (string) - The server's default timezone. - **serverName** (string) - The name of the server. - **serverTime** (object) - The current server time, including timezone. - **productName** (string) - The name of the product running on the server. - **productVersion** (string) - The version of the product. #### Response Example ```json { "_kind": "grid", "meta": { "ver": "3.0" }, "cols": [ { "name": "haystackVersion" }, { "name": "tz" }, { "name": "serverName" }, { "name": "serverTime" }, { "name": "productName" }, { "name": "productVersion" } ], "rows": [{ "haystackVersion": "4.0", "tz": "New_York", "serverName": "Demo Server", "serverTime": { "_kind": "dateTime", "val": "2024-01-15T10:30:00-05:00", "tz": "New_York" }, "productName": "Acme Haystack Server", "productVersion": "2.1.0" }] } ``` ``` -------------------------------- ### Haystack Content Negotiation with HTTP Accept Header Source: https://context7.com/project-haystack/haystack-defs/llms.txt Shows how to request different data formats (Zinc, JSON, Trio, CSV, RDF) from a Haystack server using the HTTP Accept header. The default format is Zinc. ```bash # Request Zinc format (default) curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/zinc" # Request JSON format (Haystack 4) curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/json" # Request JSON format (Haystack 3 legacy) curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/vnd.haystack+json;version=3" # Request Trio format curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/trio" # Request CSV format (type info is lost) curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/csv" # CSV response example dis,area,geoAddr Site A,2000ft²,"1000 Main St,Richmond,VA" Site B,3000ft²,"2000 Cary St,Richmond,VA" # Request RDF Turtle format curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/turtle" # Request JSON-LD format curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/ld+json" ``` -------------------------------- ### Defs Operation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Query ontology definitions (defs) from the server's namespace. Defs define the semantics for all tags in the ontology. Also includes endpoints for querying operations, file types, and libraries. ```APIDOC ## Defs Operation ### Description Query ontology definitions from the server's namespace. Defs define the semantics for all tags in the ontology. This section also covers querying operations, available file types, and library definitions. ### Endpoints **Query all defs:** ```bash curl -X GET "https://server/haystack/defs" \ -H "Accept: text/zinc" ``` **Query specific def by filter (POST with Zinc body):** ```bash curl -X POST "https://server/haystack/defs" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" filter "def==^point"' ``` **Response Example (for specific def query):** ``` ver:"3.0" def,lib,is,mandatory,docTaxonomy,doc ^point,^lib:phIoT,[^entity],M,M,"Data point such as a sensor or actuator." ``` **Query ops definitions:** ```bash curl -X GET "https://server/haystack/ops" \ -H "Accept: application/json" ``` **Query available file types:** ```bash curl -X GET "https://server/haystack/filetypes" \ -H "Accept: application/json" ``` **Query library definitions:** ```bash curl -X GET "https://server/haystack/libs" \ -H "Accept: application/json" ``` ``` -------------------------------- ### WatchSub Operation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Creates real-time subscriptions to monitor point value changes using stateful polling. ```APIDOC ## POST /haystack/watchSub ### Description Creates real-time subscriptions to monitor point value changes. Watches use stateful polling for efficient HTTP-based real-time data. ### Method POST ### Endpoint /haystack/watchSub ### Parameters #### Request Body - **ver** (string) - Required - Version of the protocol, e.g., "3.0". - **watchDis** (string) - Optional - Display name for the watch. - **lease** (string) - Optional - Duration for the watch lease, e.g., "5min". - **watchId** (string) - Optional - Identifier for an existing watch to add points to. - **id** (string) - Required - The identifier of the point to watch, e.g., "@vav-101.zoneTemp". Can be a list of IDs. ### Request Example (Create new watch) ```bash curl -X POST "https://server/haystack/watchSub" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" watchDis:"MyApp Monitor" lease:5min id @vav-101.zoneTemp @vav-101.damperCmd @vav-102.zoneTemp' ``` ### Request Example (Add points to existing watch) ```bash curl -X POST "https://server/haystack/watchSub" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" watchId:"w-abc123" id @vav-103.zoneTemp' ``` ### Response #### Success Response (200) - **ver** (string) - Protocol version. - **watchId** (string) - Unique identifier for the watch. - **lease** (string) - Duration of the watch lease. - **id** (string) - Identifier of the watched point. - **dis** (string) - Display name of the watched point. - **curVal** (any) - Current value of the watched point. - **curStatus** (string) - Current status of the watched point. #### Response Example ```zinc ver:"3.0" watchId:"w-abc123" lease:5min id,dis,curVal,curStatus @vav-101.zoneTemp,"VAV-101 ZoneTemp",72.4°F,"ok" @vav-101.damperCmd,"VAV-101 DamperCmd",45%,"ok" @vav-102.zoneTemp,"VAV-102 ZoneTemp",71.8°F,"ok" ``` ``` -------------------------------- ### Site Entity Model (Trio) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This snippet defines a Site entity using Trio syntax. It includes common properties like ID, display name, site marker, area, timezone, weather station reference, year built, address details, and geographic coordinates. ```trio // Site entity in Trio format id: @whitehouse dis: "White House" site area: 55000ft² tz: "New_York" weatherStationRef: @weather.washington yearBuilt: 1792 geoAddr: "1600 Pennsylvania Avenue NW, Washington, DC" geoStreet: "1600 Pennsylvania Ave NW" geoCity: "Washington D.C." geoCountry: "US" geoPostalCode: "20500" geoCoord: C(38.898,-77.037) ``` -------------------------------- ### Content Negotiation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Request different response formats using the HTTP Accept header. Supported formats include Zinc (default), JSON, Trio, CSV, and RDF. ```APIDOC ## Content Negotiation ### Description Request different response formats using the HTTP Accept header. Default is Zinc; JSON, Trio, CSV, and RDF formats are also supported. ### Method GET ### Endpoint `/haystack/read?filter=` ### Headers `Accept`: Specifies the desired response format. ### Examples **Request Zinc format (default):** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/zinc" ``` **Request JSON format (Haystack 4):** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/json" ``` **Request JSON format (Haystack 3 legacy):** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/vnd.haystack+json;version=3" ``` **Request Trio format:** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/trio" ``` **Request CSV format:** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/csv" ``` **CSV response example:** ```csv dis,area,geoAddr Site A,2000ft²,"1000 Main St,Richmond,VA" Site B,3000ft²,"2000 Cary St,Richmond,VA" ``` **Request RDF Turtle format:** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: text/turtle" ``` **Request JSON-LD format:** ```bash curl -X GET "https://server/haystack/read?filter=site" \ -H "Accept: application/ld+json" ``` ``` -------------------------------- ### Site Entity Model Source: https://context7.com/project-haystack/haystack-defs/llms.txt Represents buildings and physical locations with geolocation, timezone, and weather station references. ```APIDOC ## Site Entity Model ### Description Models buildings and physical locations with geolocation, timezone, and weather station references. ### Method N/A (This describes a data model, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example (Trio format) ```trio // Site entity in Trio format id: @whitehouse dis: "White House" site area: 55000ft² tz: "New_York" weatherStationRef: @weather.washington yearBuilt: 1792 geoAddr: "1600 Pennsylvania Avenue NW, Washington, DC" geoStreet: "1600 Pennsylvania Ave NW" geoCity: "Washington D.C." geoCountry: "US" geoPostalCode: "20500" geoCoord: C(38.898,-77.037) ``` ### Request Example (JSON format) ```json { "id": { "_kind": "ref", "val": "whitehouse", "dis": "White House" }, "dis": "White House", "site": { "_kind": "marker" }, "area": { "_kind": "number", "val": 55000, "unit": "ft²" }, "tz": "New_York", "weatherStationRef": { "_kind": "ref", "val": "weather.washington" }, "yearBuilt": 1792, "geoAddr": "1600 Pennsylvania Avenue NW, Washington, DC", "geoCity": "Washington D.C.", "geoCountry": "US", "geoCoord": { "_kind": "coord", "lat": 38.898, "lng": -77.037 } } ``` ### Response #### Success Response (200) - **(This is a data model, not an API response. Data conforming to this model would be returned by relevant API endpoints.)** #### Response Example ```json { "example": "(See JSON format example above)" } ``` ``` -------------------------------- ### Write Value to Priority Level (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This command shows how to write a value to a specific priority level of a writable point. It includes the point ID, the value to write, the target priority level, and an optional source identifier. ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who @thermostat.tempSp,72°F,16,"Energy App"' ``` -------------------------------- ### Define Equipment Entities in Trio Source: https://context7.com/project-haystack/haystack-defs/llms.txt Models physical assets such as meters, air handlers, and chillers using site containment and equipment nesting. This format is specific to the Trio language. ```trio // Electric meter equipment id: @site.mainMeter dis: "Main Elec Meter" ac elec meter equip siteMeter siteRef: @site spaceRef: @site.utility-closet --- // Chilled water plant (logical grouping) id: @site.chillerPlant dis: "Chiller Plant" chilled water plant equip siteRef: @site --- // Chiller nested under plant id: @site.chiller3 dis: "Chiller-3" chiller equip siteRef: @site equipRef: @site.chillerPlant --- // Air handler unit id: @site.ahu1 dis: "AHU-1" ahu equip hvac siteRef: @site spaceRef: @site.mechanicalRoom ``` -------------------------------- ### Add Points to Existing Watch (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This command demonstrates how to add more points to an already established watch subscription. It uses the existing watchId and specifies the new point IDs to be included in the monitoring. ```bash curl -X POST "https://server/haystack/watchSub" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" watchId:"w-abc123" id @vav-103.zoneTemp' ``` -------------------------------- ### Timed Override with Duration (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This command illustrates how to set a timed override for a priority level. It includes the point ID, value, priority level, source, and a duration for which the override should remain active. ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who,duration @thermostat.tempSp,74°F,8,"Manual",2hr' ``` -------------------------------- ### WatchUnsub Operation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Closes an existing watch subscription. ```APIDOC ## POST /haystack/watchUnsub ### Description Closes an existing watch subscription. ### Method POST ### Endpoint /haystack/watchUnsub ### Parameters #### Request Body - **ver** (string) - Required - Version of the protocol, e.g., "3.0". - **watchId** (string) - Required - Identifier of the watch to close. - **close** (marker) - Required - Indicates the action to close the watch. - **id** (string) - Optional - Can be used to specify which points to unsubscribe from within a watch, or empty to close the entire watch. ### Request Example ```bash curl -X POST "https://server/haystack/watchUnsub" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" watchId:"w-abc123" close id' ``` ### Response #### Success Response (200) - **(Typically a success confirmation, no specific fields defined in the example.)** #### Response Example ```json { "example": "(Success response structure not provided in the input)" } ``` ``` -------------------------------- ### PointWrite Operation Source: https://context7.com/project-haystack/haystack-defs/llms.txt Commands writable points using a 16-level priority array. Supports reading current state, writing values, and releasing priorities. ```APIDOC ## POST /haystack/pointWrite ### Description Commands writable points using a 16-level priority array. Level 1 is highest priority; level 17 is relinquish default. Supports reading current priority array state, writing values, and releasing priorities. ### Method POST ### Endpoint /haystack/pointWrite ### Parameters #### Request Body - **ver** (string) - Required - Version of the protocol, e.g., "3.0". - **id** (string) - Required - The identifier of the point, e.g., "@thermostat.tempSp". - **val** (any) - Optional - The value to write to the point. Use 'N' for null/release. - **level** (number) - Optional - The priority level to write to (1-17). - **who** (string) - Optional - Identifier for who is performing the write operation. - **duration** (string) - Optional - Duration for a timed override, e.g., "2hr". ### Request Example (Read current priority array) ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -H "Accept: text/zinc" \ -d 'ver:"3.0" id @thermostat.tempSp' ``` ### Request Example (Write value to priority level 16) ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who @thermostat.tempSp,72°F,16,"Energy App"' ``` ### Request Example (Release priority level 8) ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who @thermostat.tempSp,N,8,"Alice"' ``` ### Request Example (Timed override on level 8) ```bash curl -X POST "https://server/haystack/pointWrite" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" id,val,level,who,duration @thermostat.tempSp,74°F,8,"Manual",2hr' ``` ### Response #### Success Response (200) - **ver** (string) - Protocol version. - **level** (number) - The priority level. - **levelDis** (string) - Display name of the priority level. - **val** (any) - The value at that priority level. - **who** (string) - Identifier of who set the value at that priority level. #### Response Example (Priority Array State) ```zinc ver:"3.0" level,levelDis,val,who 1,"Emergency Override",N,N 2,N,N,N 8,"Manual Override",72°F,"Alice" 14,N,N,N 15,N,N,N 16,"Scheduler",70°F,"Schedule App" 17,"Default",68°F,N ``` ``` -------------------------------- ### Filter Query Language Source: https://context7.com/project-haystack/haystack-defs/llms.txt Entities can be queried using a declarative filter language that supports tag presence, absence, equality comparisons, numeric comparisons with units, logical operators, and reference traversal. ```APIDOC ## Filter Query Language ### Description Query entities using a declarative filter language with tag presence, comparisons, and logical operators. ### Examples **Tag Presence:** ``` site equip point and sensor ``` **Tag Absence:** ``` not temp point and not his ``` **Equality Comparisons:** ``` geoCity == "Chicago" kind == "Number" curStatus == "ok" ``` **Numeric Comparisons:** ``` curVal > 75 curVal >= 72°F curVal < 100kW area <= 50000ft² ``` **Logical Operators:** ``` site or equip equip and hvac equip and hvac and not ahu (temp or humidity) and sensor ``` **Reference Traversal:** ``` siteRef->geoCity == "Chicago" equipRef->siteRef->dis == "HQ" siteRef->weatherStationRef->tz == "New_York" ``` **Combining Patterns:** ``` point and sensor and siteRef->geoCity == "Chicago" and curVal > 70 equip and elec and meter and siteRef == @main-site ``` ``` -------------------------------- ### Haystack Data Types (Kinds) in Zinc and JSON Source: https://context7.com/project-haystack/haystack-defs/llms.txt Demonstrates the scalar and collection data types defined by Project Haystack, shown in both Zinc and JSON formats. These types extend standard JSON to include units, timezones, references, and markers for interoperable data exchange. ```zinc // Scalar Types in Zinc format N // Null M // Marker (label/type tag) T // Bool true F // Bool false 123 // Number (unitless) 72.5°F // Number with unit "hello world" // Str (string) `http://example.com/` // Uri @abc-123 // Ref (entity reference) @abc-123 "Display Name" // Ref with display name ^hot-water // Symbol (def identifier) 2024-01-15 // Date 14:30:00 // Time 2024-01-15T14:30:00-05:00 New_York // DateTime with timezone C(37.545,-77.449) // Coord (latitude, longitude) NA // NA (not available) // Collection Types [1, 2, "three", 4.0°C] // List {dis:"Building" site area:35000ft²} // Dict (dictionary) ``` ```json // JSON equivalents { "_kind": "marker" } // Marker { "_kind": "number", "val": 72.5, "unit": "°F" } // Number with unit { "_kind": "ref", "val": "abc-123", "dis": "Main Meter" } // Ref { "_kind": "dateTime", "val": "2024-01-15T14:30:00-05:00", "tz": "New_York" } // DateTime { "_kind": "coord", "lat": 37.545, "lng": -77.449 } // Coord ``` -------------------------------- ### Poll for Watch Changes (Zinc) Source: https://context7.com/project-haystack/haystack-defs/llms.txt This snippet illustrates how to poll for changes in a watch subscription. The first command polls for only changed entities, while the second command requests a full refresh, returning all watched entities regardless of changes. ```bash # Poll for changes (only returns changed entities) curl -X POST "https://server/haystack/watchPoll" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" watchId:"w-abc123" empty' # Poll with full refresh (returns all watched entities) curl -X POST "https://server/haystack/watchPoll" \ -H "Content-Type: text/zinc; charset=utf-8" \ -d 'ver:"3.0" watchId:"w-abc123" refresh empty' ``` -------------------------------- ### Read by Multiple IDs (JSON) Source: https://context7.com/project-haystack/haystack-defs/llms.txt Performs a POST request to read data for multiple point IDs simultaneously. The request body specifies the grid structure with an array of IDs to retrieve. The response is also a grid, potentially containing null rows for IDs not found. ```bash curl -X POST "https://server/haystack/read" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "_kind": "grid", "meta": { "ver": "3.0" }, "cols": [{ "name": "id" }], "rows": [ { "id": { "_kind": "ref", "val": "vav-101" } }, { "id": { "_kind": "ref", "val": "vav-102" } }, { "id": { "_kind": "ref", "val": "vav-103" } } ]' ``` ```json { "_kind": "grid", "meta": { "ver": "3.0" }, "cols": [ { "name": "id" }, { "name": "dis" }, { "name": "curVal" } ], "rows": [ { "id": { "_kind": "ref", "val": "vav-101" }, "dis": "VAV-101 ZoneTemp", "curVal": { "_kind": "number", "val": 72.4, "unit": "°F" } }, { "id": null, "dis": null, "curVal": null }, { "id": { "_kind": "ref", "val": "vav-103" }, "dis": "VAV-103 ZoneTemp", "curVal": { "_kind": "number", "val": 71.8, "unit": "°F" } } ] } ``` -------------------------------- ### Define Point Entities in Trio Source: https://context7.com/project-haystack/haystack-defs/llms.txt Models sensors, setpoints, and commands, specifying containment, kind, and real-time/historical capabilities. This format is specific to the Trio language. ```trio // Temperature sensor point id: @whitehouse.ahu3.dat dis: "White House AHU-3 DischargeAirTemp" discharge air temp sensor point cur his siteRef: @whitehouse equipRef: @whitehouse.ahu3 kind: "Number" unit: "°F" tz: "New_York" curVal: 55.2°F curStatus: "ok" hisStatus: "ok" --- // Writable command point (fan run) id: @site.ahu1.fanRun dis: "AHU-1 Fan Run" fan run cmd point writable siteRef: @site equipRef: @site.ahu1 kind: "Bool" enum: "off,on" writeVal: T writeLevel: 16 writeStatus: "ok" --- // Zone temperature setpoint with history id: @room706.tempSp dis: "Room 706 Temp Setpoint" effective zone air temp sp point his siteRef: @site spaceRef: @room706 equipRef: @room706.thermostat kind: "Number" unit: "°C" tz: "London" minVal: 15°C maxVal: 28°C hisMode: "cov" ```