HOME CONNECT INTEGRATION (working even without SSL & not exposing HA to web)

I was looking for the integration of my HOME CONNECT devices (SIEMENS, but fully compatible with BOSCH), but somehow the integrations needed SSL and/or exposing HA to the web.

After some research I found the BOSCH_DRYER python integration by GKREITZ, which i first copied and optimized for washer, dishwasher and oven. This caused too many requests, so I decided to create one integration for all HOME CONNECT devices. (Coffee machine, fridge aren’t supported yet as I do not have the possibility to test them).

image

image

The integration is still quick & dirty, no multi-language support yet, feel free to add any requests or changes.

README.md

This is a HOME ASSISTANT component to read the states of a HOME CONNECT Oven, Dishwasher, Washer & Dryer.
(Based on the BOSCH Dryer module from GKREITZ: https://github.com/gkreitz/homeassistant-bosch_dryer)

This will give you five sensors for each HOME CONNECT device you have:

If the devicse is off/not connected to wifi, you’ll get a state of unavailable and the rest as` unknown``.

Installation

  • Ensure your HOME CONNECT devices are set up and working in the HOME CONNECT app on your smartphone.
  • Copy this folder to <config_dir>/custom_components/home_connect/ .
  • Create an account on https://developer.home-connect.com/.
  • Register an application. Pick Device flow for OAuth flow.
  • Once you start the following sequence, you have 5 minutes to complete it (or you’ll have to restart from here):
  • LINUX Console:
    • export CLIENT_ID="YOUR_CLIENT_ID"
    • curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=${CLIENT_ID}" https://api.home-connect.com/security/oauth/device_authorization | tee tmp.json
    • Go to verification_uri in a browser, type in user_code . Log in using your (end user, not developer) Home Connect account and approve.
    • export DEVICE_CODE=$(jq -r .device_code tmp.json)
    • curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=${DEVICE_CODE}&client_id=${CLIENT_ID}" https://api.home-connect.com/security/oauth/token | tee access_token.json
    • jq .refresh_token access_token.json
  • WINDOWS: it should be possible to get your access_token using an HTTP API Tool like Postman or Insomnia (not tested)
    • POST Request to: “https://api.home-connect.com/security/oauth/device_authorization” with HEADER: “Content-Type: application/x-www-form-urlencoded” and DATA: “client_id=YOUR_CLIENT_ID” -> This will provide you a JSON-formatted response, you’ll need a device_code , verification_uri and user_code from it.
    • Go to verification_uri in a browser, type in user_code . Log in using your (end user, not developer) Home Connect account and approve.
    • POST Request to: “https://api.home-connect.com/security/oauth/token” with HEADER: “Content-Type: application/x-www-form-urlencoded” and DATA: “grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=DEVICE_CODE_FROM_PREVIOUS_REQUEST&client_id=YOUR_CLIENT_ID” -> This will provide you the needed refresh_token as a JSON-response.

Put the following in your home assistant config:

sensor:
  - platform: home_connect
    refresh_token: "YOUR_REFRESH_TOKEN"

Save and restart HA. The sensors for all your HOME CONNECT devices should be generated automatically.

Usage

I used the custom component ‘multiple-entity-row’ to display the states of the HOME CONNECT devices. For better readable timer i am using a template sensor.

sensors.yaml

    hb_timer:
      friendly_name: "Oven remaining"
      value_template: >
          {% if states('sensor.siemens_hbXXXXXXX_state') == 'finished' %}
            FINISHED
          {% elif states('sensor.siemens_hbXXXXXXX_state') == 'inactive' %}
            OFF
          {% elif states('sensor.siemens_hbXXXXXXX_remaining') == 'unknown' %} 
            ...
          {% elif states('sensor.siemens_hbXXXXXXX_remaining') | float < 61 %}
            {{ states('sensor.siemens_hbXXXXXXX_remaining') + " sek" }}
          {% else %}
            {{ ((states('sensor.siemens_hbXXXXXXX_remaining') | float / 60) | round(0)) | string + " min" }}
          {% endif %}

ui-lovelace.yaml

  - entity: sensor.hb_timer #Template Sensor for a more readable time
    type: custom:multiple-entity-row
    icon: mdi:window-maximize
    name: Oven
    info:
        entity: sensor.siemens_hbXXXXXXX_state
        name: "Status:"
    primary:
      entity: sensor.siemens_hbXXXXXXX_program
      name: Program
    secondary:
      entity: sensor.siemens_hbXXXXXXX_door
      name: Door
    tertiary:
      entity: sensor.siemens_hbXXXXXXX_elapsed
      name: Runtime

Remarks on the API

This is built using the Home Connect API, documented on https://developer.home-connect.com/. There is plenty in the API that is not exposed via this component. Using the API, one can also remote control the dryer, but I haven’t figured out a use case for that yet. The API is a straightforward REST API with Oauth authentication. There’s also a server-side event feed giving pretty quick updates. Originally, this module was just polling, but I figured it’d be fun to test out asyncio, so I rewrote the module to be async and cloud-push.

The API is a bit flakey, and tends to time out/return 504 during European evenings. Currently, this module retries forever, with an exponential backoff. I’ll fix to something a tad better if/when I get sufficiently annoyed.

1 Like

Great job! Pretty easy to setup and with this integration I haven’t seen the disconnect bug which plagued me with the other HomeConnect integration (https://github.com/DavidMStraub/homeconnect/issues/3).

I’ve got this working now for my Siemens washing machine and dryer. If you’d like, I could do some testing for a Siemens refrigerator? :slight_smile:

1 Like

Thank you for your feedback :slight_smile:
Ok, with you I both got testers for the coffee machine and refrigerator… I’ll give it a go and post a new beta-version for testing in the next days…

1 Like

One other thing that might be worth looking into: compatibility with HACS. Currently when you try to import the repository, HACS complains that it’s incompatible. Would make it easier to do future updates…

1 Like

does this work without the device having to go to the internet, like the oficial app?

1 Like

Sadly HOME CONNECT doesn’t allow direct access to the devices. So (as far as I know) also the official app needs internet access and the HOME CONNECT devices do communicate to the servers same as the official app.

But this solution doesn’t need any exposure of your HOME ASSISTANT to the internet, no SSL certificates… It is still a bit complicated to get the “access token”, but then it is working fine…
(there seems to be an easier way to get your access token by using the “iobroker” solution, didn’t test it by myself tough…

1 Like

Actually you can.
If you go to our appliance Settings, you can check how you are connected to it, and if you allow to use internet to talk to the device.
Check my attached images, in this case, since I’m not home I’m connected through the cloud.


1 Like

Have you ever tried it? I’m pretty sure disabling connection to server simply disables the possibility to control the device. The requirements state you must have access to internet.

1 Like

True, would be the very best solution! Privacy first :slight_smile:

1 Like

No it works without internet! But it’s kind of mwa, you need to restart the app and wiggle things. The app-response is not seamless if you switch over.
Also it’s kind of overprotected. For example if you change the DHCP manged IP adres of your homeapplicance via your router to (another) fixed IP, you need to reconnect with the app because the security prohibits a connection if the IP does not match. This is a security measurement a guy from Siemens said when I complained about it.

1 Like

Ok good to know. I did not get it working but that is probably because I did not restart the app. So in theory there is a possibility.

2 Likes

To be more concrete what I mean with wiggeling it a bit: Probably restart the machine. Maybe re-add do the add-to-your-app sequence again on the home-connect device. But it then really works.

Currenly i’m back to internet control because the Siemens made it like, when you don’t use server control you won’t recieve security updates for the machine. (bastards) and also I couldn’t use the Cotwild Dave’s integration, leaving the HomeConnect devices the only non-HomeAssistant devices wich is really stupid since their typically devices wich should be in HomeAssistant for your smart home. In my Ideal world their connected locally (privacy first!). But i’m not daring to ask that to Cotwild Dave. I’m allready glad that someone took the oppurtunity to write code that actually makes it possible to use it in HomeAssistant :slight_smile: But local control would be the ultimate goal if you ask me.

1 Like

Yes, we should aim for local only.

1 Like

Hi. Dropping this here because it’s tangentially relevant to the discussion of home connect, privacy and how the app and local/internet control work and may be of interest to this group:

I sent HC support a question about why the app provokes a ‘do you want to share your location’ warning from IOS, and got the below:

> I’m attempting to get my dishwasher connected with the app and for some reason it’s requesting my geographical location. I look forward to a response explaining why the location data is necessary, please?

For the manual connection of the household appliance to the WLAN at home, it is necessary to transfer the SSID and the password to the home appliance.

With the introduction of iOS 13, new technical guidelines apply from Apple. You may have the latest version (iOS 13) installed on your iOS device.

Apple now restricts access to Wi-Fi information in iOS. As a result, apps can only read out WLAN date such as SSID if the use allows app access to location services.

The Home Connect app does not use the location services itself, but on the SSID for integrating the home appliance in to the WLAN.

1 Like

I agree this is troublesome. Hope we can find a developer who can make a local control integration. By reverse engineering the official homeconnect app or sniffing the traffic I dunno. Or maybe Siemens/Bosch is so kind to give the code language for local control I don’t know either. Too bad I can’t do it myself, I know it’s really a study to write and understand these integrations, but my hands are itching :slight_smile:

I believe that direct connect using API request might work. Device appears to get some sort of secret/certificate from the device on the setup as it’s required to both be on same network

1 Like

I am not technical at all but if my Siemens Washer and Dryer could be integrated in Home Assistant in a way even I understand I’d be so so happy! lol

We’ll take a look at this! https://www.home-assistant.io/integrations/home_connect/

1 Like

Thank you!

My (bosch) dishwasher won’t connect to the Home Connect cloud. Local trhough the app works flawless. Any ideas? (turned pihole off)