diff --git a/main.py b/main.py index 27cfe70..6bed5ba 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,12 @@ from miio.airpurifier import AirPurifier, OperationMode, LedBrightness +from miio.discovery import create_device from collections import namedtuple from datetime import datetime import time from influxdb import InfluxDBClient import json from systemd import daemon - +import socket class Message(namedtuple('Message', ('measurement', 'time', 'tags', 'fields'))): __slots__ = () @@ -34,8 +35,8 @@ if __name__ == '__main__': try: metric = InfluxDBClient('db', database='core', use_udp=True, udp_port=8089) - - dev = AirPurifier('air', '6e1e05b87d9f7cd10a3f8f43616896fa') + air_addr=socket.gethostbyname("air") + dev = create_device(air_addr,AirPurifier) tags = { 'source': 'mi_air_2', 'position': 'center_room',