---
# System prepended metadata

title: Water Tower API v3

---

# Water Tower API
[TOC]

## Get water tower list
**GET** /web/water-tower/facilities
[ref.](https://docs.google.com/document/d/1uXYgFEY80dIeCCGTFWyn5DPNa7dB3Fo9IsWBDmwk4K8/edit#heading=h.ef85yb8zdn9w)

### URL Param
- items
help the user to search what data he wants in different columns. Backend will return all types of columns to the frontend.
The searchable fields are as follows
    - location
    - health： good | critical
    - state： active | standby
    - part_number
    - firmware_version
    - group_name
    - facility
    - product_sku
    - identity
    
    E.g.: location=xxx&health=good&state=active&part_number=xxx&firmware_version=xxx

- current_page
Which page the user wants to reference.
E.g.: current_page=1 

- sort
What column the user wants to sort it (asc or desc).
E.g.: sort=location:asc or sort=location:desc

- entries
Which page the user wants to reference.
E.g.: entries=10 

### Response
```json
{
  "entries": 1,
  "current_page": 1,
  "total_page": 1,
  "total_entries": 1,
  "list": [
    {
      "facility_name": "Tower1",
      "ipv4": "xxxx", // for future field
      "product_sku": "LCS-SCLT",
      "group_name": "Taiwan No 1",
        
      "firmware_version": "1.2.22",
      "vendor": "Supermicro",
      "model": "Cooling Tower System",
      "manufacturer": "Supermicro",
      "serial_number": "SN-30912419842",
      "part_number": "PN-LCSA1",   
      "list": [
        {
          // table info
          "id": "1",
          "location": "Tower1.1",
          "locationId": "1",
          "part_number": "LCS-U09238-ABT",
          "firmware_version": "0.4.30",
          "health": "Good", // Good | Critical
          "state": "Active", // Active | Standby
            
          "group_name": "Group 1",
          "facility_name": "B23 3in1",
          "product_sku": "250A-C3-TC",
          "vendor": "Supermicro",
          "model": "Cooling Tower Cell",
          "manufacturer": "Supermicro",
          "serial_number": "SN-3091241984234"
        }
      ]
    },
    {
      // ...similar one
    }
  ]
}
```

## Get Water Tower Tree View Data
Get the water tower tree view data.

### URL
`/web/water-tower/tree`

### Method  
GET

### Login
Required. Yes with token

### Parameter  
None

### Response  



| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "name": "SuperGroup",
  "groups": [
    {
      "group_name": "Default",
      "leaf": false, // reserved property for tree structure
      "uuid": "464758da-6025-11ef-9d94-0242c8a80002",
      "facilities": [
        {
          "facility_name": "B23 3in1",
          "ipv4": "10.147.160.111",
          "product_sku": "250A-C3",
          "vendor": "Supermicro",
          "model": "cooling tower",
          "leaf": false, // reserved property for tree structure

          "manufacturer": "Supermicro",
          "serial_number": "SN-30912419842",
          "part_number": "PN-LCSA1",
          "firmware_version": "0.2.4",
          "health": "Good",
          "towers": [
            {
              "serial_number": "HM19487",
              "part_number": "LCS-U09238-ABT",
              "firmware_version": "1200",
              "locationId": "1",
              "leaf": true, // reserved property for tree structure
                
              "location": "B23 3in1.1",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro",
            },
            {
              "serial_number": "HM19488",
              "part_number": "LCS-U09239-ABT",
              "firmware_version": null,
              "locationId": "2",
              "leaf": true, // reserved property for tree structure
                
              "location": "B23 3in1.2",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro",
            },
            {
              "serial_number": "HM19489",
              "part_number": "LCS-U09240-ABT",
              "firmware_version": "1200",
              "locationId": "3",
              "leaf": true, // reserved property for tree structure
                
              "location": "B23 3in1.3",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro",
            }
          ]
        },
        {
          "facility_name": "Tower2",
          "ipv4": "10.147.173.57",
          "product_sku": "LCS-SCLT",
          "vendor": "Supermicro",
          "model": "cooling tower",
          "leaf": false, // reserved property for tree structure
          "manufacturer": "Supermicro",
          "serial_number": "SN-30912419843",
          "part_number": "PN-LCSA2",
          "firmware_version": "0.2.4",
          "health": "Good",
          "towers": [
            {
              "serial_number": "HM18BS",
              "part_number": "LCS-U09241-ABT",
              "firmware_version": "1200",
              "locationId": "1",
              "leaf": true, // reserved property for tree structure
                
              "location": "Tower2.1",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro",
            }
          ]
        }
        // ...
      ]
    }
    // ...
  ]
}
```

## Search Water Tower Tree View Data
**GET** /web/water-tower/tree/search

### URL Param
- group_name
Search by group name.
E.g.: group_name=Default

- facility_name
Search by facility name.
E.g.: facility_name=f1

- facility_ipv4
Search by facility ipv4.
E.g.: facility_ipv4=123.123.123.123

- tower_location
Search by tower location.
Use facility name and tower location id as key to search.
E.g.: tower_location=f1.1

**Sample**
GET /web/water-tower/tree/search?facility_ipv4=10.147.160.111
```json
{
  "name": "SuperGroup",
  "groups": [
    {
      "group_name": "Default",
      "leaf": false, // reserved property for tree structure
      "uuid": "464758da-6025-11ef-9d94-0242c8a80002",
      "facilities": [
        {
          "facility_name": "B23 3in1",
          "ipv4": "10.147.160.111",
          "product_sku": "250A-C3",
          "vendor": "Supermicro",
          "model": "cooling tower",
          "leaf": false, // reserved property for tree structure

          "manufacturer": "Supermicro",
          "serial_number": "SN-30912419842",
          "part_number": "PN-LCSA1",
          "firmware_version": "0.2.4",
          "health": "Good",
          "towers": [
            {
              "serial_number": "HM19487",
              "part_number": "LCS-U09238-ABT",
              "firmware_version": "1200",
              "locationId": "1",
              "leaf": true, // reserved property for tree structure

              "location": "B23 3in1.1",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro"
            },
            {
              "serial_number": "HM19488",
              "part_number": "LCS-U09239-ABT",
              "firmware_version": null,
              "locationId": "2",
              "leaf": true, // reserved property for tree structure

              "location": "B23 3in1.2",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro"
            },
            {
              "serial_number": "HM19489",
              "part_number": "LCS-U09240-ABT",
              "firmware_version": "1200",
              "locationId": "3",
              "leaf": true, // reserved property for tree structure

              "location": "B23 3in1.3",
              "health": "Good",
              "state": "Inactive",
              "product_sku": "250A-C3-TC",
              "vendor": "Supermicro",
              "model": "Cooling Tower Cell",
              "manufacturer": "Supermicro"
            }
          ]
        }
        // ...
      ]
    }
    // ...
  ]
}
```

## Check Water Tower Facility Name Exist
**GET** /web/water-tower/facilities/check-name-exist

### URL Param
- identity
Facility name.
E.g.: identity=Facility1

### Response
```json
{
  "result": true,
  "ipv4": "10.147.173.58",
}
```

## Add Water Tower Facility
**POST** /web/water-tower/facilities
* Need to record the action in the activity log.

### Request body
Pass facility level structure to backend.
```json
{
  "list": [
    {
      "group_name": "Group Name",
      "facility_name": "Facility1",
      "ipv4": "10.147.173.58",
      "username": "Admin",
      "password": "Tower@1"
      
    },
    {
      "group_name": "Group Name",
      "facility_name": "Facility2",
      "ipv4": "10.147.173.61",
      "username": "Admin",
      "password": "Tower@1"
    }
  ]
}
```
### Response
Return tower level add operation response.
```json
{
  "list": [
    { "facility_name": "Facility1", "result": "Success", "reason": "" },
    { "facility_name": "Facility2", "result": "Failed", "reason": "some reason" }
  ]
}
```

## Update Water Tower Facility
**PATCH** /web/water-tower/facilities/{facility_ip}
* Need to record the action in the activity log.

### Request body
Pass facility level structure to backend.
```json
{
  "facility_name": "New Facility Name",
  "group_name": "New Group Name",
}
```
### Response
Return facility level add operation response.
```json
{
  "facility_name": "New Facility Name", 
  "result": "Success", 
  "reason": "" 
}
```
Facility exist but cannot update
```json
{ 
  "facility_name": "New Facility Name", // or display old facility name?
  "result": "Failed", 
  "reason": "some reason" 
}
```
Facility does't exist
```json
{ 
  "facility_name": "New Facility Name",
  "result": "Failed", 
  "reason": "Facility do not exist" 
}
```


## Delete Water Tower Facility
**DELETE** /web/water-tower/facilities
* Need to record the action in the activity log.

### Request body
Pass facility level uuid to backend.
```json
{
  "list": [
    {
      "facility_name": "Facility1",
      "ipv4": "10.147.173.58"
    },
    {
      "facility_name": "Facility2",
      "ipv4": "10.147.173.61"
    }
  ]
}
```
### Response
Return tower level delete operation response.
If facility not exist, return facility name as location.
```json
{
  "list": [
    { "facility_name": "Facility1", "result": "Success", "reason": "" },
    // water tower exist but can not delete
    { "facility_name": "Facility2", "result": "Failed", "reason": "some reason" },
    // facility not exist
    { "facility_name": "Facility2", "result": "Failed", "reason": "Facility not exist" } 
  ]
}
```

# Facility Level
## Get the Carousel data
**GET** /web/water-tower/facilities/{facility_ip}/carousel

### Response
```json
{
  current_status: [
    {
      title: "Temperature",
      contents: [
        { title: "Inlet Air", value: "35", unit: "°C" },
        { title: "Outlet Air", value: "35", unit: "°C" },
        { title: "Inlet Facility Water", value: "25", unit: "°C" },
        { title: "Outlet Facility Water", value: "25", unit: "°C" },
      ]
    },
    {
      title: "Spraying",
      contents: [
        { title: "Pump Power", value: "1.4", unit: "kW" },
        { title: "Pump Outlet Pressure", value: "100", unit: "KPA" },
        { title: "Make Up Water", value: "2.4", unit: "m3" },
        { title: "Water Temperature", value: "30.1", unit: "°C" },
      ]
    },
  ]
}
```

## Get Water Tower Facility Physical Assets Info
**GET** /web/water-tower/facilities/{facility_ip}/physical-assets

### Response
```json
{
    "facility_name": "Tower1",
    "ipv4": "192.168.25.37",
    "group_name": "VMWare",
    "product_sku": "LCS-SCLT",
    "part_number": "S356783X9513724",
    "serial_number": "SN12345A6789",
    "manufacturer": "Supermicro",
    "firmware_version": "1200",
    "health": "Good",
    "tower_count": "3",
    "pump_count": "2",
}
```

## Get Water Tower Facility Sensor Reading(Updated)
**GET** /web/water-tower/facilities/{facility_ip}/sensor-reading

### Response
```json 
{
  result: "Success",
  timestamp: "2024-03-27T08:08:11Z", // UTC time
  status_list: [
    {
      label: "Control Module",
      value: "Good" | null, // Good or Error
    },
    {
      label: "Facility Pump 1 Status",
      value: "Good" | null, // Auto or Manual or Stop
    },
    {
      label: "Facility Pump 2 Status",
      value: "Good" | null, // Auto or Manual or Stop
    },
    {
      label: "Facility Pump 3 Status",
      value: "Good" | null, // Auto or Manual or Stop
    },
  ],
  table_list: [
    {
      label: "Pump",
      list: [
        { 
          "Sensor Name": "Facility Pump 1 VFD Power(kW)", 
          value: "4.5" | null
        },
        { 
          "Sensor Name": "Facility Pump 1 VFD Speed(%)", 
          value: "70" | null
        },
        { 
          "Sensor Name": "Facility Pump 2 VFD Power(kW)", 
          value: "4.5" | null
        },
        { 
          "Sensor Name": "Facility Pump 2 VFD Speed(%)", 
          value: "70" | null
        },
        { 
          "Sensor Name": "Facility Pump 3 VFD Power(kW)", 
          value: "4.5" | null
        },
        { 
          "Sensor Name": "Facility Pump 3 VFD Speed(%)", 
          value: "70" | null
        },
      ]
    },
    {
      label: "Facility",
      list: [
        { 
          "Sensor Name": "Inlet Facility Water Temperature(°C)", 
          value: "42.1" | null
        },
        { 
          "Sensor Name": "Outlet Facility Water Temperature(°C)", 
          value: "32.1" | null
        },
        { 
          "Sensor Name": "Inlet Facility Water Pressure(kPa)",
          value: "500" | null
        },
        { 
          "Sensor Name": "Outlet Facility Water Pressure(kPa)", 
          value: "400" | null
        },
        { 
          "Sensor Name": "Facility Water Flow Rate(GPM)", 
          value: "400" | null
        },
      ]
    }
  ]
}
```

## Get Water Tower Facility Analytics Pumps
### VFD Speed
**GET** /web/water-tower/facilities/{facility_ip}/analytics/pump/vfd-speed

#### URL Param
- data range
Time range for data.
E.g.: start=2024-04-04T04:00:00Z&end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Facility Pumps VFD Speed",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z",
  ],
  "unit": "%",
  "facility_pump_1": [
    "60", "61", "75", "63", "89"
  ],
  "facility_pump_2": [
    "60", "61", "75", "63", "89"
  ],
  "facility_pump_3": [
    "60", "61", "75", "63", "89"
  ]
}
```
### VFD Power(Updated)
**GET** /web/water-tower/facilities/{facility_ip}/analytics/pump/vfd-power

