Yeelight binding?

you need to set the token.
Check out this:

Thank for the hint!!!
It worked for me now.

Here is my code:
Turn on/off

YeelightWhiteEsszimmer_ActionsCommands.sendCommand("set_power['on', 'smooth', 500]")
YeelightWhiteEsszimmer_ActionsCommands.sendCommand("set_power['off', 'smooth', 500]")

Set Brightness :

case YeeDimmer.state == 30: 
YeelightWhiteEsszimmer_ActionsCommands.sendCommand("set_bright[30, 'smooth', 500]")
2 Likes

And here is my udated and better solution:

Number YeeDimmer
Number YeeColor

For Brigthness

YeelightWhiteEsszimmer_ActionsCommands.sendCommand("set_bright["+YeeDimmer.state.toString+", 'smooth', 500]")

For color temprature

YeelightWhiteEsszimmer_ActionsCommands.sendCommand("set_ct_abx["+YeeColor.state.toString+", 'smooth', 500]")

Here is the sitemap:

Frame label="Dimmer"{
	Setpoint item=YeeDimmer label="" icon="light" minValue=1 maxValue=100 step=1
	Switch item=YeeDimmer label="" icon="light" mappings=[1="1",5="5",10="10",30="30",50="50",80="80",100="100"]
}
Frame label="Farbtemperatur" {
	Setpoint item=YeeColor icon="heating" minValue=1700 maxValue=6500 step=100
	Switch item=YeeColor icon="heating" mappings=[2700="2700K",3000="3000k", 3500="3500K",4000="4000K",5400="5400K",6000="6500K"]
}
3 Likes

Ive tried it with my Xiaomi Mi6 but saddly it didnt work with a random phone CLI.
Tried it with my Raspberry too, but requires Python 3.5 or higher.
The default Python version on my Pi is 2.7, after installing a higher version, nothing happened.
Am I missing something?
Thanks

Sorry dude, it was my fault. Actually i did it like here:


Its in german, in case u dont get nothing here a short guide:

You dont need any Python. I did it with java.

  1. Install ADB:
    https://www.xda-developers.com/install-adb-windows-macos-linux/

  2. Navigate in command prompt to your ADB folder
    3.Check if your device is connected

adb devices
  1. Then do the adb backup
adb backup -f backup.ab com.yeelight.cherry

now u should get a backup.ab file.
5.Create an ab extract(tar) with this tool:

5.1. therefore put the extracted android-backup-tookit to your adb folder
5.2 in cmd use this:

java -jar .\android-backup-tookit\android-backup-extractor\android-backup-extractor-20180203-bin\abe.jar unpack .\backup.ab backup.tar
  1. one its done u will get a tar which u can extract
  2. check the \apps\com.yeelight.cherry\sp\ folder for miot file :slight_smile:
  3. Get your token, be happy :slight_smile:

I hope it will help.

1 Like

Thanks alot!
Im German, so thats pretty precious.
Does the Token change over time? I’ve been setting up everything via Yeelight App and I have to reset and implement all Yeelights within the Mi Home App now once again.
So Would be a shame, If I had to do this all over again, If something crashes and I added them back to the Yeelight App after extracting the token.

Hi NIco im glad to hear that i could help :slight_smile:

The token will be always the same until you reset the bulb! -->DO NOT DO THIS!!! NEVEREVER!!! :skull_and_crossbones: :stuck_out_tongue:
Turning the bulb 5x on and off in a row will reset everything and u will need to extract the token once again!

Greetings
Niko

Running this CLI command: (as Admin and without Admin)
java -jar .\android-backup-tookit\android-backup-extractor\android-backup-extractor-20180203-bin\abe.jar unpack .\backup.ab backup.tar
Im getting this Exception:
Unable to access jarfile .\android-backup-tookit\android-backup-extractor\android-backup-extractor-20180203-bin\abe.jar
Does someone know the answer?

Edit: The version just updated lol I got it

Is there a way to send a rgb value to the Yeelight with the MI IO binding?

I just did the update to OH 2.3 and now this addon isnt working anymore. Will there be an updated version soon?

I assume you refer to the yeelight binding?
The Mi IO binding should work with 2.3 and 2.4-snapshop

A year ago I programmed this lambda, it works reliably:

