You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
927 B

from os import sys, path
7 years ago
USAGE = '''
python3 read.py [device] <mac-address>
7 years ago
DEVICE:
flora Mi Flower Care
mijia Mijia Temperature & Humidity sensor
7 years ago
'''
7 years ago
def UsageAndExit(msg):
if msg:
print(msg)
print(USAGE)
sys.exit(0)
7 years ago
if __name__ == '__main__' and __package__ is None:
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from dynamo import save_data
argv = sys.argv[1:]
if len(argv) != 2:
UsageAndExit()
7 years ago
supported_devices = ['flora', 'mijia']
if argv[0] not in supported_devices:
UsageAndExit("Unsupported devices")
device, mac_addr = argv
if device == 'flora':
from miflora.miflora.miflora_poller import MiFloraPoller
poller = MiFloraPoller(mac_addr)
elif device == 'mijia':
from mijia.mijia.mijia_poller import MijiaPoller
poller = MijiaPoller(mac_addr)
save_data(device, poller)