#### URL Param
- data range
Time range for data.
E.g.: start=2024-04-04T04:00:00Z&end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Facility Pumps VFD Power",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kW",
  "facility_pump_1": [
    "2.4", "1.7", "1.7", "1.0", "2.1"
  ],
  "facility_pump_2": [
    "2.4", "1.7", "1.7", "1.0", "2.1"
  ],
  "facility_pump_3": [
    "2.4", "1.7", "1.7", "1.0", "2.1"
  ]
}
```
## Get Water Tower Facility Analytics Facility
### Water Temperature
**GET** /web/water-tower/facilities/{facility_ip}/analytics/facility/water-temperature

#### URL Param
- data range
Time range for data.
E.g.: start=2024-04-04T04:00:00Z&end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Facility Water Temperature",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z",
  ],
  "unit": "℃",
  "inlet_facility_water_temperature": [
    "20", "21", "35", "23", "49"
  ],
  "outlet_facility_water_temperature": [
    "13", "17", "31", "18", "40"
  ]
}
```
### Water Pressure
**GET** /web/water-tower/facilities/{facility_ip}/analytics/facility/water-pressure

#### URL Param
- data range
Time range for data.
E.g.: start=2024-04-04T04:00:00Z&end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Facility Water Pressure",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kPa",
  "inlet_facility_water_pressure": [
    "400", "530", "550", "590", "520"
  ],
  "outlet_facility_water_pressure": [
    "300", "430", "450", "490", "420"
  ],
}
```
### Water Flow Rate
**GET** /web/water-tower/facilities/{facility_ip}/analytics/facility/water-flow-rate

#### URL Param
- data range
Time range for data.
E.g.: start=2024-04-04T04:00:00Z&end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Facility Water Flow Rate",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "LPM",
  "facility_water_flow_rate": [
    "400", "530", "550", "590", "520"
  ]
}
```

