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.
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.
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.
…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.
Extract the POST URL which includes the session_code, execution, client_id and tab_id
Construct the HTTP POST Request including the correct message headers and POST this using the appropriate credentials
Extract the returned failed redirect to ‘ondus://’ from the web response and resubmit the URL using ‘https’ instead.
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.
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.
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.
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.
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.
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
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?
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…
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
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.