#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMIOT from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miotType('BLINKER_MIOT_SENSOR') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 def miotQuery(queryCode): ''' ''' BLINKER_LOG('MIOT Query codes: ', queryCode) if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER: BLINKER_LOG('MIOT Query All') BlinkerMIOT.temp(20) BlinkerMIOT.humi(20) BlinkerMIOT.pm25(20)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMIOT from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * import os auth = 'Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miotType('BLINKER_MIOT_OUTLET') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 oState = 'on' def miotPowerState(state): global oState global counter BLINKER_LOG('need set power state: ', state) oState = state BlinkerMIOT.powerState(state) BlinkerMIOT.print() if state == 'true': os.system("ping -c 4 www.bing.com") # 使用系统命令ping www.bing.com
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber, BlinkerMIOT from Blinker.BlinkerConfig import * from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode('BLINKER_WIFI') Blinker.miotType('BLINKER_MIOT_LIGHT') Blinker.begin(auth) button1 = BlinkerButton('btn-abc') number1 = BlinkerNumber('num-abc') counter = 0 wsState = 'on' wsMode = BLINKER_CMD_COMMON def miotPowerState(state): ''' ''' BLINKER_LOG('need set power state: ', state) BlinkerMIOT.powerState(state) BlinkerMIOT.print()