## Get Water Tower Facility Analytics Operation
### Facility Pumps Status(New)
**GET** /web/water-tower/facilities/{facility_ip}/analytics/operation/facility-pumps-status

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "facility_pump_1": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Good", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
  ],
  "facility_pump_2": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Good", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
  ],
  "facility_pump_3": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Good", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
  ]
}
```

### Control Module(New)
**GET** /web/water-tower/facilities/{facility_ip}/analytics/operation/control-module

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "control_module": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Error", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
    // ...
  ]
}
```


# Tower Level

## Get the Carousel data
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/carousel

### Response
```json
{
  current_status: [
    {
      title: "Temperature",
      contents: [
        { title: "Inlet Air", value: "35", unit: "°C" },
        { title: "Outlet Air", value: "35", unit: "°C" },
        { title: "Inlet Facility Water", value: "25", unit: "°C" },
        { title: "Outlet Facility Water", value: "25", unit: "°C" },
      ]
    },
    {
      title: "Spraying",
      contents: [
        { title: "Pump Power", value: "1.4", unit: "kW" },
        { title: "Pump Outlet Pressure", value: "100", unit: "KPA" },
        { title: "Make Up Water", value: "2.4", unit: "m3" },
        { title: "Water Temperature", value: "30.1", unit: "°C" },
      ]
    },
  ]
}
```

