-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (25 loc) · 959 Bytes
/
main.py
File metadata and controls
31 lines (25 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from irController import mapingController, ir_transmitter
from time import sleep
import json
def parseCommandFromAWS(msg):
try:
with open('mappedButtons.json', 'r') as r:
mappedButtonsJson = json.loads(r.read())
r.close()
except:
print('Could not open mappedButtons File.')
mapController = input('Do you want to map a remote controller right now? [Y/N] ')
if mapController.upper() == 'Y':
mapingController()
with open('mappedButtons.json', 'r') as r:
mappedButtonsJson = json.loads(r.read())
else:
return
for word in msg:
if word in mappedButtonsJson.keys():
print(f'\n\nsending signal - {word}\n\n')
sleep(3)
ir_transmitter(mappedButtonsJson[word])
if __name__ == '__main__':
msg = 'tell BR to power the TV and then put on netflix'
parseCommandFromAWS(msg.split(' '))