Fixed dashboard to use new washinsa format

This commit is contained in:
Arnaud Vergnet 2020-07-02 12:11:25 +02:00
parent 7cb08b17eb
commit 943f55b084
3 changed files with 64 additions and 52 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
/facebook/token /facebook/token
/washinsa/washinsa.json /washinsa/washinsa_data.json
/facebook/facebook_data.json /facebook/facebook_data.json
/dashboard/dashboard_data.json /dashboard/dashboard_data.json
/menu/menu_data.json /menu/menu_data.json

View file

@ -2,101 +2,113 @@
"dryers": [ "dryers": [
{ {
"number": "1", "number": "1",
"state": "DISPONIBLE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
}, },
{ {
"number": "2", "number": "2",
"state": "EN COURS", "donePercent": "",
"startTime": "15:24", "startTime": "",
"endTime": "15:59", "state": 0,
"donePercent": "62.9", "program": "",
"remainingTime": "13" "endTime": "",
"remainingTime": ""
}, },
{ {
"number": "3", "number": "3",
"state": "TERMINE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
} }
], ],
"washers": [ "washers": [
{ {
"number": "4", "number": "4",
"state": "EN COURS", "donePercent": "68.9",
"startTime": "\u00a0", "startTime": "11:32",
"endTime": "\u00a0", "state": 1,
"donePercent": "", "program": "Couleurs 60\u00b0C & Lessive Automatique",
"remainingTime": "0" "endTime": "12:21",
"remainingTime": "15"
}, },
{ {
"number": "5", "number": "5",
"state": "EN COURS", "donePercent": "",
"startTime": "15:35", "startTime": "",
"endTime": "16:15", "state": 0,
"donePercent": "26.9", "program": "",
"remainingTime": "29" "endTime": "",
"remainingTime": ""
}, },
{ {
"number": "6", "number": "6",
"state": "DISPONIBLE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
}, },
{ {
"number": "7", "number": "7",
"state": "EN COURS", "donePercent": "",
"startTime": "15:34", "startTime": "",
"endTime": "16:19", "state": 3,
"donePercent": "26", "program": "",
"remainingTime": "33" "endTime": "",
"remainingTime": ""
}, },
{ {
"number": "8", "number": "8",
"state": "DISPONIBLE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
}, },
{ {
"number": "9", "number": "9",
"state": "DISPONIBLE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
}, },
{ {
"number": "10", "number": "10",
"state": "DISPONIBLE", "donePercent": "58.2",
"startTime": "", "startTime": "11:39",
"endTime": "", "state": 1,
"donePercent": "", "program": "Non repassable 40\u00b0C",
"remainingTime": "" "endTime": "12:24",
"remainingTime": "19"
}, },
{ {
"number": "11", "number": "11",
"state": "DISPONIBLE",
"startTime": "",
"endTime": "",
"donePercent": "", "donePercent": "",
"startTime": "",
"state": 0,
"program": "",
"endTime": "",
"remainingTime": "" "remainingTime": ""
}, },
{ {
"number": "12", "number": "12",
"state": "EN COURS", "donePercent": "",
"startTime": "15:02", "startTime": "",
"endTime": "15:47", "state": 4,
"donePercent": "97.7", "program": "",
"remainingTime": "1" "endTime": "",
"remainingTime": ""
} }
] ]
} }

View file

@ -3,7 +3,7 @@ from datetime import date
import urllib.request import urllib.request
import os.path import os.path
WASHINSA_FILE = '../washinsa/washinsa.json' WASHINSA_FILE = '../washinsa/washinsa_data.json'
MENU_FILE = '../menu/menu_data.json' MENU_FILE = '../menu/menu_data.json'
FACEBOOK_FILE = '../facebook/facebook_data.json' FACEBOOK_FILE = '../facebook/facebook_data.json'
@ -56,10 +56,10 @@ def get_available_machines():
available_dryers = 0 available_dryers = 0
available_washers = 0 available_washers = 0
for machine in data['dryers']: for machine in data['dryers']:
if machine['state'] == 'DISPONIBLE': if machine['state'] == 0:
available_dryers += 1 available_dryers += 1
for machine in data['washers']: for machine in data['washers']:
if machine['state'] == 'DISPONIBLE': if machine['state'] == 0:
available_washers += 1 available_washers += 1
except FileNotFoundError: except FileNotFoundError:
print("Could not find " + WASHINSA_FILE) print("Could not find " + WASHINSA_FILE)