## Get Water Tower Physical Assets Info
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/physical-assets

### Response
```json
{
    "location": "f1.1",
    "group_name": "VMWare",
    "tower_sku": "LCS-SCLT",
    "part_number": "G29389230479328",
    "serial_number": "HM18BS019487",
    "manufacturer": "Supermicro",
    "firmware_version": "1200",
    "health": "Good",
    "status": "On" // On | Off // new info
}
```

## Get Water Tower Sensor Reading
修改 response 回應
- Remove Outlet Air Temperature, Outlet Air Relative Humidity in Air Side Card.
- Remove Spraying Water Flow Rate, Spraying Water Temperature in Spraying Card
- Change unit to “Gallons” for Make up Water

### URL
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/sensor-reading

### Response
```json 
{
  result: 'Success',
  timestamp: '2024-03-27T08:08:11Z', // UTC time
  status_list: [
    {
      label: 'Operation Mode',
      value: 'Manual' | null, // TBD
    },
    {
      label: 'Fan VFD Status',
      value: 'Good' | null, // Good or Error
    },
    {
      label: 'Bassin Level Sensor',
      value: 'Overflow' | null, // Low/Good/Overflow
    },
    {
      label: 'Spraying Pump Status',
      value: 'On' | null, // Low/Good/Overflow
    }
  ],
  table_list: [
    {
      label: 'Air Side',
      list: [
        { 
          'Sensor Name': 'Fan VFD Speed(%)', 
          value: '50' | null
        },
        { 
          'Sensor Name': 'Fan Power(kW)', 
          value: '35' | null
        },
        { 
          'Sensor Name': 'Inlet Air Temperature(℃)', 
          value: '35' | null
        },
        { 
          'Sensor Name': 'Inlet Air Relative Humidity(%)', 
          value: '38' | null
        }
      ]
    },
    {
      label: 'Spraying',
      list: [
        { 
          'Sensor Name': 'Spraying Pump Power(kW)', 
          value: '1.4' | null
        },
        { 
          'Sensor Name': 'Pump Outlet Pressure(kPa)', 
          value: '38' | null
        },
        { 
          'Sensor Name': 'Make Up Water(usGallons)', // 2024-04-01
          value: '2.4' | null
        },
      ]
    },
    {
      label: 'Calculated Data',
      list: [
        { 
          'Sensor Name': 'Dew Point(℃)', 
          value: '50' | null
        },
        { 
          'Sensor Name': 'Heat Load(kW)', 
          value: '49' | null
        },
        { 
          'Sensor Name': 'Total Power(kW)', 
          value: '3245' | null
        },
        { 
          'Sensor Name': 'PUE', 
          value: '3261' | null
        },
        { 
          'Sensor Name': 'WUE(G/MWh)', // 2024-04-01
          value: '48' | null
        },
      ]
    }
  ]
}
```

