Skip to main content

Home Connect Websocket API

Project description

HomeConnect Websocket

Control HomeConnect Appliances through a local Websocket connection.

Authentication and Device Description

To connect to an Appliance you need its encryption keys and the description of its features and options. The Appliance uses either TLS PSK or AES encryption, AES requires an additional Initialization Vector (IV). Both Key and IV are send to HomeConnects cloud servers on setup. To get the keys and description from the cloud use the hc-login.py script from the hcpy project (https://github.com/hcpy2-0/hcpy/)

From the script output you need the following:

  • devices.json: The PSK ("key") and the IV ("iv") if the Appliance uses AES
  • [serialNumber].zip: The two files named *_DeviceDescription.xml and *_FeatureMapping.xml containing the Device Description

Parsing Device Description

import json
from pathlib import Path

from homeconnect_websocket import parse_device_description

# Load Description from File
with Path("DeviceDescription.xml").open() as file:
    DeviceDescription = file.read()

with Path("FeatureMapping.xml").open() as file:
    FeatureMapping = file.read()

description = parse_device_description(DeviceDescription, FeatureMapping)

# Save Description to File for later use
with Path("DeviceDescription.json", "w").open() as file:
    json.dump(description, file)

Its best to save the parsed description as a json File to reuse later.

Connecting

import asyncio
import json

from homeconnect_websocket import DeviceDescription, HomeAppliance


async def main(description: DeviceDescription) -> None:
    app_name = "Example App"  # Name of your App
    app_id = "d50661eca7e45a"  # ID of your App
    psk64 = "whZJhkPa3a1hkuDdI3twHdqi1qhTxjnKE8954_zyY_E="  # PSK Key
    # iv64 = "ofi7M1WB98sJeM2H1Ew3XA==" # IV for Devices with AES Encryption

    appliance = HomeAppliance(
        description,
        "192.168.1.2",
        app_name,
        app_id,
        psk64=psk64,
        # iv64=iv64
    )
    await appliance.connect()

    # Set PowerState to On
    await appliance.settings["BSH.Common.Setting.PowerState"].set_value("On")


if __name__ == "__main__":
    # Load DeviceDescription from File
    with open("DeviceDescription.json", "r") as f:
        description = json.load(f)

    asyncio.run(main(description))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

homeconnect_websocket-1.2.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

homeconnect_websocket-1.2.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file homeconnect_websocket-1.2.1.tar.gz.

File metadata

  • Download URL: homeconnect_websocket-1.2.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for homeconnect_websocket-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ef44feb8df4df6d1d84d7424cff871a4849bc2255df6cf4d61f12a3e195f7b98
MD5 561c7cc5b3ba52a6b1935ee308d5ca95
BLAKE2b-256 79f0d408fc364d053746fcd1eb7e4d70398166774cde37e70d9f36c3def619da

See more details on using hashes here.

Provenance

The following attestation bundles were made for homeconnect_websocket-1.2.1.tar.gz:

Publisher: publish.yml on chris-mc1/homeconnect_websocket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file homeconnect_websocket-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for homeconnect_websocket-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6847168847d3eee637b0629aa649ab3dbc1a725e0949ac438ffd82bab53a69e2
MD5 cd3de9333b15af3a1e9fa9712a58bce9
BLAKE2b-256 42820b9f5f5f1241376e90ed304d3a85c23926e4946e6c2cb11dabf7935533cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for homeconnect_websocket-1.2.1-py3-none-any.whl:

Publisher: publish.yml on chris-mc1/homeconnect_websocket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page