Initial commit
This commit is contained in:
21
scripts/lywsd03mmc
Executable file
21
scripts/lywsd03mmc
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
import lywsd03mmc
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('mac', help='MAC address of LYWSD02 device', nargs='+')
|
||||
args = parser.parse_args()
|
||||
|
||||
for mac in args.mac:
|
||||
try:
|
||||
client = lywsd03mmc.Lywsd03mmcClient(mac)
|
||||
print('Fetching data from {}'.format(mac))
|
||||
data = client.data
|
||||
print('Temperature: {}°C'.format(data.temperature))
|
||||
print('Humidity: {}%'.format(data.humidity))
|
||||
print('Battery: {}%'.format(client.battery))
|
||||
print()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
34
scripts/lywsd03mmc2csv
Executable file
34
scripts/lywsd03mmc2csv
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
import lywsd03mmc
|
||||
import csv
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('mac', help='MAC address of LYWSD03MMC device')
|
||||
parser.add_argument('--output', help='File to output', default='output.csv')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.output, 'w') as csvfile:
|
||||
c = csv.writer(csvfile)
|
||||
c.writerow(["Time", "Min temperature", "Min humidity", "Max temperature", "Max humidity"])
|
||||
|
||||
try:
|
||||
client = lywsd03mmc.Lywsd03mmcClient(args.mac)
|
||||
print('Fetching data from {}'.format(args.mac))
|
||||
data = client.data
|
||||
print('Temperature: {}'.format(data.temperature))
|
||||
print('Humidity: {}%'.format(data.humidity))
|
||||
print('Battery: {}%'.format(data.battery))
|
||||
print('Device start time: {}'.format(client.start_time))
|
||||
print()
|
||||
print('Fetching history from {}'.format(args.mac))
|
||||
client.enable_history_progress = True
|
||||
history = client.history_data
|
||||
for i in history:
|
||||
c.writerow(history[i])
|
||||
print('Done')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Reference in New Issue
Block a user