Package: boschshcpy
Bosch Smart Home Controller API Python LibraryThis 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 availablehere.The following device services are implemented:TemperatureLevelHumidityLevelRoomClimateControlShutterContactValveTappetPowerSwitchPowerMeterRoutingPowerSwitchProgramPresenceSimulationConfigurationBinarySwitchSmokeDetectorCheckAlarmShutterControlCameraLightPrivacyModeCameraNotificationIntrusionDetectionControlKeypadLatestMotionAirQualityLevelSurveillanceAlarmBatteryLevelThermostatWaterLeakageSensorWaterLeakageSensorTiltand moreThe following device models are implemented, using the above services:ShutterContact,ShutterContact2ShutterControl,Micromodule ShutterSmartPlugSmartPlugCompactLightControl,Micromodule Light Control,Micromodule Light Attached,Micromodule RelaySmokeDetectorCameraEyes,Camera360IntrusionDetectionSystemRoomClimateControlThermostat,Thermostat2WallThermostatUniversalSwitchMotionDetectorPresenceSimulationSystemTwinguardWaterLeakageSensorCommand line access to SHCInstall apython(>=3.10) environment on your computer.Install latest version ofboschshcpy, you should have at leastversion>=0.2.45.pipinstallboschshcpyRegistering a new clientTo register a new client, use the scriptboschshc_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 alsoUsage GuideRawscansTo make a rawscan of your devices, use the scriptboschshc_rawscanMake a rawscan of the public informationboschshc_rawscan-ip_your_shc_ip_-cert_your_shc_cert_file_-key_your_shc_key_file_public_informationMake a rawscan of all devicesboschshc_rawscan-ip_your_shc_ip_-cert_your_shc_cert_file_-key_your_shc_key_file_devicesMake a rawscan of a single device with a knowndevice_idboschshc_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 deviceboschshc_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 thedevice_idas well as theservice_idare knownboschshc_rawscan-ip_your_shc_ip_-cert_your_shc_cert_file_-key_your_shc_key_file_device_service_your_device_id__your_service_idMake a rawscan of the all scenariosboschshc_rawscan-ip_your_shc_ip_-cert_your_shc_cert_file_-key_your_shc_key_file_scenariosMake a rawscan of the all roomsboschshc_rawscan-ip_your_shc_ip_-cert_your_shc_cert_file_-key_your_shc_key_file_roomsExample code to use theboschshcpylibraryimportboschshcpy# Create sessionsession=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 stateservice.short_poll()# Start long polling thread in backgroundsession.start_polling()# Do work here...# Stop pollingsession.stop_polling()# Trigger intrusion detection systemintrusion_control=session.intrusion_systemintrusion_control.arm()# Get rawscan of devicesscan_result=session.rawscan(command="devices")Usage guideBefore 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 informationhere.