Beiträge von Tone

    Hello, I have a Rpi3 (Raspbian Stretch and Kodi 18.2 with Hyperion) and it syncs perfectly. Now I have a yeelight color version 2. I have activate LAN-Control and I can do ping to my bulb.


    When I run yee.py with my bulb off, yee.py put my bulb on (white).



    My yee.py is:


    #!/usr/bin/python
    import socket
    import time
    import math
    from yeelight import *
    ip_address = "10.42.0.233"
    timeout = 200
    def rgb2hsv(r, g, b):
    r, g, b = r/255.0, g/255.0, b/255.0
    mx = max(r, g, b)
    mn = min(r, g, b)
    df = mx-mn
    if mx == mn:
    h = 0
    elif mx == r:
    h = (60 * ((g-b)/df) + 360) % 360
    elif mx == g:
    h = (60 * ((b-r)/df) + 120) % 360
    elif mx == b:
    h = (60 * ((r-g)/df) + 240) % 360
    if mx == 0:
    s = 0
    else:
    s = df/mx
    v = mx
    return round(h), round(s * 100, 1), round(v * 100, 1)
    #UDP SERVER
    port = 20450
    last = ""
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.bind(("", port))
    print("waiting on port:", port)
    #YEELIGHT
    bulb = Bulb(ip_address, effect="smooth", duration=timeout)
    bulb.turn_on()
    status = "on";
    # bulb.effect = "smooth"
    #Stop/Start music mode, bypasses lamp rate limits, ensures that previous sockets close before starting
    while True:
    try:
    bulb.stop_music()
    break
    except BulbException:
    break
    time.sleep(1)
    while True:
    try:
    bulb.start_music()
    break
    except BulbException:
    break
    time.sleep(1)
    try:
    while True:
    d = s.recvfrom(3)
    new = bytearray(d[0])
    hsv = rgb2hsv(new[0], new[1], new[2])
    if new != last:
    if hsv[2] == 0.0:
    if status == "on":
    bulb.turn_off()
    status = "off"
    elif status == "off":
    bulb = Bulb(ip_address, effect="smooth", duration=timeout)
    while True:
    try:
    bulb.start_music()
    break
    except BulbException:
    break
    bulb.turn_on()
    status = "on"
    if status == "on":
    bulb.set_hsv(*hsv)
    last = new
    except KeyboardInterrupt:
    print("Exit ...")




    My yeelight.config.json is:


    {
    "device" :
    {
    "name" : "MyPiudp",
    "type" : "udp",
    "output" : "127.0.0.1:20450", "protocol" : 0,
    "rate" : 1000000,
    "colorOrder" : "rgb"
    },
    // COLOR CALIBRATION CONFIG
    "color" :
    {
    "transform" :
    [
    {
    "id" : "default",
    "leds" : "*",
    "hsl" :
    {
    "saturationGain" : 1.0000,
    "luminanceGain" : 1.0000,
    "luminanceMinimum" : 0.0000
    },
    "red" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.3000
    },
    "green" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.3000
    },
    "blue" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.4000
    }
    }
    ],
    // SMOOTHING CONFIG
    "smoothing" :
    {
    "type" : "linear",
    "time_ms" : 200,
    "updateFrequency" : 20.0000,
    // "updateDelay" : 0
    }
    },
    // JSON SERVER CONFIG
    "jsonServer" :
    {
    "port" : 19450
    },
    // PROTO SERVER CONFIG
    "protoServer" :
    {
    "port" : 19451
    },
    "leds" :
    [
    {
    "index" : 0,
    "hscan" : { "minimum" : 0.0000, "maximum" : 0.1000 },
    "vscan" : { "minimum" : 0.0000, "maximum" : 1.0000 }
    }
    ],

    "blackborderdetector" :
    {
    "enable" : true,
    "threshold" : 0.1
    },

    "endOfJson" : "endOfJson"
    }



    And in hyperion.config.json I added:


    "forwarder" :
    {
    "json" : [ "127.0.0.1:19450" ],
    "proto" : [ "127.0.0.1:19451" ]
    },
    "endOfJson" : "endOfJson"



    What am I doing wrong? Because when I run python yee.py only put the yeelight on (white) if previously is off, but if I see a film only sync the leds strip I have on tv.