## Air Side
### Fan VFD Speed
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/air-side/fan-vfd-speed
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Fan VFD Speed",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "%",
  "fan_vfd_speed": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Fan Power
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/air-side/fan-power
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Fan Power",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kW",
  "fan_power": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Inlet Air Temperature
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/air-side/inlet-air-temperature
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Inlet Air Temperature",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "℃",
  "inlet_air_temperature": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Inlet Air Relative Humidity
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/air-side/inlet-air-relative-humidity
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Inlet Air Relative Humidity",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "%",
  "inlet_air_relative_humidity": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```

## Spraying

### Bassin Level Sensor
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/spraying/bassin-level-sensor

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "bassin_level_sensor": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Error", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
    // ...
  ]
}
```
### Spraying Pump Power
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/spraying/spraying-pump-power
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Spraying Pump Power",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kw",
  "spraying_pump_power": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Pump Outlet Pressure
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/spraying/pump-outlet-pressure
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Pump Outlet Pressure",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kPa",
  "pump_outlet_pressure": [
    "10", "15", "20", "15", "20"
  ]
}
```
### Make Up Water
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/spraying/make-up-water
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Make Up Water",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "usGallons",
  "make_up_water": [
    "1", "1.5", "2", "1.5", "2"
  ],
  "total_make_up_water_usage": "50"
}
```
## Operation
### Operation Mode
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/operation/operation-mode

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "operation_mode": [
    [
      "2022-05-30T06:02:00Z",
      "Stop", // Stop, Manual, Auto
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Manual", // Stop, Manual, Auto
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Auto", // Stop, Manual, Auto
      "2022-05-31T08:02:00Z"
    ]
    // ...
  ]
}
```

### Fan VFD Status
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/operation/fan-vfd-status

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "fan_vfd_status": [
    [
      "2022-05-30T06:02:00Z",
      "Good", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Error", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Good", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
    // ...
  ]
}
```

