gkreitz / homeassistant-grohe_sense

Grohe Sense integration for Home Assistant
MIT License
42 stars 25 forks source link

Grohe have changed there endpoint #11

Closed MortenVinding closed 3 years ago

MortenVinding commented 3 years ago

Old endpoint is using a revoked certificate: https://idp-apigw.cloud.grohe.com/v3/iot/

New endpoint seems to be: https://idp2-apigw.cloud.grohe.com/v3/iot/

Judging from info in: https://github.com/FlorianSW/grohe-ondus-api-java/blob/master/src/main/java/org/grohe/ondus/api/OndusService.java

gkreitz commented 3 years ago

BIG Thank you for pointing that out! Then I can reverse all the ugly code to set up a bespoke SSL context to trust Grohe's old certificate.

MortenVinding commented 3 years ago

No problem. I’m just happy I didn’t screw anything up, this is my fist pull request :)

I’m working on getting my Grohe Blue Home chilled water tap working with your integration (that’s the reason I looked at the OpenHAB/Java code). But I’m not a programmer and no nothing about Python so it’s a bit of a learning experience for me :)

I have implemented the basics in a shell script (because that what I know :)).

A request ${BASE_URL}/locations/${LOCATION_ID}/rooms/${ROOM_ID}/appliances/${APPLIANCE_ID} returns:

[ { "appliance_id": "ec613805-7fea-4a3d-861e-7df400a42beb", "installation_date": "2020-12-08T22:13:32.000+00:00", "name": "MY U-SPOUT", "serial_number": "305a31303123456789012345678901234567890123456789", "type": 104, "version": "01.00.Z10.0300.0104", "tdt": "2021-01-19T13:35:30.000+01:00", "timezone": 60, "config": { "co2_type": 1, "hose_length": 110, "co2_consumption_medium": 48, "co2_consumption_carbonated": 65, "guest_mode_active": true, "auto_flush_active": true, "flush_confirmed": false, "f_parameter": 3, "l_parameter": 0, "flow_rate_still": 16, "flow_rate_medium": 25, "flow_rate_carbonated": 16 }, "role": "owner", "registration_complete": true, "presharedkey": “XXXXXXXXXXXXXXXXXXXXXXXXXXXX=", "params": { "water_hardness": 0, "carbon_hardness": 20, "filter_type": 1, "variant": 3, "auto_flush_reminder_notif": true, "consumables_low_notif": true, "product_information_notif": true }, "error": { "errors_1": false, "errors_2": false, "errors_3": false, "errors_4": false, "errors_5": false, "errors_6": false, "errors_7": false, "errors_8": false, "errors_9": false, "errors_10": false, "errors_11": false, "errors_12": false, "errors_13": false, "errors_14": false, "errors_15": false, "errors_16": false, "error1_counter": 0, "error2_counter": 0, "error3_counter": 0, "error4_counter": 0, "error5_counter": 0, "error6_counter": 0, "error7_counter": 0, "error8_counter": 0, "error9_counter": 0, "error10_counter": 0, "error11_counter": 0, "error12_counter": 6656, "error13_counter": 0, "error14_counter": 0, "error15_counter": 0, "error16_counter": 0 }, "state": { "start_time": 1611014189, "APPLIANCE_SUCCESSFUL_CONFIGURED": false, "co2_empty": false, "co2_20l_reached": false, "filter_empty": false, "filter_20l_reached": false, "cleaning_mode_active": false, "cleaning_needed": false, "flush_confirmation_required": false, "System_error_bitfield": 0 } } ]

Does that look like the output from the Sense Guard? Or is it very different? Any possibility you have an example from the Sense Guard? That would be a huge help to me :)

Med Venlig Hilsen

Morten Vinding Sonnerupvej 69 2700 Brønshøj +45 24 47 01 69

On 19 Jan 2021, at 13.49, Gunnar Kreitz notifications@github.com wrote:

BIG Thank you for pointing that out! Then I can reverse all the ugly code to set up a bespoke SSL context to trust Grohe's old certificate.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gkreitz/homeassistant-grohe_sense/pull/11#issuecomment-762819763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJCB62OUSOVVDLAK5MH77DS2V5TZANCNFSM4WIUYTGQ.

gkreitz commented 3 years ago

No problem. I’m just happy I didn’t screw anything up, this is my fist pull request :) I’m working on getting my Grohe Blue Home chilled water tap working with your integration (that’s the reason I looked at the OpenHAB/Java code). But I’m not a programmer and no nothing about Python so it’s a bit of a learning experience for me :) I have implemented the basics in a shell script (because that what I know :)).

