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
/washinsa/washinsa.json
/washinsa/washinsa_data.json
/facebook/facebook_data.json
/dashboard/dashboard_data.json
/menu/menu_data.json

View file

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

View file

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