Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Smart lamp Philips ZhiRui e27 connect

General discussion about anything TouchDesigner

Smart lamp Philips ZhiRui e27 connect

Postby sequoia » Tue Aug 20, 2019 8:26 am

Hello derivative community!
Got himself a smart lamp Philips ZhiRui e27. Already got to control it with python.
Two simple steps made it possible to do it.

The first is to get the token from the lamp - https://github.com/jghaanstra/com.xiaom ... n_token.md

The second install miio library in python - https://github.com/rytilahti/python-miio and
https://github.com/aholstenson/miio#installation

Then, I wrote just a simple code to flash my light bulb (attached to the message)
Running the code in cmd all works well, the light flashes
But when I try to run the same code in touchdesigner. TD does not find the miio library. (a screenshot of the error attached)
Maybe there will be experts who will tell you how to fix it.

Code: Select all
#!/usr/bin/python3

IP = '192.168.0.18'
# to list smart devices open terminal -> $ mirobo discover --handshake 1
TOKEN = '982b468a7419121c1b83e7ca89911fd7'

DELAY = 0.1

import sys
import argparse
import site
import time

path = ''
path = site.getsitepackages()
for i in path:
    sys.path.append(i)

import miio.philips_bulb

def lamp_send(level, temp, power=''):

    MyBulb = miio.philips_bulb.PhilipsBulb(IP, TOKEN)

    MyBulb.set_brightness(level)
    MyBulb.set_color_temperature(temp)

    if power == "ON":
        MyBulb.on()
    elif power == "OFF":
        MyBulb.off()

    print(MyBulb.status())

time.sleep(1)

while True:
    for i in range(5):
        lamp_send(i*20 + 1, 1)
        time.sleep(DELAY)

    for i in range(5):
        lamp_send(100, i*20 + 1)
        time.sleep(DELAY)

    for i in range(5):
        lamp_send(100 - i*20, 100)
        time.sleep(DELAY)
Attachments
Capture.PNG
Capture.PNG (530.29 KiB) Viewed 287 times
sequoia
 
Posts: 3
Joined: Fri Sep 02, 2016 12:36 pm

Return to General TouchDesigner Discussion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 16 guests