pip install PyParticleIO
PyParticleIO
is an Open Source licensed Python package that provides a class to
interface with the ParticleIO cloud
This ParticleCloud class is meant to be a minimal python implementation to access a Particle devices (Core, Photon, Electron) functions, variables and events.
Inspired heavily from: https://github.com/Alidron/spyrk/blob/master/spyrk/spark_cloud.py -- Thank you for sharing your implementation
particle_cloud = ParticleCloud(access_token) particle_cloud = ParticleCloud(username, password)
particle_cloud.devices
particle_cloud.internet_button1.ledOn('led1')
particle_cloud.internet_button1.buttonCount
- def callback(event_data):
- print("event callback")
particle_cloud.internet_button1.subscribe("button1", callback)
particle_cloud.internet_button1.cloud_subscribe("button2", callback)
particle_cloud.internet_button1.publish("do_rainbow")
An example usage:
from pyparticleio.ParticleCloud import ParticleCloud access_token = "Your Access Token Here" particle_cloud = ParticleCloud(username_or_access_token=access_token) all_devices = particle_cloud.devices for device in all_devices: print("Device: {0}".format(device)) print("done")
Example usage behind a proxy server:
from pyparticleio.ParticleCloud import ParticleCloud access_token = "Your Access Token Here" proxy_dict = { "proxies": { "https": "Your HTTPS Proxy Address Here" # like "https://192.168.1.1:8080" } } particle_cloud = ParticleCloud(username_or_access_token=access_token, **proxy_dict) all_devices = particle_cloud.devices for device in all_devices: print("Device: {0}".format(device)) print("done")