> For the complete documentation index, see [llms.txt](https://docs.mclimate.eu/mclimate-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mclimate.eu/mclimate-api-documentation/control-devices/t-valve-lorawan.md).

# T-Valve LoRaWAN

### Get device data

*Request URL:*

```
POST /provider/fetch
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number" : "{T-Valve Serial Number}"
}
```

*Response:*

```
{
    "provider": {
        "network_provider": "the_things_network",
        "rssi": -31,
        "spf": "SF7BW125",
        "valveState": false,
        "boxTamper": true,
        "floodDetectionWireState": false,
        "flood": false,
        "magnet": false,
        "alarmValidated": false,
        "manualOpenIndicator": true,
        "manualCloseIndicator": true,
        "closeTime": 0,
        "openTime": 0,
        "waterTemp": 24.5,
        "ambientTemp": 24.5,
        "battery": 2.872,
        "createdAt": "2021-02-16T11:53:16.526Z",
        "lastActive": "2021-02-23T14:50:24.192Z",
        "online": true
    },
    "_links": {
        "self": {
            "href": "/v1/provider/fetch"
        }
    }
}
```

### Request full data

*Request URL:*

```
POST /provider/fetch
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number" : "{T-Valve Serial Number}",
  "command" : "request_full_data"
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "603516aa08f81715fffd1827",
        "commandName": "RequestFullData",
        "commandParams": "",
        "deviceId": "36************1",
        "createdAt": "2021-02-23T14:52:26.634Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set KeepAlive Time

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_keepalive_time",
  "time" : 3 // in minutes
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fa06f0a9764116d41b4ab",
        "commandParams": {
            "time": 3
        },
        "commandName": "SetPacketPeriod",
        "deviceId": "3************1",
        "createdAt": "2021-02-19T11:26:39.004Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Open Close Time

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_open_close_time",
  "opening_time" : 1, //in minutes, range 0-255, cannot be both 0
  "closing_time" : 0 //in minutes, range 0-255, cannot be both 0
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fb8470a9764116d41b562",
        "commandName": "SetOpenCloseTime",
        "commandParams": {
            "openingTime": 1,
            "closingTime": 0
        },
        "deviceId": "36************11",
        "createdAt": "2021-02-19T13:08:23.394Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Manual Control

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_manual_control",
  "enable_open" : false,
  "enable_close" : false
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fba020a9764116d41b563",
        "commandName": "SetManualControl",
        "commandParams": {
            "enableOpen": false,
            "enableClose": false
        },
        "deviceId": "363************1",
        "createdAt": "2021-02-19T13:15:46.578Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Emergency Openings

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_emergency_openings",
  "max_openings" : 5 // max 15
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fba020a9764116d41b563",
        "commandName": "SetEmergencyOpenings",
        "commandParams": {
            "maxOpenings": 5
        },
        "deviceId": "363************1",
        "createdAt": "2021-02-19T13:15:46.578Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set LED

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_led",
  "led_id" : 0,
  "behavior" : 1,
  "seconds" : 2 //IF seconds=0, execute the command until OK button is pressed or 
    //next command is received
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fba020a9764116d41b563",
        "commandName": "SetLED",
        "commandParams": {
            "ledId": 0,
            "behavior": 1,
            "seconds": 2
        },
        "deviceId": "363************1",
        "createdAt": "2021-02-19T13:15:46.578Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Buzzer

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_buzzer",
  "volume" : 0, // Volume 15 - off, 0 - min... 14 - max
  "frequency" : 1, // range 0 - 10
  "active_time" : 2, // seconds; 0 - untill volume 15 is received
  "on_time" : 10, // ms; min 10ms
  "off_time" : 2 // ms; min 10 ms
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "602fba020a9764116d41b563",
        "commandName": "SetBuzzer",
        "commandParams": {
            "volume": 0,
            "frequency": 1,
            "activeTime": 2,
            "onTime": 1,
            "offTime": 2
        },
        "deviceId": "363************1",
        "createdAt": "2021-02-19T13:15:46.578Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Working Voltage

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_working_voltage",
  "voltage" : 1850 // in mV, value less than 1850mV has undefined behavior
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "604b5a5fdf17f60011b5d58c",
        "commandName": "SetWorkingVoltage",
        "commandParams": {
            "voltage": 1850
        },
        "deviceId": "363************1",
        "createdAt": "2021-03-12T12:11:11.300Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Set Device Flood Sensor

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-Valve Serial Number}”,
  "command" : "set_device_flood_sensor",
  "enabled" : true 
}
```

*Response:*

```
{
    "provider": {
        "status": "pending",
        "_id": "604b5cf0df17f60011b5d5bf",
        "commandName": "SetDeviceFloodSensor",
        "commandParams": {
            "enabled": true
        },
        "deviceId": "363************1",
        "createdAt": "2021-03-12T12:22:08.954Z",
        "__v": 0
    },
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```

### Get Pending Commands

*Request URL:*

```
POST /provider/send
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "serial_number": “{T-valve Serial Number}”,
  "command" : "get_pending_commands"
}
```

*Response:*

```
{
    "provider": [
        {
            "_id": "652d43a7c4ff3228464dfb08",
            "deviceId": "70B**********8B",
            "commandName": "GetKeepAliveTime",
            "commandParams": [],
            "status": "queued",
            "createdAt": "2023-10-16T14:07:35.872Z",
            "__v": 0
        }
    ],
    "_links": {
        "self": {
            "href": "/v1/provider/send"
        }
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mclimate.eu/mclimate-api-documentation/control-devices/t-valve-lorawan.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
