You are not logged in.

#26 2018-04-17 16:39:32

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,808
Website

Re: How to detect dominant color on screen [SOLVED]

the code in previous post does that, it prints like this #BCBDBC
if you need to get rid of '#' sign just edit it out from this line

fmt.Printf("#%s\n", items[0].AsString())

https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

#27 2018-04-17 21:11:22

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,808
Website

Re: How to detect dominant color on screen [SOLVED]

prominent color for the active window

package main

import (
	"fmt"
	"image"

	"github.com/BurntSushi/xgb"
	"github.com/BurntSushi/xgb/xproto"
	"github.com/EdlinOrg/prominentcolor"
)

func main() {
	c, err := xgb.NewConn()
	if err != nil {
		panic(err)
	}
	aname := "_NET_ACTIVE_WINDOW"
	activeAtom, err := xproto.InternAtom(c, true, uint16(len(aname)), aname).Reply()
	if err != nil {
		panic(err)
	}
	screen := xproto.Setup(c).DefaultScreen(c)
	reply, err := xproto.GetProperty(c, false, screen.Root, activeAtom.Atom,
		xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
	if err != nil {
		panic(err)
	}
	windowId := xproto.Window(xgb.Get32(reply.Value))
	geo, err := xproto.GetGeometry(c, xproto.Drawable(windowId)).Reply()
	if err != nil {
		panic(err)
	}
	xImg, err := xproto.GetImage(c, xproto.ImageFormatZPixmap, xproto.Drawable(windowId), geo.X, geo.Y, uint16(geo.Width), uint16(geo.Height), 0xffffffff).Reply()
	if err != nil {
		panic(err)
	}

	data := xImg.Data
	for i := 0; i < len(data); i += 4 {
		data[i], data[i+2], data[i+3] = data[i+2], data[i], 255
	}
	img := &image.RGBA{data, 4 * int(geo.Width), image.Rect(0, 0, int(geo.Width), int(geo.Height))}
	items, err := prominentcolor.Kmeans(img)
	if err != nil {
		panic(err)
	}
	fmt.Printf("#%s\n", items[0].AsString())
}

https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

#28 2018-04-21 09:34:45

Cristhian
Member
Registered: 2018-02-17
Posts: 76

Re: How to detect dominant color on screen [SOLVED]

Hi, I'm sorry for posting so late! But I tested so much this solution and now I can say that:
1) The go program it's pretty fast and do its job
2) the script in python I use to send the command to the bulb have some problems. Here there are the error message and the link to the python script I use .

Setting the bulb to RGB #3D4042...
Setting the bulb to RGB #3D3F42...
Setting the bulb to RGB #2F291D...
Setting the bulb to RGB #211F21...
Setting the bulb to RGB #171717...
Setting the bulb to RGB #211F22...
Setting the bulb to RGB #211F22...
Setting the bulb to RGB #181718...
Setting the bulb to RGB #171718...
Setting the bulb to RGB #171718...
Setting the bulb to RGB #271E1A...
Setting the bulb to RGB #271E1A...
Setting the bulb to RGB #271E1A...
Setting the bulb to RGB #261D19...
Setting the bulb to RGB #261E1A...
Setting the bulb to RGB #261D19...
Setting the bulb to RGB #261C19...
Setting the bulb to RGB #4A3538...
Setting the bulb to RGB #4C3639...
Setting the bulb to RGB #4D3639...
Setting the bulb to RGB #4B090D...
Setting the bulb to RGB #51090F...
Setting the bulb to RGB #510A0F...
Setting the bulb to RGB #4E080D...
Setting the bulb to RGB #500A0E...
Setting the bulb to RGB #A45204...
Setting the bulb to RGB #A35204...
Setting the bulb to RGB #A04F04...
Setting the bulb to RGB #9F5004...
Setting the bulb to RGB #A05004...
Setting the bulb to RGB #A05004...
Setting the bulb to RGB #5D1F10...
Setting the bulb to RGB #8E7D42...
Setting the bulb to RGB #8D8148...
Setting the bulb to RGB #772211...
Setting the bulb to RGB #842917...
Setting the bulb to RGB #1D201D...
Setting the bulb to RGB #242A2E...
Setting the bulb to RGB #2A4A4A...
Setting the bulb to RGB #625432...
Setting the bulb to RGB #503B20...
Setting the bulb to RGB #483216...
Setting the bulb to RGB #977859...
Setting the bulb to RGB #617245...
Setting the bulb to RGB #A54846...
Setting the bulb to RGB #A64847...
Setting the bulb to RGB #A34745...
Setting the bulb to RGB #DACEC4...
Setting the bulb to RGB #14A09F...
Setting the bulb to RGB #60ADAD...
Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 324, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.
panic: Failed, no non-alpha pixels found (either fully transparent image, or the ColorBackgroundMask removed all pixels)

