48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
"""
|
|
Eventboard script in Python
|
|
Author: Marcus Ferl
|
|
Email: marcus@weifer.de
|
|
"""
|
|
|
|
import json
|
|
from datetime import date
|
|
import requests
|
|
import config
|
|
|
|
|
|
# Get current Date
|
|
def get_current_date():
|
|
currentDate = date.today()
|
|
day = str('{:02d}'.format(currentDate.day))
|
|
month = str('{:02d}'.format(currentDate.month))
|
|
year = str(currentDate.year)
|
|
return [day, month, year]
|
|
|
|
|
|
# Raw data from Json file
|
|
def read_JSON(filename):
|
|
f = open(filename)
|
|
data = json.load(f)
|
|
f.close()
|
|
return data
|
|
|
|
# Returns the Garbage
|
|
def create_Message():
|
|
if config.garbage == 'true':
|
|
for i in read_JSON('muell.json'):
|
|
day = i['date']['day']
|
|
month = i['date']['month']
|
|
year = i['date']['year']
|
|
|
|
if day == get_current_date()[0] and \
|
|
month == get_current_date()[1] and \
|
|
year == get_current_date()[2]:
|
|
return i['name']
|
|
|
|
# Send Message to the Device
|
|
def matrixRequest():
|
|
requests.get('http://' + config.host + config.get_request + create_Message())
|
|
|
|
|
|
matrixRequest()
|