Eventboard_v_2.0/eventboard.py

48 lines
1.1 KiB
Python
Raw Normal View History

2022-02-16 22:49:20 +01:00
"""
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():
2022-02-17 14:44:35 +01:00
requests.get('http://' + config.host + config.get_request + str(create_Message()))
2022-02-16 22:49:20 +01:00
matrixRequest()