SmartThings Community

Xiaomi Yeelight RGBW E27

dth_lighting
requires_server

#182

Freakapotamus

Please explain how to use. I hope this is also work with Xiaomi ceiling light


(Nuno Martins) #183

is not possible to not use discovery, and specify each lamp ip address? and use local API to control it?


(Edward Niedziejko) #184

Due to hardware limitations, Yeelights use a non-standard port for discovery, so ST can’t be used for discovery, that’s the reason for the server-in-the-middle.


(Nuno Martins) #185

But what I was trying to say is, cant we bypass discovery and add each lamp/light manually specifying the IP address, and then use Local API to control it?


(Zen) #186

The home assistant support for yeelight requires the use of developer mode if I understand correctly, I don’t really know how ST discovery works for WiFi devices


(Nuno Martins) #187

Thats exactly what I was thinking. If we enable developer mode, and skip discovery maybe its possible to control it like Home Assistant does

# Example configuration.yaml entry

light:

  • platform: yeelight
    devices:
    192.168.1.25:
    name: Living Room
    transition: 1000
    use_music_mode: True #(defaults to False)
    save_on_change: False #(defaults to True)
    192.168.1.13:
    name: Front Door

Another example here:

>>> bulb = Bulb("192.168.0.5")
>>> bulb.turn_on()

(Tea Pot91) #188

Do I need a Pi to get this working, or can I just install it directly onto my smart things device?


(roelofk85@gmail.com) #189

So mutch people who are asking if Samsung can let this bulbs work with Smartthings and they just don’t want to get it worked…
To bad samsung bought smartthings, flexability is gone with such a big company?

Is ie possible to install the bridge software on an Android device whats always up?

Thanks


(Nuno Martins) #190

at this point, is there anyone using yeelight with ST without the IFTTT solution ?


(Rich) #191

For me… I use Alexa integration to change the colors and/or brightness.
I use a leviton outlet to turn them on or off in smarthings.


(Gareth) #192

Hi All, I’ve gone through the process of installing both the RPi server and the Smartapp/Device Handler in the IDE.

One the RPi I’m seeing the following after checking the server status:
image

But when discovering devices in the Smartapp I’m not picking anything up. I see the following in the Live Logging:

Does the server address need to be configured somewhere? If not, is there a way to check that the server status is being represented correctly?

Any help would be appreciated…


(Peke) #193

If you have a rasberry pi laying around then install domoticz and you can use this smartapp Connection to Domoticz defined devices like Blinds and On/Off switches
to control your yeelights, tested it and works perfect.


(Babar Khan) #194

same here; any solution that you found?


(Simon Tether) #195

Has anyone got any further doing it this way, ie no discovery, just manual input of IP addresses ?

I currently use an ST simulated switch and the eventghost smartapp “send events to eventghost”.
I then use the yeelight python library in eventghost to switch on/off/dim the yeelight, using a python script and manually entered IP addresses and not using any discovery. Works OK but no feedback to ST if lights are switched on using the Yeelight APP.


(Simon Tether) #196

I managed to get this working with bits and pieces of smartapp code from this forum.

No discovery needed, just find the IP of your bulb from your app / router.

This will turn a yeelight on and off only and I use a simulated switch to trigger each part.

I’m very new to this so I’m sure there must be a better way but works for me.

This snippet is used to turn it on and off:

def switchHandler(evt) {
	if (evt.value == "on") {
		onSwitches()
	} else if (evt.value == "off") {
		offSwitches()
	}
}

def onSwitches() {
def String ipaddr = "192.168.1.xx"
def port = 55443
def String hexIp = ipaddr.tokenize('.').collect {
    String.format('%02X', it.toInteger())
}.join()
def String hexPort = String.format('%04X', port)
def String myNetworkID = "${hexIp}:${hexPort}"
log.debug "network ID is " + myNetworkID
def transmittedData = new physicalgraph.device.HubAction("""{"id": 1, "method": "set_power", "params":["on", "smooth", 500]}\r\n""", physicalgraph.device.Protocol.LAN, myNetworkID)
transmittedData.options = [type:'LAN_TYPE_CLIENT', protocol:'LAN_PROTOCOL_TCP']
sendHubCommand(transmittedData)	
}

