From 8e0beec40f74e085aecf143f8537b70c41c24930 Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Sun, 22 Oct 2017 18:33:48 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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',