Skip to content

Commit

Permalink
Merge to master (blynkkk#1)
Browse files Browse the repository at this point in the history
Initial release to master
  • Loading branch information
antohaUa authored Mar 4, 2019
1 parent 81facc6 commit 7cd3a0c
Show file tree
Hide file tree
Showing 17 changed files with 1,573 additions and 2 deletions.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2019 Anton Morozenko
Copyright (c) 2015-2019 Volodymyr Shymanskyy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
115 changes: 113 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,113 @@
# lib-python
Blynk Library for Python
# Blynk Python Library
Blynk Python/Micropython Library

## What is Blynk?
**[Blynk][blynk-io]** provides **iOS** and **Android** apps to control any hardware **over the Internet** or **directly using Bluetooth**.
You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets, **right on your smartphone**.
Blynk is **the most popular IoT platform** used by design studios, makers, educators, and equipment vendors all over the world.

![Blynk Banner][blynk-banner]

## Download

**Blynk App:
[<img src="https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/googleplay.svg" width="18" height="18" /> Google Play][blynk-app-android] |
[<img src="https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/apple.svg" width="18" height="18" /> App Store][blynk-app-ios]**

Optionally: **[Blynk Server][blynk-server]**. Public Blynk Cloud is free for anyone who is using Blynk for personal (non-commercial) purposes.

![Blynk Architecture][blynk-architecture]

## Installation

#### Installation via Python pip
sudo pip install blynklib


#### Manual installation
git clone https://github.com/blynkkk/lib-python.git
cd lib-python
pip install --user -e .

# sudo pip install -e . # if installation needed not for current but for all users

#### Testing
You can run unit tests using the command:

python setup.py test

## Features
Library allows to communicate with public or custom [Blynk Server][blynk-server].

Supports Python2/Python3/Micropython.

HW support of RaspberryPi/ESP32

##### List of available operations:
- connect/disconnect events subscribe
- read/write [virtual pins][blynk-vpins] events subscribe
- [virtual pin][blynk-vpins] write
- [virtual pin][blynk-vpins] sync
- internal app notifications
- email notifications
- set widget property


## [Quickstart][blynk-docs]
Install Blynk python library
Download Blynk App ([GooglePlay][blynk-app-android] | [Apple][blynk-app-ios]) and register within it.
During registration personal auth token will be provided. Use this token within your python scripts to pass
[public][blynk-server-public] or [custom][blynk-server] Blynk server authentification.

#### Usage example
```py
import blynklib

BLYNK_AUTH = '<YourAuthToken>'
blynk = blynklib.Blynk(BLYNK_AUTH)

# register handler for virtual pin V11 reading
# for example when some Blynk App widget asks virtual pin data from server periodically
@blynk.handle_event('read V11')
def read_virtual_pin_handler(pin):

# user code for this event goes here
# ...
# Example: calculate, get sensor values, current time etc

# update current virtual pin value on server
blynk.virtual_write(pin, <USER_CALCULATED_VALUE>)
# or any other pin if needed
# blynk.virtual_write(24, '<ANY_OTHER_USER_CALCULATED_VALUE>')

# actions if calculated value become CRITICAL
if <USER_CALCULATED_VALUE> >= <USER_DEFINED_CRITICAL_VALUE>
# set red color for widget that performs periodical virtual pin read operations
blynk.set_property(pin, 'color', '#FF0000')
# send internal notification to Blynk App and notification to defined e-mail
blynk.notify('Warning critical value')
blynk.email(<Your e-mail>, 'Device alarm', 'Critical value!')

# main loop that starts program and handles registered events
while True:
blynk.run()
```

Examine more **[examples][blynk-py-examples]** to be familiar with basic features usage.


### License
This project is released under The MIT License (MIT)



[blynk-io]: https://github.com/blynkkk/blynkkk.github.io
[blynk-architecture]: https://github.com/blynkkk/blynkkk.github.io/blob/master/images/architecture.png
[blynk-banner]: https://github.com/blynkkk/blynkkk.github.io/blob/master/images/GithubBanner.jpg
[blynk-server]: https://github.com/blynkkk/blynk-server
[blynk-server-public]: http://blynk-cloud.com
[blynk-docs]: https://docs.blynk.cc/
[blynk-py-examples]: https://github.com/blynkkk/lib-python/blob/master/examples
[blynk-app-android]: https://play.google.com/store/apps/details?id=cc.blynk
[blynk-app-ios]: https://itunes.apple.com/us/app/blynk-control-arduino-raspberry/id808760481?ls=1&mt=8
[blynk-vpins]: http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/what-is-virtual-pins
Loading

0 comments on commit 7cd3a0c

Please sign in to comment.