def _main(): api = ConnectAPI() devices = api.list_connected_devices().data if len(devices) == 0: raise Exception("No endpints registered. Aborting") # Delete device subscriptions api.delete_device_subscriptions(devices[0].id) # First register to webhook api.update_webhook("https://mbed-iot.herokuapp.com/webhook/") time.sleep(2) api.add_resource_subscription(devices[0].id, BUTTON_RESOURCE)
def _main(): api = ConnectAPI() devices = api.list_connected_devices().data if len(devices) == 0: raise Exception("No endpints registered. Aborting") # Delete device subscriptions api.delete_device_subscriptions(devices[0].id) # First register to webhook api.update_webhook("http://python.requestcatcher.com/") time.sleep(2) api.add_resource_subscription(devices[0].id, BUTTON_RESOURCE) while True: print("Webhook registered. Listening to button updates for 10 seconds...") time.sleep(10) break api.delete_webhook() print("Deregistered and unsubscribed from all resources. Exiting.")
def _main(): api = ConnectAPI() api.start_notifications() devices = api.list_connected_devices().data if not devices: raise Exception("No connected devices registered. Aborting") device_id = "015e9a938ff100000000000100100019" api.delete_device_subscriptions(device_id) api.list_presubscriptions() api.add_resource_subscription_async(device_id, INCRIMENTAL_RESOURCE, _callback_fn) api.add_resource_subscription_async(device_id, VOLTAGE_RESOURCE, _callback_fn) api.add_resource_subscription_async(device_id, CURRENT_RESOURCE, _callback_fn) api.add_resource_subscription_async(device_id, POWER_RESOURCE, _callback_fn) while True: time.sleep(0.1)
def _main(): api = ConnectAPI() api.delete_device_subscriptions(dev) api.update_webhook("https://www.tric.kr/heroku/mbed-iot/webhook/") time.sleep(1) api.add_resource_subscription(dev, POPUP_IOT_RESOURCE)