goroutine 1 [running]:
main.main()
        /home/sirth/Downloads/Scripts/main.go:54 +0x54f
exit status 2
Usage: yeecli rgb [OPTIONS] HEX_COLOR

Error: Missing argument "hex_color".
Setting the bulb to RGB #090102...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 282, in send_command
    self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 184, in _socket
    self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 288, in send_command
    raise_from(BulbException('A socket error occurred when sending the command.'), ex)
  File "/usr/lib/python3.6/site-packages/future/utils/__init__.py", line 398, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
yeelight.main.BulbException: A socket error occurred when sending the command.
Setting the bulb to RGB #64112B...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 282, in send_command
    self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 184, in _socket
    self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 288, in send_command
    raise_from(BulbException('A socket error occurred when sending the command.'), ex)
  File "/usr/lib/python3.6/site-packages/future/utils/__init__.py", line 398, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
yeelight.main.BulbException: A socket error occurred when sending the command.
Setting the bulb to RGB #300A18...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 282, in send_command
    self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 184, in _socket
    self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 288, in send_command
    raise_from(BulbException('A socket error occurred when sending the command.'), ex)
  File "/usr/lib/python3.6/site-packages/future/utils/__init__.py", line 398, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
yeelight.main.BulbException: A socket error occurred when sending the command.
Setting the bulb to RGB #621428...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 282, in send_command
    self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 184, in _socket
    self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb

PS: Until it say "Setting the bulb..." it means that everything is fine and the bulb is changing the color according with the scene.

Here two links to the script I use to send the command to the bulb :

https://github.com/skorokithakis/yeecli
https://media.readthedocs.org/pdf/yeeli … elight.pdf  ( Complete PDF to understand how the script works)

3) Here there is the script I use to put together go program and python script:

#! /bin/bash

while true;do

HEX=$( go run ~/Downloads/Scripts/main.go)

yeecli --ip 151.32.228.60  -e smooth rgb $HEX

sleep 1;

done

Offline

#29 2018-04-21 13:44:46

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,808
Website

Re: How to detect dominant color on screen [SOLVED]

It is the go program that panics

panic: Failed, no non-alpha pixels found (either fully transparent image, or the ColorBackgroundMask removed all pixels)

goroutine 1 [running]:
main.main()
        /home/sirth/Downloads/Scripts/main.go:54 +0x54f
exit status 2

I'll look into it when I have time


https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

#30 2018-04-21 14:05:45

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,808
Website

Re: How to detect dominant color on screen [SOLVED]

It seems by default the prominentcolor package masks white, green and black colors so if you get entire screen of such color it thinks there is nothing. The code below should catch it.
If you need per window version let me know

package main

import (
	"flag"
	"fmt"
	"image"
	"os"

	"github.com/BurntSushi/xgb"
	"github.com/BurntSushi/xgb/xinerama"
	"github.com/BurntSushi/xgb/xproto"
	"github.com/EdlinOrg/prominentcolor"
)

func main() {
	headFlag := flag.Int("head", 0, "select monitor")
	flag.Parse()
	c, err := xgb.NewConn()
	if err != nil {
		panic(err)
	}

	err = xinerama.Init(c)
	if err != nil {
		panic(err)
	}

	reply, err := xinerama.QueryScreens(c).Reply()
	if err != nil {
		panic(err)
	}
	if len(reply.ScreenInfo) < *headFlag+1 {
		fmt.Fprintf(os.Stderr, "%d %s\n", *headFlag, "head out of range!")
		os.Exit(1)
	}
	head := reply.ScreenInfo[*headFlag]

	screen := xproto.Setup(c).DefaultScreen(c)
	x0 := head.XOrg
	y0 := head.YOrg
	//now := time.Now()
	xImg, err := xproto.GetImage(c, xproto.ImageFormatZPixmap, xproto.Drawable(screen.Root), x0, y0, head.Width, head.Height, 0xffffffff).Reply()
	if err != nil {
		panic(err)
	}

	data := xImg.Data
	for i := 0; i < len(data); i += 4 {
		data[i], data[i+2], data[i+3] = data[i+2], data[i], 255
	}
	img := &image.RGBA{data, 4 * int(head.Width), image.Rect(0, 0, int(head.Width), int(head.Height))}
	items, err := prominentcolor.Kmeans(img)
	if err != nil {
		items, err = prominentcolor.KmeansWithAll(prominentcolor.DefaultK, img, prominentcolor.ArgumentDefault, prominentcolor.DefaultSize, nil)
		if err != nil {
			panic(err)
		}
	}
	//fmt.Printf("\rLatency: %s\n", time.Now().Sub(now))
	fmt.Printf("#%s\n", items[0].AsString())

}

Edit: per active window

package main

