This commit is contained in:
marcusferl 2022-03-12 23:59:01 +01:00
parent d2b22e4d54
commit 4d4c2bd530
5 changed files with 21 additions and 30 deletions

View File

@ -8,6 +8,14 @@
Migration von JavaScript zu Python
<h4>Funktionen</h4>
<ul>
<li>Müllkalender</li>
<li>Geburtstage</li>
<li>Feiertage</li>
<li>Zufällige Zitate</li>
</ul>
### Config

View File

@ -1,4 +1,4 @@
host = 'Device IP' # ur device ip, where u upload the matrix.ino
host = 'Device_Ip' # ur device ip, where u upload the matrix.ino
#Edit the Events, decide what u wanna show on you Led Matrix
garbage = 'true'

View File

@ -1,7 +1,6 @@
# Digit converter
import json
def digit_convert(filename):
with open(filename, 'r') as file:
data = json.load(file)
@ -12,11 +11,9 @@ def digit_convert(filename):
with open('events.json', 'w') as file:
json.dump(data, file, indent=2)
if len(i['date']['month']) != 2:
i['date']['month'] = str('{:02d}'.format(i['date']['month']))
with open('events.json', 'w') as file:
json.dump(data, file, indent=2)
digit_convert('events.json')

View File

@ -8,8 +8,7 @@ import json
from datetime import date
import requests
import config
import datetime
import random
# Get current Date
def get_current_date():
@ -17,9 +16,8 @@ def get_current_date():
day = str('{:02d}'.format(currentDate.day))
month = str('{:02d}'.format(currentDate.month))
year = str(currentDate.year)
tomorrow_date = date.today() + datetime.timedelta(days=1)
tomorrow = str('{:02d}'.format(tomorrow_date.day))
return [day, month, year, tomorrow]
return [day, month, year]
# Raw data from Json file
def read_JSON(filename):
@ -28,13 +26,6 @@ def read_JSON(filename):
f.close()
return data
# Creat default Message
def default_message():
lines = []
with open('zitate.txt', 'r') as file:
for l in file:
lines.append(l)
return random.choice(lines)
# Returns the Garbage
def create_Message():
@ -44,9 +35,7 @@ def create_Message():
for i in read_JSON('muell.json'):
day = i['date']['day']
month = i['date']['month']
if day == get_current_date()[3] and month == get_current_date()[1]:
message = message + ' Morgen: ' + i['name']
elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]:
if day == get_current_date()[0] and month == get_current_date()[1]:
message = message + ' ' + i['name']
if config.events == 'true':
@ -54,9 +43,7 @@ def create_Message():
for i in read_JSON(filename):
day = i['date']['day']
month = i['date']['month']
if day == get_current_date()[3] and month == get_current_date()[1]:
message = message + ' Morgen: ' + i['name']
elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]:
if day == get_current_date()[0] and month == get_current_date()[1]:
message = message + ' ' + i['name']
if config.holidays == 'true':
@ -64,19 +51,14 @@ def create_Message():
for i in read_JSON(filename):
day = i['date']['day']
month = i['date']['month']
if day == get_current_date()[3] and month == get_current_date()[1]:
message = message + ' Morgen: ' + i['name']
elif int(day) == int(get_current_date()[0]) and month == get_current_date()[1]:
if day == get_current_date()[0] and month == get_current_date()[1]:
message = message + ' ' + i['name']
if len(message) < 5:
message = default_message()
return message
# Send Message to the Device
def matrixRequest():
requests.get('http://' + config.host + config.get_request + str(create_Message()))
# Main
matrixRequest()

View File

@ -115,7 +115,11 @@ Nur wer sein Ziel kennt, findet den Weg. - Laozi
Der Langsamste, der sein Ziel nur nicht aus den Augen verliert, geht immer noch geschwinder als der, der ohne Ziel herumirrt. - Gotthold Ephraim Lessing
Ziele zu setzen ist der erste Schritt das unsichtbare in das sichtbare zu verwandeln. - Tony Robbins
Der Mensch arbeitet immer fuer ein Ziel. Wer jedoch keine eigenen Ziele hat, arbeitet fuer die von Anderen. - Brian Tracy
<<<<<<< HEAD
Fordert man sich nicht unablaessig selber heraus, verdorrt man. - Lido Lee Iacocca
=======
Fordert man sich nicht unablaessig selber heraus, verdorrt man. - Lido Lee Iacocca
>>>>>>> 046c2bb (update)
Man muss das Unmoegliche versuchen, um das moegliche zu erreichen. - Hermann Hesse
Nichts verschafft mehr Ruhe, als ein gefasster Entschluss. - Charles Maurice de Talleyrand
Erst Ziele geben unserem Leben einen Sinn.— C.H. Parkhurst