### Spraying Pump Status
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/operation/spraying-pump-status

#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
| Code | Description
| ------ | ------
| 200 | OK
| 400 | Bad Request
| 401 | Unauthorized
| 404 | Not found

**Sample**
```json
{
  "spraying_pump_status": [
    [
      "2022-05-30T06:02:00Z",
      "Error", // Good, Error
      "2022-05-30T10:02:00Z"
    ],
    [
      "2022-05-30T10:02:00Z",
      "Good", // Good, Error
      "2022-05-30T20:02:00Z"
    ],
    [
      "2022-05-30T20:02:00Z",
      "Error", // Good, Error
      "2022-05-31T08:02:00Z"
    ]
    // ...
  ]
}
```

## Calculated Data
### Dew Point

~~GET /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/dew-point~~
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/wet-bulb-temperature


#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Dew Point",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "℃",
  "dew_point": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Heat Load
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/heat-load
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Heat Load",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kW",
  "heat_load": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### Total Power
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/total-power
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "Total Power",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "kW",
  "total_power": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### PUE
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/pue
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "PUE",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "",
  "pue": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```
### WUE
**GET** /web/water-tower/facilities/{facility_ip}/{location_id}/analytics/calculated-data/wue
#### URL Param
- start
Start of Timestamp, UTC.
E.g.: start=2024-04-04T04:00:00Z
- end
End of Timestamp, UTC.
E.g.: end=2024-04-05T04:00:00Z

#### Response
```json
{
  "label": "WUE",
  "time_stamp": [
    "2024-04-04T04:00:00Z",
    "2024-04-04T04:01:00Z",
    "2024-04-04T04:02:00Z",
    "2024-04-04T04:03:00Z",
    "2024-04-04T04:04:00Z"
  ],
  "unit": "G/MWh",
  "wue": [
    "1", "1.5", "2", "1.5", "2"
  ]
}
```

# Group
## Get Group List
**GET** /web/water-tower/groups

### URL Param

- items
help the user to search what data he wants in different columns. Backend will return all types of columns to the frontend.
E.g.: group_name=all&description=all&facility_number=all

- current_page
Which page the user wants to reference.
E.g.: current_page=1 

- sort
What column the user wants to sort it (asc or desc).
E.g.: sort=group_name:asc or sort=group_name:desc

- entries
Which page the user wants to reference.
E.g.: entries=10 

### Response
```json
{
  "entries": 10,
  "current_page": 1,
  "total_page": 1,
  "total_entries": 1,
  "list": [
    {
      "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-1", // identify the group
      "group_name": "Group 1",
      "description": "Some description",
      "facility_number": 6
    }
  ]
}
```
## Get All Groups
**GET** /web/water-tower/groups/all
When user add new water tower, user need to select which group is water tower belong.

### Response
Return all groups name and uuid.
```json
{
  "list": [
    {
      "group_name": "Group 1",
      "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-1"
    },
    {
      "group_name": "Group 2",
      "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-2"
    },
  ],
}
```

## Add Group
**POST** /web/water-tower/groups

### Request body
```json
{
  "list": [
    {
      "group_name": "Group 1",
      "description": "Some description",
    },
    {
      "group_name": "Group 2",
      "description": "Some description 2",
    }
  ]
}
```

### Response
```json
{
  "list": [
    { "group_name": "Group 1", "result": "Success", "reason": "" },
    { "group_name": "Group 2", "result": "Failed", "reason": "some reason" },
  ]
}
```
## Check Group Name Exist
**GET** /web/water-tower/groups/check-name-exist
When user add new group, need to check if backend already have same group name.

### URL Param
- identity
Group name.
E.g.: identity=Group%201

### Response
Return result and named group uuid, need uuid for update group  to check it is same group or not.
```json
{
  "result": "true",
  "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-1"
}
```
```json
{
  "result": "false",
  "uuid": null
}
```

## Get Facilities of Groups
**GET** /web/water-tower/groups/get-facilities
When user delete groups, need to list all facilities for user to check.

### URL Param
- identity
Group uuid.
E.g.: identity=00000000-0000-0000-0000-7CC25551CC-GROUP-1,00000000-0000-0000-0000-7CC25551CC-GROUP-2

### Response
```json
{
  "list": [
    {
      "facility_name": "Tower1",
      "group_name": "Group 1",
    },
    {
      "facility_name": "Tower2",
      "group_name": "Group 1",
    },
    {
      "facility_name": "Tower3",
      "group_name": "Group 1",
    },
    {
      "facility_name": "Tower4",
      "group_name": "Group 2",
    }
  ]
}
```

## Update Group
**PUT** /web/water-tower/groups/{uuid}
Update an existing group.

### Request body
```json
{
  "group_name": "New Group Name",
  "description": "New description"
}
```

### Response
Success
```json
{
  "group_name": "New Group Name",
  "result": "Success",
  "reason": ""
}
```
Group exist but cannot update
```json
{
  "group_name": "New Group Name",
  "result": "Failed",
  "reason": "Some reason"
}
```
Group doesn't exist
```json
{
  "group_name": "New Group Name",
  "result": "Failed",
  "reason": "Group doesn't exist"
}
```

## Delete Groups
**DELETE** /web/water-tower/groups
Delete groups and water towers.

### Request body
Pass group uuid to backend.
```json
{
  "list": [
    {
      "group_name": "Group 1",
      "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-1"
    },
    {
      "group_name": "Group 2",
      "uuid": "00000000-0000-0000-0000-7CC25551CC-GROUP-2"
    },
  ],
}
```

### Response
```json
{
  "list": [
    { "group_name": "Group 1", "result": "Success", "reason": "" },
    { "group_name": "Group 2", "result": "Failed", "reason": "some reason" },
  ]
}
```

# Notification
New notification activities.

Add new activities: 
- Add Facility
- Update Facility
- Delete Facilities
- Add Cooling Tower Group
- Update Cooling Tower Group
- Delete Cooling Tower Groups

![image](https://hackmd.io/_uploads/rJ4k69qpA.png)
![image](https://hackmd.io/_uploads/ByxoWaq5pC.png)
![image](https://hackmd.io/_uploads/SyOzTqcTC.png)
![image](https://hackmd.io/_uploads/B1Km655aR.png)
![image](https://hackmd.io/_uploads/SJR7T9c6A.png)
![image](https://hackmd.io/_uploads/rymVTq5pR.png)


# Cooling Tower Phase 2.1
## Log Event Cooling Tower
**GET** /web/log/cooling-tower-event/list
get list of cooling tower events

### URL Param
- entries : how many entries are on each page.
E.g.: entries=10

- items : help the user to search what data he wants in different columns. Backend will return all types of columns to the frontend.
E.g.: trap_id=all&severity=all&message=all&facility_name=all&facility_ip=all& timestamp=all&start=&end=

  - If the front-end does not support it to the backend. Backend will search all of the items !
  - Total have 8 types of categories

- current_page : Which page the user wants to reference.
E.g.: current_page=2     get list of 2’s page


  - if current_page <= 0 , current_page = 1.
  - if current_page >= total_page, current_page = total_page.
  - min of total_page = 1 even no data.

- sort : What column the user wants to sort it (asc or desc).
E.g.: sort=entity_id:asc or sort=entity_id:desc


mark_id : Only for notification redirection.
E.g : mark_id=124

```json
{
    current_page: 1,
    entries: 10,
    total_entries: 5635,
    total_pages: 564,
    list: [
      {
        entity_id: 23,
        trap_id: '1',
        severity: 'alert' , // 'alert' | 'warning'
        message: 'some alert message',
        facility_name: 'test',
        facility_ip: '10.0.168.203',
        timestamp: "2024-03-27T08:08:11Z", // UTC time
        group_uuid: 'bce2e76c-8555-11ef-9b24-4ec585073c20',
      },
      {
        entity_id: 24,
        trap_id: '2',
        severity: 'warning', // 'alert' | 'warning'
        message: 'another message',
        facility_name: 'test1',
        facility_ip: '10.43.242.34',
        timestamp: "2024-03-27T08:08:11Z", // UTC time
        group_uuid: 'a3364b66-8551-11ef-9b22-4ec585073c20',
      },
    ],

  }
