GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — iot_assignment/notification.py at master · Gr4nts/iot_assignment

Expand file tree

/

notification.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
41 lines (34 loc) · 1.1 KB
/

notification.py

Copy path

File metadata and controls

41 lines (34 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
from sense_hat import SenseHat
import requests
import json
import os
ACCESS_TOKEN="o.6sbKQW77lMj9a9ezmLSzbyhuqgbG7htV"
sense = SenseHat()
temp = sense.get_temperature()
def send_notification_via_pushbullet(title):
""" Sending notification via pushbullet.
Args:
title (str) : title of text.
body (str) : Body of text.
"""
data_send = {"type": "note", "title": title}
resp = requests.post('https://api.pushbullet.com/v2/pushes', data=json.dumps(d$
headers={'Authorization': 'Bearer ' + ACCESS_TOKEN,
'Content-Type': 'application/json'})
if resp.status_code != 200:
raise Exception('Something wrong')
else:
print('complete sending')
def getSenseHatData():
sense = SenseHat()
temp = sense.get_temperature()
if temp is not None:
temp = round(temp, 1)
def main():
getSenseHatData()
if temp <= 20:
send_notification_via_pushbullet("Time to put on a sweater bro!")
else:
send_notification_via_pushbullet("Its a nice day today")
main()
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.