Coder Social home page Coder Social logo

blynkapi's Introduction

blynkapi

This is a simple blynk HTTP/HTTPS API wrapper.

Introduction

This library created for simple using Blynk API and manage your project via python. It's simple one class lib which used urllib2 for requests.

You can also:

  • Read/write pin value
  • Check hardware network status
  • Check application network status
  • Send push notification
  • Send email
  • Get pin history data
  • Get QR for project cloning
  • Get project info
  • Query API

Installation

Install via pip

pip install blynkapi

after installation import it in your code

from blynkapi import Blynk

Or simple copy blynkapi/Blynk.py to your main python program dir and import it

from Blynk import *

Using

# if you install it from pip, else use `from Blynk import *`
from blynkapi import Blynk
# vars
auth_token = "sdjflksjflkdsjfkldsjfkldfkldjflk"

# create objects
room_light = Blynk(auth_token, pin = "V3")
kitchen_light = Blynk(auth_token, pin = "V4")
house_door = Blynk(auth_token, pin = "V5")
amp_power = Blynk(auth_token, pin = "V6")

# get current status
res = room_light.get_val()
print res

# set pin value (one)
amp_power.set_val(["120"])

# set pin value to 1
room_light.on()
# set pin value to 0
room_light.off()

Available methods

All methods return values from API or error if it fixed. For detailed description of returning values and scheme read official [Blynk API guide] (http://docs.blynkapi.apiary.io/#reference)

Creating main object

Blynk(token, server, protocol, port, pin, value)
  • token - Your project token
  • server - Blynk server for API requests, default "blynk-cloud.com"
  • protocol - http or https, default "http"
  • port - Your Blynk server API port, default "8080"
  • pin - Pin for working with, default "None"
  • value - Value for method get_val, default "None"

To turn pin on (set val "1" to pin)

on()

To turn pin off (set val "0" to pin)

off()

To set your value for pin

set_val(value)

To get data from pin

get_val()

Send push notification

push(value)
  • value - String no more than 255 chars.

Send email

email(to, title, subj)
  • to - String
  • title - String
  • subj - String

Check hardware status (connection to server)

hw_status()

Check app status (connection to server)

app_status()

Get pin history

history()

Get QR image

qr()

Get project info For details see [docs] (http://docs.blynkapi.apiary.io/#reference/0/get-project/get-project)

get_project()

Query API. For details see [docs] (http://docs.blynkapi.apiary.io/#reference/0/query-api/query-api)

query_api(groupBy, aggregation, pin, value)
  • groupBy - String
  • aggregation - String
  • pin - String
  • value - String

Todos

  • Write Tests

License

MIT

blynkapi's People

Contributors

xandr2 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.