Grohe Sense and Sense Guard

For those interested in using the Grohe Sense Guard, I partly solved my problem with a Script instead of an app.

These are the steps I took to be able to turn on and off water from within a flow.
Steps 1 - XX are done using a Rest Client, like Postman

  1. Get your Login token,
    POST https://idp-apigw.cloud.grohe.com/v2/iot/auth/users/login
    Body: {“username”:“XXXXX”,“password”:“XXXXXX”}
    Header: Content-Type: application/json

  2. Get your Locations
    GET https://idp-apigw.cloud.grohe.com/v2/iot/locations
    Header: Content-Type: application/json
    Header: Authorization:<Login Token from Step 1>

  3. Get Rooms
    GET https://idp-apigw.cloud.grohe.com/v2/iot/locations/<Location ID from step 2>/rooms
    Header: Content-Type: application/json
    Header: Authorization:<Login Token from Step 1>

  4. Get Appliances
    GET: https://idp-apigw.cloud.grohe.com/v2/iot/locations/<Location ID from step 2>/rooms/<Room ID from step 3>/appliances
    Header: Content-Type: application/json
    Header: Authorization:<Login Token from Step 1>

  5. Post Command to Close Water
    POST https://idp-apigw.cloud.grohe.com/v2/iot/<Location ID from step 2>/rooms/<Room ID from step 3>/appliances/<Appliance ID from Step 4>/command
    Body: { “type”: 103, “command”: { “valve_open”: false }}
    Header: Content-Type: application/json
    Header: Authorization:<Login Token from Step 1>

If everything works fine to step 5, just use this script with Homey.

postData(https://idp-apigw.cloud.grohe.com/v2/iot/locations/**<LocationID>**/rooms/**<RoomID>**/appliances/**<ApplianceID>**/command, {“type”: 103,“command”: {“valve_open”: args[0]}})
.then(data => console.log(JSON.stringify(data)))
.catch(error => console.error(error));

function postData(url = ``, data = {}) {
// Default options are marked with *
return fetch(url, {
method: “POST”, // *GET, POST, PUT, DELETE, etc.
mode: “cors”, // no-cors, cors, *same-origin
cache: “no-cache”, // *default, no-cache, reload, force-cache, only-if-cached
credentials: “same-origin”, // include, *same-origin, omit
headers: {
“Content-Type”: “application/json”,
“Authorization”: “”,
},
redirect: “follow”, // manual, *follow, error
referrer: “no-referrer”, // no-referrer, *client
body: JSON.stringify(data), // body data type must match “Content-Type” header
})
.then(response => response.json()); // parses JSON response into native Javascript objects
}

The script is originally from this site: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

There are a lot of improvements for the above script. For example, I am not sure how long the token will be valid for, so a new token could be needed once in a while. Could be solved using a script making a login request and store the token in a variable.

5 Likes