- Platform information:
- Hardware: Windows 10 Laptop
- OS: Windows 10
- Java Runtime Environment: Zulu Java 8
- openHAB version: 2.5.6
I would like to create a HTML form that consists of a button, that when clicked, posts to the REST API and sets the temperature of a thermostat to 20 degrees Celcius.
On my local host REST API docs page, I can successfully change the state of the item using the “Try it Out” button located under “Items” and “Post.” On that page, the CURL command sends a value of “20” to my item and it works.
curl -X POST --header “Content-Type: text/plain” --header “Accept: application/json” -d “20” “https://localhost:8443/rest/items/zwave_device_1c17d314_node3_thermostat_setpoint_cooling”
Also on the REST API page, if I issue a GET command to the item, I get the following response:
{
“link”: “https://localhost:8443/rest/items/zwave_device_1c17d314_node3_thermostat_setpoint_cooling”,
“state”: “23.3333333333333333333333333333333 °C”,
“stateDescription”: {
“pattern”: “%.0f”,
“readOnly”: false,
“options”: []
},
“editable”: false,
“type”: “Number:Temperature”,
“name”: “zwave_device_1c17d314_node3_thermostat_setpoint_cooling”,
“label”: “Setpoint (cooling)”,
“category”: “Heating”,
“tags”: [],
“groupNames”: []
}
What should my HTML form parameter names and values be to change the status of the thermostat?
Here is my HTML without the brackets <> until I figure out how to use a code fence to display the HTML.
form method=“post” enctype=“text/plain” action=“not allowed to post a third link since I’m a newbie”
input type=“hidden” name=“status” value=“20”/
input type=“submit” value=“Submit”/
/form
The openhab.log file confirms my HTML form posts are received, but the status value is not accepted. The log shows:
[WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/zwave_device_1c17d314_node3_thermostat_setpoint_cooling’ with an invalid status value ‘status=20.0’.