val org.eclipse.xtext.xbase.lib.Functions$Function4<ColorItem, SwitchItem, StringItem, Object ,Boolean> yeelightCP = [
	org.eclipse.smarthome.core.library.items.ColorItem colorYee,
    org.eclipse.smarthome.core.library.items.SwitchItem switchYee,
    org.eclipse.smarthome.core.library.items.StringItem Yee,
	java.lang.Object commandYee |
	
	var String data = ""
	
   	if(switchYee.state.toString == "ON")  {	
		if(commandYee instanceof HSBType) {
		  	var HSBType hsbValue = colorYee.state as HSBType
	        var hueValue = hsbValue.hue.intValue
	        var satValue = hsbValue.saturation.intValue
	        var briValue = hsbValue.brightness.intValue
	        
		    data = String::format('{"id":1,"method":"set_hsv","params":[%1s, %2s,"smooth",150]}\r\n', hueValue, satValue)
			data += String::format('{"id":2,"method":"set_bright","params":[%1s,"smooth",150]}\r\n', briValue)
		}
		if(commandYee instanceof PercentType) {
		  	var HSBType hsbValue = colorYee.state as HSBType
	    	var briValue = hsbValue.brightness.intValue
	        
			data = String::format('{"id":2,"method":"set_bright","params":[%1s,"smooth",150]}\r\n', briValue)
		}
		if(commandYee instanceof OnOffType) {
		  	if(commandYee == ON ) {
				data = '{"id":1,"method":"set_power","params":["on","smooth",150]}\r\n'
		  	}else if (commandYee == OFF ) {
		  		data = '{"id":1,"method":"set_power","params":["off","smooth",150]}\r\n'
		  	}
		}
		var java.net.Socket clientSocket = new java.net.Socket(Yee.label, 55443)
		var java.io.DataOutputStream outToServer = new java.io.DataOutputStream(clientSocket.getOutputStream())
		outToServer.writeBytes(data)
		clientSocket.close()
	} else {
		postUpdate(colorYee, "OFF" )
	}
	true
]

Example item:

Color  FlurYeePicker 		"Flur Licht" 		<colorwheel>
String FlurYee				"192.168.0.30"
Switch flurYeeWLAN 	        "Yeelight Stromnetz [MAP(yeelight.map):%s]"		<bulb>

Example rule:

rule "FlurYeeColorPicker"
when
  Item FlurYeePicker received command
then
	yeelightCP.apply(FlurYeePicker, flurYeeWLAN, FlurYee, receivedCommand)
end

Example sitemap:

Frame label="Licht" {
	Switch item=FlurYeePicker label="Schalter Lampe" icon="switch" visibility=[flurYeeWLAN==ON]
    Colorpicker item=FlurYeePicker label="Farbe Lampe" visibility=[flurYeeWLAN==ON]
    Text item=flurYeeWLAN visibility=[flurYeeWLAN==OFF]					
}

Everything works without a specific binding

1 Like

As of today the binding is finally merged and can be installed in snapshot builds: https://github.com/openhab/openhab2-addons/pull/3582

Hello,

This is great for me because unfortunately the new xiaomi lamp is not supported by the old binding.
But where should I copy the above code?

Script?

val org.eclipse.xtext.xbase.lib.Functions$Function4<ColorItem, SwitchItem, StringItem, Object ,Boolean> yeelightCP = [
	org.eclipse.smarthome.core.library.items.ColorItem colorYee,
    org.eclipse.smarthome.core.library.items.SwitchItem switchYee,
    org.eclipse.smarthome.core.library.items.StringItem Yee,
	java.lang.Object commandYee |
	
	var String data = ""
	
   	if(switchYee.state.toString == "ON")  {	
		if(commandYee instanceof HSBType) {
		  	var HSBType hsbValue = colorYee.state as HSBType
	        var hueValue = hsbValue.hue.intValue
	        var satValue = hsbValue.saturation.intValue
	        var briValue = hsbValue.brightness.intValue
	        
		    data = String::format('{"id":1,"method":"set_hsv","params":[%1s, %2s,"smooth",150]}\r\n', hueValue, satValue)
			data += String::format('{"id":2,"method":"set_bright","params":[%1s,"smooth",150]}\r\n', briValue)
		}
		if(commandYee instanceof PercentType) {
		  	var HSBType hsbValue = colorYee.state as HSBType
	    	var briValue = hsbValue.brightness.intValue
	        
			data = String::format('{"id":2,"method":"set_bright","params":[%1s,"smooth",150]}\r\n', briValue)
		}
		if(commandYee instanceof OnOffType) {
		  	if(commandYee == ON ) {
				data = '{"id":1,"method":"set_power","params":["on","smooth",150]}\r\n'
		  	}else if (commandYee == OFF ) {
		  		data = '{"id":1,"method":"set_power","params":["off","smooth",150]}\r\n'
		  	}
		}
		var java.net.Socket clientSocket = new java.net.Socket(Yee.label, 55443)
		var java.io.DataOutputStream outToServer = new java.io.DataOutputStream(clientSocket.getOutputStream())
		outToServer.writeBytes(data)
		clientSocket.close()
	} else {
		postUpdate(colorYee, "OFF" )
	}
	true
]

Did you test the binding I linked above? Also which device model are you talking about? There is an ongoing effort to support newer devices as well: https://github.com/openhab/openhab2-addons/issues/3665

Device: Yeelight Color Bulb YLDP06YL 10W

Xiaomi Mi IO Binding :

yeelight binding is the same :frowning:
LAN Control enabled.

Did you try to add it (manually) as a basic device and overwrite the modelid to yeelink.light.color1

Is it that working? If yes, I add it as such device

That is the new generation color bulb. I own the same and it is working for me, but maybe you have a different hardware revision with model changed to color1?

Does the inbox/manual searching for things display this bulb in the results?

I’ve added it to the database. If you update the binding it should recognise it

update Xiaomi IO Binding 2.3 to 2.4 and add manual Device Model String : yeelink.light.color1

Working!
Thanks!