示例#1
0
def miotBright(bright):
    ''' '''

    BLINKER_LOG('need set brightness: ', bright)

    BlinkerMiot.brightness(bright)
    BlinkerMiot.print()
示例#2
0
def miotColor(color):
    ''' '''

    BLINKER_LOG('need set color: ', color)

    # if color == 'Red':
    #     # your codes
    # elif color == 'Yellow':
    #     # your codes
    # elif color == 'Blue':
    #     # your codes
    # elif color == 'Green':
    #     # your codes
    # elif color == 'White':
    #     # your codes
    # elif color == 'Black':
    #     # your codes
    # elif color == 'Cyan':
    #     # your codes
    # elif color == 'Purple':
    #     # your codes
    # elif color == 'Orange':
    #     # your codes

    BlinkerMiot.color(color)
    BlinkerMiot.print()
示例#3
0
def miotColorTemp(colorTemp):
    ''' '''

    BLINKER_LOG('need set colorTemperature: ', colorTemp)

    BlinkerMiot.colorTemp(colorTemp)
    BlinkerMiot.print()
示例#4
0
def miotPowerState(state):
    ''' '''

    BLINKER_LOG('need set power state: ', state)
    wsState = state and 'on' or 'off'
    BlinkerMiot.powerState(wsState)
    BlinkerMiot.print()
示例#5
0
def miotPowerState(state):
    ''' '''

    global oState

    BLINKER_LOG('need set power state: ', state)

    oState = state

    BlinkerMiot.powerState(state)
    BlinkerMiot.print()
示例#6
0
def miotPowerState(state, num):
    ''' '''

    BLINKER_LOG("need set outlet: ", num, ", power state: ", state)

    global wsState
    wsState[num] = state

    if num == 0 and state == 'false':
        for i in len(wsState):
            wsState[i] = state

    BlinkerMiot.powerState(state, num)
    BlinkerMiot.print()
示例#7
0
def miotcMode(cmode):
    ''' '''

    BLINKER_LOG('need cancel mode: ', cmode)

    # if mode == BLINKER_CMD_MIOT_READING:
    #     # Your mode function
    # elif mode == BLINKER_CMD_MIOT_MOVIE:
    #     # Your mode function
    # elif mode == BLINKER_CMD_MIOT_SLEEP:
    #     # Your mode function
    # elif mode == BLINKER_CMD_MIOT_HOLIDAY:
    #     # Your mode function
    # elif mode == BLINKER_CMD_Miot_MUSIC:
    #     # Your mode function
    # elif mode == BLINKER_CMD_MIOT_COMMON:
    #     # Your mode function

    BlinkerMiot.mode(cMode)
    BlinkerMiot.print()
示例#8
0
def miotQuery(queryCode):
    ''' '''

    BLINKER_LOG('Miot Query codes: ', queryCode)

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER:
        BLINKER_LOG('Miot Query All')
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.color(_getCurColor())
        BlinkerMiot.mode(wsMode)
        BlinkerMiot.colorTemp(50)
        BlinkerMiot.brightness(100)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER:
        BLINKER_LOG('Miot Query Power State')
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_COLOR_NUMBER:
        BLINKER_LOG('Miot Query Color')
        BlinkerMiot.color('red')
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_MODE_NUMBER:
        BLINKER_LOG('Miot Query Mode')
        BlinkerMiot.mode(wsMode)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_COLORTEMP_NUMBER:
        BLINKER_LOG('Miot Query ColorTemperature')
        BlinkerMiot.colorTemp(50)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_BRIGHTNESS_NUMBER:
        BLINKER_LOG('Miot Query Brightness')
        BlinkerMiot.brightness(100)
        BlinkerMiot.print()
    else:
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.color('red')
        BlinkerMiot.mode(wsMode)
        BlinkerMiot.colorTemp(50)
        BlinkerMiot.brightness(100)
        BlinkerMiot.print()
示例#9
0
    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)


def data_callback(data):
    global counter

    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)


button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerMiot.attachPowerState(miotPowerState)
BlinkerMiot.attachColor(miotColor)
BlinkerMiot.attachMode(miotMode)
BlinkerMiot.attachCancelMode(miotcMode)
BlinkerMiot.attachBrightness(miotBright)
BlinkerMiot.attachColorTemperature(miotColorTemp)
BlinkerMiot.attachQuery(miotQuery)

if __name__ == '__main__':

    while True:
        Blinker.run()
示例#10
0
def miotQuery(queryCode):
    ''' '''

    global oState

    BLINKER_LOG('Miot Query codes: ', queryCode)

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER:
        BLINKER_LOG('Miot Query All')
        BlinkerMiot.powerState(oState)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER:
        BLINKER_LOG('Miot Query Power State')
        BlinkerMiot.powerState(oState)
        BlinkerMiot.print()
    else:
        BlinkerMiot.powerState(oState)
        BlinkerMiot.print()
示例#11
0
def button1_callback(state):
    ''' '''

    BLINKER_LOG('get button state: ', state)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)


def data_callback(data):
    global counter

    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)


button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerMiot.attachPowerState(miotPowerState)
BlinkerMiot.attachQuery(miotQuery)

if __name__ == '__main__':

    while True:
        Blinker.run()
示例#12
0
def miotQuery(queryCode, num):
    ''' '''

    BLINKER_LOG("Miot Query outlet: ", num,", codes: ", queryCode)

    global wsState
    state = 'off'
    
    for i, val in enumerate(wsState) :
        if i == num :
            state = val

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER :
        BLINKER_LOG('Miot Query All')
        BlinkerMiot.powerState(state, num)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
        BlinkerMiot.powerState(state, num)
        BlinkerMiot.print()
    else :
        BlinkerMiot.powerState(state, num)
        BlinkerMiot.print()
示例#13
0
def miQuery(queryCode):
    ''' '''

    BLINKER_LOG('MIOT Query codes: ', queryCode)

    if queryCode == BLINKER_CMD_QUERY_ALL_NUMBER:
        BLINKER_LOG('MIOT Query All')
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.aqi(19)
        BlinkerMiot.temp(20)
        BlinkerMiot.humi(21)
        BlinkerMiot.pm25(22)
        BlinkerMiot.co2(23)
        BlinkerMiot.print()
    elif queryCode == BLINKER_CMD_QUERY_POWERSTATE_NUMBER:
        BLINKER_LOG('Miot Query Power State')
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.print()
    else:
        BlinkerMiot.powerState(wsState)
        BlinkerMiot.aqi(24)
        BlinkerMiot.temp(25)
        BlinkerMiot.humi(26)
        BlinkerMiot.pm25(27)
        BlinkerMiot.co2(28)
        BlinkerMiot.print()
示例#14
0
def button1_callback(state):
    ''' '''

    BLINKER_LOG('get button state: ', state)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text(u'设备返回的text')
    button1.print(state)


def data_callback(data):
    global counter

    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)


button1.attach(button1_callback)
Blinker.attachData(data_callback)

BlinkerMiot.attachQuery(miQuery)
BlinkerMiot.attachPowerState(
    miotPowerState)  # 服务端未实现? 发送语言开关命令时没收到服务器发来的mqtt消息。但light类型的可以

if __name__ == '__main__':

    while True:
        Blinker.run()