import (
	"fmt"
	"image"

	"github.com/BurntSushi/xgb"
	"github.com/BurntSushi/xgb/xproto"
	"github.com/EdlinOrg/prominentcolor"
)

func main() {
	c, err := xgb.NewConn()
	if err != nil {
		panic(err)
	}
	aname := "_NET_ACTIVE_WINDOW"
	activeAtom, err := xproto.InternAtom(c, true, uint16(len(aname)), aname).Reply()
	if err != nil {
		panic(err)
	}
	screen := xproto.Setup(c).DefaultScreen(c)
	reply, err := xproto.GetProperty(c, false, screen.Root, activeAtom.Atom,
		xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
	if err != nil {
		panic(err)
	}
	windowId := xproto.Window(xgb.Get32(reply.Value))
	geo, err := xproto.GetGeometry(c, xproto.Drawable(windowId)).Reply()
	if err != nil {
		panic(err)
	}
	xImg, err := xproto.GetImage(c, xproto.ImageFormatZPixmap, xproto.Drawable(windowId), geo.X, geo.Y, uint16(geo.Width), uint16(geo.Height), 0xffffffff).Reply()
	if err != nil {
		panic(err)
	}

	data := xImg.Data
	for i := 0; i < len(data); i += 4 {
		data[i], data[i+2], data[i+3] = data[i+2], data[i], 255
	}
	img := &image.RGBA{data, 4 * int(geo.Width), image.Rect(0, 0, int(geo.Width), int(geo.Height))}
	items, err := prominentcolor.Kmeans(img)
	if err != nil {
		items, err = prominentcolor.KmeansWithAll(prominentcolor.DefaultK, img, prominentcolor.ArgumentDefault, prominentcolor.DefaultSize, nil)
		if err != nil {
			panic(err)
		}
	}
	fmt.Printf("#%s\n", items[0].AsString())
}

Last edited by ugjka (2018-04-21 14:19:52)


https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

#31 2018-04-22 01:58:59

Cristhian
Member
Registered: 2018-02-17
Posts: 76

Re: How to detect dominant color on screen [SOLVED]

Why do you think it's not about the go program? This is the error with the new code you send me

Setting the bulb to RGB #404753...
Setting the bulb to RGB #393F41...
Setting the bulb to RGB #434854...
Setting the bulb to RGB #A98482...
Setting the bulb to RGB #414465...
Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 324, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.
Setting the bulb to RGB #0F0E25...
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 282, in send_command
    self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 184, in _socket
    self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yeecli", line 11, in <module>
    load_entry_point('yeecli==0.1.0', 'console_scripts', 'yeecli')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/yeecli/cli.py", line 133, in rgb
    bulb.set_rgb(red, green, blue)
  File "<decorator-gen-3>", line 2, in set_rgb
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 31, in _command
    method, params = f(*args, **kw)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 350, in set_rgb
    self.ensure_on()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 192, in ensure_on
    self.get_properties()
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 256, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/usr/lib/python3.6/site-packages/yeelight/main.py", line 288, in send_command
    raise_from(BulbException('A socket error occurred when sending the command.'), ex)
  File "/usr/lib/python3.6/site-packages/future/utils/__init__.py", line 398, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
yeelight.main.BulbException: A socket error occurred when sending the command.
Setting the bulb to RGB #312E35...
^C
Aborted!
^C⏎

I forget to say that after these errors, I can't even ask for the status of the bulb . But if I use my app on the smartphone I can still turn on or off my bulb and do every kind of actions. So I'm forced to switch of the bulb from the physical button to use it again from my pc

Offline

#32 2018-04-22 07:36:33

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,808
Website

Re: How to detect dominant color on screen [SOLVED]

well it seems something is wrong with the python script you use this time.


https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

#33 2018-04-22 08:07:08

Cristhian
Member
Registered: 2018-02-17
Posts: 76

Re: How to detect dominant color on screen [SOLVED]

Yes I must find another script to communicate with my bulb. Anyway Thanks so much to everyone for helping and being so patient!! I think the main problem is solved, I don't know if I must edit the title with [SOLVED] or just do nothing and wait to see if someone give me some advice.

EDIT: I think I found the problem, I will test it until the end of the day, if nothing wrong will come out I think I'm going to close this topic and mark it as SOLVED

Last edited by Cristhian (2018-04-22 08:14:51)

Offline

#34 2018-04-23 21:20:37

Cristhian
Member
Registered: 2018-02-17
Posts: 76

Re: How to detect dominant color on screen [SOLVED]

Problem Solved!! There was a conflict because in my i3-block bar I've a module that show me the brightness of the bulb and it refresh every 1 second. So when I run the pyhton script, the bulb receive more than one command at the same time and maybe the bulb block the ip form wich comes the commands. I  think this because when it happend, the bulb is still active and I can control it by my app on Android.
Thanks so much for helping !!!

Offline

Board footer

Powered by FluxBB