Skip to content

PerfecXX/Micropython-Linenotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Micropython-linenotify

Version License

It is a MicroPython library for sending notifications to Line Notify,which can be used with ESP8266 and ESP32.

Can send both text messages, stickers and images.

Installation

Before you receive any messages, you need to install this library on your device.

by choosing one of the following methods:

  1. Manual upload

    • You can install this library by simply uploading linenotify.py to your device.
  2. Package Management in Thonny IDE

    • If you are using the Thonny IDE, you can go to Tools > Manage Packages.
    • At the search bar, simply search for "micropython-linenotify" and install it.

Prerequisite

  • ESP32/ESP8266 with MicroPython installed and can connect to the internet
  • Line Notify Token

How to get Line Notify Token

Login at https://notify-bot.line.me/en/.

At the top-right dropdown menu, select my page .

Scroll down the browser window to find Generate Token.

Enter your Notify Name then select chat or group.

Click Generate Token, and the token will be generated.

Usage

  • Import Library
from linenotify import LineNotify
  • Create Instance and set token
line = LineNotify('<token>')
  • Notify text message
line.notify('<message>')
  • Notify sticker with text message

Sticker List: https://developers.line.biz/en/docs/messaging-api/sticker-list/

line.notifySticker('<Sticker Package ID>','<Sticker ID>','<Message>')
  • Notify image from URL with text message
line.notifyImageURL('<Image URL>','<Message>')

Example Code

# Import Library
from linenotify import LineNotify
from network import WLAN,STA_IF

# Network Setup
ssid = '<ssid>'
password = '<password>'
wlan = WLAN(STA_IF)
wlan.active(True)
print('Connecting...')
wlan.connect(ssid,password)
while not wlan.isconnected():
    pass
print(wlan.ifconfig())

# Set Line Token 
line = LineNotify('<token>')
# Notify text message 
line.notify('Hello World!')
# Notify sticker with message
line.notifySticker(3,240,'Nice Sticker')
# Notify image from URL with message
line.notifyImageURL('https://static.wikia.nocookie.net/chainsaw-man/images/1/1b/Pochita.PNG','Pochita')

Reference

https://developers.line.biz/en/docs/messaging-api/sticker-list/

https://notify-bot.line.me/doc/en/