```

## Get Facility Settings
**GET** /web/water-tower/facilities/{facility_ip}/settings

### Response
```json
{ 
    "outletFacilityWaterTemperatureSetPoint": {
        "displayName": "Outlet Facility Water Temperature Set Point",
        "unit": "°C",
        "setPoint": 35
    },
    "outletFacilityWaterPressureSetPoint": {
        "displayName": "Outlet Facility Water Pressure Set Point",
        "unit": "kPa",
        "setPoint": 102
    }
}
```
## Patch Facility Settings
**PATCH** /web/water-tower/facilities/{facility_ip}/settings

### Request Body
```json
{ 
    "outletFacilityWaterTemperatureSetPoint"?: 35,
    "outletFacilityWaterPressureSetPoint"?: 200,
}
```
### Response
```json
{
    "list":[
        { 
            "settings": 'Outlet Facility Water Temperature Set Point',
            "facilityName": 'Facility 1',
            "result": 'Success' | 'Failed',
            "reason"?: 'some reason',
        },
        { 
            "settings": 'Outlet Facility Water Pressure Set Point',
            "facilityName": 'Facility 1',
            "result": 'Success' | 'Failed',
            "reason"?: 'some reason',
        },
    ]
}
```

## Get Facility Settings Current Value
use [sensor reading](https://hackmd.io/ropyPFVfQh2ahG5hT3v0Cw#Get-Water-Tower-Facility-Sensor-ReadingUpdated) api