It looked like a perfectly fine pull request, but that first one sure can be scary! :)

The protocol example for the Blue you show looks relatively different compared to the protocol for the other devices (or, at least the parts of the protocol I've implemented here). On a positive note - the protocol you show looks pretty simple, at least if one simply wants to build sensors from that data.

I'm not sure if this is the easiest component to start with if you're new to programming. I've written this code to make use of python's async features, which may be a new stumbling block. That said, some rambling guidance for roughly how I would start if I were to try to implement support for Blue:

My code will scan for appliances, putting all of them in an array in hass.data[DOMAIN]['devices'], https://github.com/gkreitz/homeassistant-grohe_sense/blob/master/__init__.py#L60 . Note that the last request there is to ${BASE_URL}/locations/${LOCATION_ID}/rooms/${ROOM_ID}/appliances/ (which returns all the appliances in a room). You may want to check that the type returned there for a Blue is 104 (as in your reply), I saw some worrying indications in https://github.com/FlorianSW/grohe-ondus-api-java/issues/12 that they may put type as 0 in that array (seems like a bug on Grohe's end).

For the Blue device, you'll likely want to deviate a bit from the code structure I have in place. In this code, I do a pattern where I have one GroheSenseGuardReader class (fetching data periodically), and then classes for the various styles of sensors (the easiest being GroheSenseSensorEntity). This structure is to keep down polling (1 request/appliance, instead of 1 per sensor), but when you're prototyping it may be easier to try to write something similar to GroheSenseSensorEntity directly - making a request to the correct url in async_update and storing the measurement as a variable in the object, returning it in the state method.

On https://github.com/gkreitz/homeassistant-grohe_sense/blob/master/sensor.py#L68 , you'd then want an if statement to check if the device is a Blue device (using the type above) and have all my code as an else, creating an instance of your new sensor class for a Blue device.

Do you know what sort of functionality you'd want in home assistant for the Blue? Are there values in the response you showed that you want to have as sensors? Or are you more trying to build commands for something?

MortenVinding commented 3 years ago

Thank you Gunnar,

My Blue is returning 104 as device id, so no problems there :)

Hmm I’m probably not gonna understand all of your code anytime soon anyway, so my plan is mostly to modify it to work reasonably with the Blue :)

I have implemented some of it already in the switch.py just copying the GroheSenseGuardValve class and adjusting it to GroheBlueHomeTap :)

I’m mostly after commands that’s why it is the switch.py I modified. The Blue has a “tap” command:

"{
  \"command\": {
    \"tap_type\": $1,
    \"tap_amount\": $2
  }
}"

So my plan is to make a switch panel to fill up a glass or a carafe :)

But so far all I have managed is to set a hardcoded value, so when I flip the switch in Home Assistant, the tap runs for that value. Obesely I need to modify that to accept integers instead of a boolean :)

Still some way to go, but I’m learning :)

Taping 20ml of water (minimum setting just for test): https://user-images.githubusercontent.com/1188091/105553633-06311900-5d06-11eb-9636-47444f89f10b.MOV

Thank you so much for your help :) I will keep you posted on my progress

bluenobbe commented 1 year ago

Hello MortenVinding can you post your final code to get running the Grohe Blue tab. I would like to integrate my Grohe Blue as well. Thanks in advance for your help.