def offSwitches() {
def String ipaddr = "192.168.1.xx"
def port = 55443
def String hexIp = ipaddr.tokenize('.').collect {
    String.format('%02X', it.toInteger())
}.join()
def String hexPort = String.format('%04X', port)
def String myNetworkID = "${hexIp}:${hexPort}"
log.debug "network ID is " + myNetworkID
def transmittedData = new physicalgraph.device.HubAction("""{"id": 1, "method": "set_power", "params":["off", "smooth", 500]}\r\n""", physicalgraph.device.Protocol.LAN, myNetworkID)
transmittedData.options = [type:'LAN_TYPE_CLIENT', protocol:'LAN_PROTOCOL_TCP']
sendHubCommand(transmittedData)	
}

private String convertIPtoHex(host) { 
String hosthex = host.tokenize( '.' ).collect {  String.format( '%02x', it.toInteger() ) }.join()
log.debug "the returned host is $hosthex"
return hosthex
}

private String convertPortToHex(port) {
	String porthex = port.toString().format( '%04x', port.toInteger() )
log.debug "the returned port is $porthex"
return porthex
}

(George) #197

Could you please post the full DH. Is this standalone, or are you also using Eventghost as you said in the previous post?


(Simon Tether) #198

This is a standalone smartapp, no eventghost needed.

I couldn’t figure out the device handler route so used a smart app, mainly from bits of code here and there. It is only one way, ie ST will not update if the Yeelight is changed elsewhere. I am working on this still so may have a 2 way version with dimming and colour in the future and maybe a DTH.

Heres the entire code, don’t forget to change the IP of your yeelight in the code then just create a simulated switch and in the settings of the app select it.

The Yeelight API is readily available and easy to use so may add features bit by bit.

Oh, don’t forget to turn on “Lan Control” in the Yeelight APP.

Let me know if it works OK for you

/**
 * Yeelight On and OFF
 */
definition(
name: "Yeelight ON and OFF",
namespace: "smartthings",
author: "Simon Tether",
description: "A SmartApp that when sends URL requests to a yeelight that triggers when a simulated switch is turned on or off",
category: "Convenience",
iconUrl: "https://png.icons8.com/ultraviolet/50/000000/lamp.png",
iconX2Url: "https://png.icons8.com/ultraviolet/80/000000/lamp.png",
iconX3Url: "https://png.icons8.com/ultraviolet/80/000000/lamp.png")

preferences {
section("Send Yeelight Command to Switch") {
    input "theswitch", "capability.switch", required: true, title: "Which switch?"
}
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(theswitch, "switch", switchHandler)
}

def switchHandler(evt) {
	if (evt.value == "on") {
		onSwitches()
	} else if (evt.value == "off") {
		offSwitches()
	}
}

def onSwitches() {
def String ipaddr = "192.168.1.131"
def port = 55443
def String hexIp = ipaddr.tokenize('.').collect {
    String.format('%02X', it.toInteger())
}.join()
def String hexPort = String.format('%04X', port)
def String myNetworkID = "${hexIp}:${hexPort}"
log.debug "network ID is " + myNetworkID
def transmittedData = new physicalgraph.device.HubAction("""{"id": 1, "method": "set_power", "params":["on", "smooth", 500]}\r\n""", physicalgraph.device.Protocol.LAN, myNetworkID)
transmittedData.options = [type:'LAN_TYPE_CLIENT', protocol:'LAN_PROTOCOL_TCP']
sendHubCommand(transmittedData)
sendEvent(name: "switch", value: "on")
}

def offSwitches() {
def String ipaddr = "192.168.1.131"
def port = 55443
def String hexIp = ipaddr.tokenize('.').collect {
    String.format('%02X', it.toInteger())
}.join()
def String hexPort = String.format('%04X', port)
def String myNetworkID = "${hexIp}:${hexPort}"
log.debug "network ID is " + myNetworkID
def transmittedData = new physicalgraph.device.HubAction("""{"id": 1, "method": "set_power", "params":["off", "smooth", 500]}\r\n""", physicalgraph.device.Protocol.LAN, myNetworkID)
transmittedData.options = [type:'LAN_TYPE_CLIENT', protocol:'LAN_PROTOCOL_TCP']
sendHubCommand(transmittedData)
sendEvent(name: "switch", value: "off")
}

(Tiago Gonçalves) #199

works on yeelight light strip.

thanks


(Simon Tether) #200

I’ve added a bit more now and created a DTH, you can try this out if you wish. You’ll need to add a new device in the IDE and have this DTH as the type.

I still need to add 2 way communications (as it is, if you change the light status at the Yeelight app it won’t update ST) but there’s an ST problem with parsing responses from hubActions at the minute


Mi Connector (Xiaomi and Yeelight)
(David Jacobs) #201

Seems to work for me. Great work so far.