def api_test(): try: ACCESS_CERT = args.access_cert ACCESS_KEY = args.access_key if not os.path.isfile(ACCESS_CERT) or not os.path.isfile(ACCESS_KEY): print("No valid cert or key file, aborting!") sys.exit() # Create a BoschSHC client with the specified ACCESS_CERT and ACCESS_KEY. client = BoschShcPy.Client(args.ip_address, args.port, ACCESS_CERT, ACCESS_KEY) api = BoschShcPy.Api(client) token = api.register_client(args.id, args.name, args.password) if token != None: print( 'successful registered new device with token {}'.format(token)) else: print( 'No valid token received, did you press client registration button on smart home controller?' ) sys.exit() shc_info = client.shc_information() print(' version : %s' % shc_info.version) print(' updateState : %s' % shc_info.updateState) except BoschShcPy.client.ErrorException as e: print('\nAn error occured during new client registration:\n')
def setup_client(): try: # Create a BoschSHC client with the specified ACCESS_CERT and ACCESS_KEY. client = BoschShcPy.Client(IP_SHC, PORT_SHC, ACCESS_CERT, ACCESS_KEY) shc_info = client.shc_information() print(' version : %s' % shc_info.version) print(' updateState : %s' % shc_info.updateState) # device = client.device(shutter_control_ID) # print(device) # print("Accessing all devices...") smart_plugs = BoschShcPy.smart_plug.initialize_smart_plugs(client, client.device_list()) for item in smart_plugs: client.register_device(item, callback) client.register_device(item.device, callback) shutter_controls = BoschShcPy.shutter_control.initialize_shutter_controls(client, client.device_list()) for item in shutter_controls: client.register_device(item, callback) client.register_device(item.device, callback) shutter_contacts = BoschShcPy.shutter_contact.initialize_shutter_contacts(client, client.device_list()) for item in shutter_contacts: client.register_device(item, callback) client.register_device(item.device, callback) # intrusion_detection = BoschShcPy.IntrusionDetection(client) # intrusion_detection.register_polling(client, callback) except BoschShcPy.client.ErrorException as e: print('\nAn error occured while requesting a SmartPlug object:\n') for error in e.errors: print(' code : %d' % error.code) print(' description : %s' % error.description) print(' parameter : %s\n' % error.parameter) return client
import sys, os, time sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import BoschShcPy ACCESS_CERT = 'keystore/aps-cert.pem' ACCESS_KEY = 'keystore/aps-key.pem' HDM_ID = "hdm:Cameras:fa991a12-8c6b-3f3c-b9c5-727ff4c318b6" IP_SHC = '192.168.1.6' PORT_SHC = '8444' try: # Create a BoschSHC client with the specified ACCESS_CERT and ACCESS_KEY. client = BoschShcPy.Client(IP_SHC, PORT_SHC, ACCESS_CERT, ACCESS_KEY) shc_info = client.shc_information() print(' version : %s' % shc_info.version) print(' updateState : %s' % shc_info.updateState) # device = client.device(SMART_PLUG_ID) # print(device) # # print("Accessing a dummy device...") # camera = BoschShcPy.CameraEyes( # client, BoschShcPy.Device(), HDM_ID, "Dummy") # camera.update() # print(camera)
import sys, os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import BoschShcPy ACCESS_CERT = 'keystore/aps-cert.pem' ACCESS_KEY = 'keystore/aps-key.pem' SMART_PLUG_ID = "hdm:HomeMaticIP:3014F711A0000496D858ACC5" IP_SHC = '192.168.1.6' PORT_SHC = '8444' try: # Create a BoschSHC client with the specified ACCESS_CERT and ACCESS_KEY. client = BoschShcPy.Client(IP_SHC, PORT_SHC, ACCESS_CERT, ACCESS_KEY) shc_info = client.shc_information() print(' version : %s' % shc_info.version) print(' updateState : %s' % shc_info.updateState) # device = client.device(SMART_PLUG_ID) # print(device) # print("Accessing a dummy device...") smart_plug = BoschShcPy.SmartPlug(client, BoschShcPy.Device(), SMART_PLUG_ID, "Dummy") smart_plug.update() print(smart_plug)
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import time import BoschShcPy ACCESS_CERT = 'keystore/aps-cert.pem' ACCESS_KEY = 'keystore/aps-key.pem' SHUTTER_CONTROL_ID = "hdm:HomeMaticIP:3014F711A00018D878598448" IP_SHC = '192.168.1.6' PORT_SHC = '8444' try: # Create a BoschSHC client with the specified ACCESS_CERT and ACCESS_KEY. client = BoschShcPy.Client(IP_SHC, PORT_SHC, ACCESS_CERT, ACCESS_KEY) shc_info = client.shc_information() print(' version : %s' % shc_info.version) print(' updateState : %s' % shc_info.updateState) # device = client.device(shutter_control_ID) # print(device) # print("Accessing all shutter control devices...") shutter_controls = BoschShcPy.shutter_control.initialize_shutter_controls(client, client.device_list()) for item in shutter_controls: item.update() print(item)