From 149d96b8a0b7735adf0b01064148ba0a8623c353 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 17 Feb 2022 15:55:10 +0100 Subject: [PATCH] update --- config.py | 2 +- digit_converter.py | 22 ++++++++++++++++++++++ eventboard.py | 5 +---- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 digit_converter.py diff --git a/config.py b/config.py index 5dea836..9ab30f5 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -host = '192.168.0.19' # 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' diff --git a/digit_converter.py b/digit_converter.py new file mode 100644 index 0000000..3948e9f --- /dev/null +++ b/digit_converter.py @@ -0,0 +1,22 @@ +# Digit converter +import json + + +def digit_convert(filename): + with open(filename, 'r') as file: + data = json.load(file) + + for i in data: + if len(i['date']['day']) != 2: + i['date']['day'] = str('{:02d}'.format(i['date']['day'])) + 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') \ No newline at end of file diff --git a/eventboard.py b/eventboard.py index 81eeae0..5c770aa 100644 --- a/eventboard.py +++ b/eventboard.py @@ -38,7 +38,6 @@ def create_Message(): if day == get_current_date()[0] and month == get_current_date()[1]: message = message + ' ' + i['name'] - if config.events == 'true': filename = 'events.json' for i in read_JSON(filename): @@ -56,12 +55,10 @@ def create_Message(): message = message + ' ' + i['message'] - - - # Send Message to the Device def matrixRequest(): requests.get('http://' + config.host + config.get_request + str(create_Message())) +# Main matrixRequest()