Skip to main content

Bosch Smart Home Controller API Python Library

Project description

Bosch Smart Home Controller API Python Library

This library implements the local communication REST API for the Bosch Smart Home Controller system. It supports both long and short polling. The API documentation is available here.

The following device services are implemented:

  • TemperatureLevel
  • HumidityLevel
  • RoomClimateControl
  • ShutterContact
  • ValveTappet
  • PowerSwitch
  • PowerMeter
  • Routing
  • PowerSwitchProgram
  • PresenceSimulationConfiguration
  • BinarySwitch
  • SmokeDetectorCheck
  • Alarm
  • ShutterControl
  • CameraLight
  • PrivacyMode
  • CameraNotification
  • IntrusionDetectionControl
  • Keypad
  • LatestMotion
  • AirQualityLevel
  • SurveillanceAlarm
  • BatteryLevel
  • Thermostat
  • WaterLeakageSensor
  • WaterLeakageSensorTilt
  • and more

The following device models are implemented, using the above services:

  • ShutterContact, ShutterContact2
  • ShutterControl, Micromodule Shutter
  • SmartPlug
  • SmartPlugCompact
  • LightControl, Micromodule Light Control, Micromodule Light Attached, Micromodule Relay
  • SmokeDetector
  • CameraEyes, Camera360
  • IntrusionDetectionSystem
  • RoomClimateControl
  • Thermostat, Thermostat2
  • WallThermostat
  • UniversalSwitch
  • MotionDetector
  • PresenceSimulationSystem
  • Twinguard
  • WaterLeakageSensor

Command line access to SHC

  1. Install a python (>=3.10) environment on your computer.
  2. Install latest version of boschshcpy, you should have at least version>=0.2.45.
pip install boschshcpy

Registering a new client

To register a new client, use the script boschshc_registerclient:

boschshc_registerclient -ip _your_shc_ip_ -pw _your_shc_password_

This will register your client and will write the associated certificate/key pair into your working directory. See also Usage Guide

Rawscans

To make a rawscan of your devices, use the script boschshc_rawscan

Make a rawscan of the public information

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ public_information

Make a rawscan of all devices

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ devices

Make a rawscan of a single device with a known device_id

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ device _your_device_id_

An exemplary output looks as follows:

    {
        "@type": "device",
        "rootDeviceId": "xx-xx-xx-xx-xx-xx",
        "id": "hdm:HomeMaticIP:30xxx",
        "deviceServiceIds": [
            "Thermostat",
            "BatteryLevel",
            "ValveTappet",
            "SilentMode",
            "TemperatureLevel",
            "Linking",
            "TemperatureOffset"
        ],
        "manufacturer": "BOSCH",
        "roomId": "hz_8",
        "deviceModel": "TRV",
        "serial": "30xxx",
        "profile": "GENERIC",
        "name": "Test Thermostat",
        "status": "AVAILABLE",
        "parentDeviceId": "roomClimateControl_hz_8",
        "childDeviceIds": []
    },

Make a rawscan of the associated services of a device

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ device_services _your_device_id_

The exemplary output will look as follows:

[
    {
        "@type": "DeviceServiceData",
        "id": "BatteryLevel",
        "deviceId": "hdm:HomeMaticIP:30xxx",
        "path": "/devices/hdm:HomeMaticIP:30xxx/services/BatteryLevel"
    },
    {
        "@type": "DeviceServiceData",
        "id": "Thermostat",
        "deviceId": "hdm:HomeMaticIP:30xxx",
        "state": {
            "@type": "childLockState",
            "childLock": "OFF"
        },
        "path": "/devices/hdm:HomeMaticIP:30xxx/services/Thermostat"
    },
...
]

Make a rawscan of the a service of a device, where the device_id as well as the service_id are known

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ device_service _your_device_id_ _your_service_id

Make a rawscan of the all scenarios

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ scenarios

Make a rawscan of the all rooms

boschshc_rawscan -ip _your_shc_ip_ -cert _your_shc_cert_file_ -key _your_shc_key_file_ rooms

Example code to use the boschshcpy library

import boschshcpy

# Create session
session = boschshcpy.SHCSession(controller_ip="192.168.25.51", certificate='cert.pem', key='key.pem')
session.information.summary()

device = session.device('roomClimateControl_hz_5')
service = device.device_service('TemperatureLevel')
print(service.temperature)

# Update this service's state
service.short_poll()

# Start long polling thread in background
session.start_polling()

# Do work here
...

# Stop polling
session.stop_polling()

# Trigger intrusion detection system
intrusion_control = session.intrusion_system
intrusion_control.arm()

# Get rawscan of devices
scan_result = session.rawscan(command="devices")

Usage guide

Before accessing the Bosch Smart Home Controller, a client must be registered on the controller. For this a valid cert/key pair must be provided to the controller. To start the client registration, press and hold the button on the controller until the led starts flashing. More information here.

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

boschshcpy-0.2.77.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

boschshcpy-0.2.77-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

Details for the file boschshcpy-0.2.77.tar.gz.

File metadata

  • Download URL: boschshcpy-0.2.77.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for boschshcpy-0.2.77.tar.gz
Algorithm Hash digest
SHA256 330d3dbdd839c2cf5aef57bfe95ef5d57e6b98b644eeb0a3ce5a31729bea55fe
MD5 4a83a0e82d73e37c943200569b94469a
BLAKE2b-256 60102438f6125ca4885086cb78f9ff09fe0f53ce6ad3943983d6c66f6d687cc8

See more details on using hashes here.

Provenance

File details

Details for the file boschshcpy-0.2.77-py3-none-any.whl.

File metadata

  • Download URL: boschshcpy-0.2.77-py3-none-any.whl
  • Upload date:
  • Size: 34.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for boschshcpy-0.2.77-py3-none-any.whl
Algorithm Hash digest
SHA256 84b93361b2a6e7c5dd04ae576fa3ad782b6e1b03283d4a77a1307ea37cfed67c
MD5 7253605827c9f0f5925ab26ae91b2b9e
BLAKE2b-256 edd1c106b1e7f3af7bce7a577dfc602ca8264fb61d161e95ce5a7cdc78ca52c2

See more details on using hashes here.

Provenance

Supported by

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