Grohe Sense (Ondus)

Hi @gkreitz
Have you tried to generate a refresh token using code?

I have been trying to reverse engineer their auth flow using postman but haven’t gotten very far. I’m not sure what I should put into the execution and session_code parameters for example. If I copy-paste the parameters that I get from chrome and run them using postman I only get " You took too long to login. Login process starting from beginning".

If you have some time I would love to look into this together.

My refresh token gets expired after only a few days so this would be nice to get working.

1 Like

I think this is a great idea - I don’t have to refresh my token as frequently as you do - but I definitely think there’s mileage in using Postman to model the authentication and refresh_token retrieval flow.

I’ll take a look at this myself… great suggestion

Nice that you like the suggestion, have you tried it yet?
This is what I have so far, it appears to be three calls:

First one is to set the STATE. This is done upon loading the login page. It is a GET method to this url:
**[https://idp2-apigw.cloud.grohe.com/v1/sso/auth/realms/idm-apigw/protocol/openid-connect/auth]
It passes these query string parameters:

redirect_uri: ondus://idp2-apigw.cloud.grohe.com/v3/iot/oidc/token
scope: openid
response_type: code
client_id: iot
state: [GUID]

Second one is a POST made upon pressing the login button:
[https://idp2-apigw.cloud.grohe.com/v1/sso/auth/realms/idm-apigw/login-actions/authenticate]
It passes this in the query string params:

session_code: [Some-ID, don't know if this is just generated. Looked like something that was base64 encoded but I can't decode it]
execution: [GUID]
client_id: iot
tab_id: [Some-ID?]

Payload is sent from data url encoded with Username, Password and RemeberMe=On

Third one is the actual token and the step you do yourself that fails in Chrome. GET to:
[ondus://idp2-apigw.cloud.grohe.com/v3/iot/oidc/token]
Where you replace the ondus with https.
Sends in these query string params:

state: [GUID sent in the first request]
session_state: [GUID, I think this is set in a cookie?)
code: [This is several GUIDs, don't know how it generates this one]

It also appears as though cookie data is used and sent in in the header data but I’m not that comfortable with cookies and how those work.

Anybody else that has input?

Yes, I get the same as you…

…and I’m now trying to move the auth flow into Node-Red on Home Assistant so that I can generate the ‘refresh-token’ with a flow. The problem I have is crafting the HTTP POST with my user credentials in a node. I’ve decrypted the whole login process using Wireshark and I can see what it looks like but Node-Red doesn’t have any readily available nodes for completing an HTTP POST with Form data.

I need to spend more time on this and experiment with the nodes that are available.

1 Like

Cool! Would you like to share the flow that you have so far and I could try it out as well? :slight_smile:

OK, so the logic I am using is as follows:

HTTP Request to: https://idp2-apigw.cloud.grohe.com/v3/iot/oidc/login

  1. Extract the POST URL which includes the session_code, execution, client_id and tab_id

  2. Construct the HTTP POST Request including the correct message headers and POST this using the appropriate credentials

  3. Extract the returned failed redirect to ‘ondus://’ from the web response and resubmit the URL using ‘https’ instead.

  4. Extract the ‘refresh_token’ from the JSON response

I’m basically working through each stage - and rather crudely crafting each HTTP GET/POST to ensure that it’s doing what it should. No point in over engineering it - I just want to extract the token in the simplest way possible.

I’ll try and devote some more time to it next week.

1 Like

Hi @retel ,

I haven’t looked much at it. I’d prefer a solution where Grohe creates some stable longer-term refresh tokens intended for API usage (as that would be much better than having username + password in the configuration). Bonus points for a properly documented API. If anyone likes the game of “convincing companies to do things”, this may be an excellent thing to do to improve home assistant that does not require any programming skills.

Currently I don’t have much time to put into this module, but when I do, I can take a look at implementing support for using a username + password to grab the refresh token.

Hi!

I understand you, well when you do find the time that would be awesome. And yes, if they could make their api more usable by other apps that would be the best, I have already email them a while back but nothing happened. Maybe if more people would send in requests we might be heard.

Anyway, I was so sure that my token got invalidated because everything stopped working. My statistics weren’t updated and I couldn’t control my valve anymore, switching the token always fixed this issue for me. But last time it happened to I didn’t have the time to fix it so I just left it for a couple of days, and to my surprise it suddenly started working again after a couple of days without me touching the token?!

Has anybody seen this behavior and has an idea on how to fix it?

Check here how my history looks, you can see it is updated regerualy and then stops for a couple of days and then suddenly gets back without me doing anything. No restarts or nothing. You can also see it stops working after a day again.

Hi eveybody,

i just installed my Grohe Sense friday and the integration at the night. I can get information and control the flow water.

But I have a problem, there is an important gap between flow consumption in the Grohe ondus app vs information taht shows HA. Righty now, 467L in the app and 290 in the Ha.

Do you know whats could be the reason?

Any possibilitu taht restart could affect the numbers.

Thanks

I have the same issue and I’m guessing this is a consequence of the poll times to the Grohe servers by HA and the Grohe App.

The app seems to update every 20 minutes or so, not in real time - but the HA custom component may have a different polling interval, hence the possible discrepancy between the daily consumption figures you are seeing.

That said, I would expect the two figures to be the same over a similar period - but they might be out of step in the short term if that makes sense.

Any improvement in this way?

I have to renewal my token every 2 days.

Thanks

Hi,

I’ve struggled a couple of months with that this integration stops responding after a few hours to a few days after restarting HA.

The log suggest that my refresh_token has expired, but restarting HA without updating the refresh_token solves the issue temporarily until it stops working again a few hours to a few days later.

I’ve tested getting a new refresh token, but get the same issue after a similar interval.
I’ve seen one case where the integration came back online without restarting HA.

Has anybody made any progress with modifying the code so that it can get a new refresh_token automatically? There has been some suggestions to do this and I found a python code that at least makes it simpler to get the refresh_token: https://github.com/gkreitz/homeassistant-grohe_sense/issues/23

Hi!

I am considering buying Grohe Sens Guard and just wanted to check with those of you who have been using this integration if it is still working well or if it is more like per.takman writes that the issues with the token got worse?

Thank you!

Hi

Have you tried the Node-Red integration.
I set it up today and it was easy to get it working. Just put in your Email, password and HomeID and the node takes care of the rest. No token to be fetched manually just plug and play…

Mi ,

Please could you explain deeper how did you set up it?.

Any example please, please. I, m validating the token every two days.

It would be helpful.

Thanks

Install the plugin above in nodered under palette.
Check the name of your home in the app and configure your emai+pw.

I have just started but I can get all the withdrawal from the past 2days as the example.
I have a sensor in HA with all the data as raw.

Just need to figure out how to graph and organise the data. Apex card first ant then in to energy card under water is the plan…

Thanks

I have installed the plugin and also connected the node grohe Sense, Now is in connected stattus, but I can´t see anything.

I dont´use normaly node red, which node or configuration I must to do after node of guard is connected to get the sensors to HA?

Thanks again

Hi

Let me work on it during the weekend and I will post something in this thread on Mondag.
I have some issues formatting the output data to a sensor so it can be used in the Energy dashboard or built in graphs.

There is a need to extract the timezone as a key folowed by the waterconsumption as value

I was thinking of a function node in NodeRed with a
msg.payload.data.withdrawals.forEach(h => )… something

Currently the data looks like.

- starttime: '2022-11-02T00:42:12.000+01:00'
stoptime: '2022-11-02T00:42:49.000+01:00'
waterconsumption: 2.4
maxflowrate: 4.1
hotwater_share: 0.7
water_cost: 0.095983
energy_cost: 0.032838
- starttime: '2022-11-02T01:05:35.000+01:00'
stoptime: '2022-11-02T01:06:05.000+01:00'
waterconsumption: 1.9
maxflowrate: 4.2
hotwater_share: 0.6
water_cost: 0.075987
energy_cost: 0.025997
- starttime: '2022-11-02T02:20:33.000+01:00'
stoptime: '2022-11-02T02:20:40.000+01:00'
waterconsumption: 0.5
maxflowrate: 4.1
hotwater_share: 0.1
water_cost: 0.019997
energy_cost: 0.006841

ok thanks.

Because I Have elemental problems, and I don’t know how to get this information from the Grohe node. debugging nothing appears. I don´t know where i must to send the message or which messages.

I get lost.

Thanks,

Waiting for you conclusion this weekend, nice job.

1 Like