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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file homeconnect_websocket-1.0.0.tar.gz
.
File metadata
- Download URL: homeconnect_websocket-1.0.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ee8c635de220f84efd5c4decd2d863712078739e768ea927efd1af81ad2264 |
|
MD5 | 3df79ff1ee1b5906c051696be5ca6611 |
|
BLAKE2b-256 | c95bc1154931a51b82c3773541c5ae5ec5b876a71afc1a64beed0aa8bb7ae150 |
File details
Details for the file homeconnect_websocket-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: homeconnect_websocket-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8547e385ac70769a64bfedb56560c1ba0e3098b768327dcfe3071c45da0dfe7 |
|
MD5 | 5dcbf19fffb66f033c82681821622a56 |
|
BLAKE2b-256 | 1ef107d60e9f3ea90a92eadfe713575104641aa291519dc2621b58048bf62104 |