Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yeelight Discovery #26574

Closed
magicsmoke opened this issue Sep 11, 2019 · 19 comments · Fixed by #37191
Closed

Yeelight Discovery #26574

magicsmoke opened this issue Sep 11, 2019 · 19 comments · Fixed by #37191
Assignees

Comments

@magicsmoke
Copy link

Home Assistant release with the issue:
0.98.1

Last working Home Assistant release (if known):
unknown

Operating environment (Hass.io/Docker/Windows/etc.):
Docker

Component/platform:
Discovery
Yeelight

Description of problem:
After debugging and talking with the developer of yeelight he informed me that with the latest firmware of the Yeelight Colour there has been no changes to the multicast discovery code.

The issue might have something to do with the Homekit discovery #26129
I tested with a previous firmware of yeelight, before the Homekit update and the bulbs were discovered normally.

In his debug testing he informed me that the packets are the same as before the latest firmware and showed that a third party multicast discovery finds both old and new firmware

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

discovery:

Traceback (if applicable):


Additional information:

@magicsmoke magicsmoke changed the title Yeelight Discovery broken Yeelight Discovery Sep 11, 2019
@probot-home-assistant
Copy link

Hey there @rytilahti, @zewelor, mind taking a look at this issue as its been labeled with a integration (yeelight) you are listed as a codeowner for? Thanks!

@vvpossible
Copy link

Any update on this topic? I'm from Yeelight and we recently received lots of complaint about the discovery issue. Yeelight discovery mechanism is not changed, the new firmware only adds Homekit function.

@clempat
Copy link

clempat commented Sep 21, 2019

Interesting I am facing the same issue. My yeelight disappeared from Home assistant and only appeared as Homekit Accessories... This concerns the yeelights with v.2.0.6_0051, the ceiling one with 1.5.9_0184 are working well.

@rytilahti
Copy link
Member

I'm not sure which multicast discovery protocol are you talking about (mdns or ssdp-like), but
just as a sidenote, the yeelight integration uses mDNS instead of the custom SSDP-like discovery protocol as implemented by the yeelight library.

There has been some changes related to discovery of mdns/upnp devices to make it more straightforward, maybe this is related to that? Ping @zewelor

@vvpossible
Copy link

@rytilahti mDNS discovery in Yeelight devices is never the official way, in our API spec, only ssdp-like protocol is documented. We will remove mDNS in our further firmware update. For Homekit compatible devices, mDNS is used for Apple's Bonjour protocol and should not be used for Yeelight local discovery either.

@rytilahti
Copy link
Member

rytilahti commented Sep 23, 2019

The reason for not using the custom protocol was that there was no proper way to integrate custom discovery protocols to homeassistant (https://github.com/home-assistant/netdisco). As mdns information provided enough information to detect the device and its type, it was used there. For reference, there was discussion about including custom protocols, I'll leave this here just for reference: home-assistant-libs/netdisco#193

However, you should really consider using the SSDP as it was designed to (i.e., using the standard port), this would make integration much easier (where it would be simple matter of adding some metadata: https://developers.home-assistant.io/docs/en/next/creating_integration_manifest.html#ssdp).

So just to be clear, was the mDNS advertisements for _miio._udp removed by a recent firmware releases? If yes, that could explain the issue. If not, another possibility would be that the homekit autodetection takes precedence?

Now that we have a way to add custom discovery protocols, it could be possible to move away from mDNS to use the custom protocol. As I do not have access to any devices at the moment, I hope someone else will work on that, though.

edit: while we have your attention, could you please reconsider extending the API wrt the points 2 & 3 mentioned in https://forum.yeelight.com/t/topic/7075/3 ?

@vvpossible
Copy link

Thanks for your information. I can confirm mDNS advertisement for _miio._udp will be removed completely in the new firmware. The reason is that our App doesn't use mDNS to discover device anymore and mDNS stack from all chip vendors are not stable and good enough.

Regarding extending the API, we will put these items on our to-do list.

@mikeage
Copy link
Contributor

mikeage commented Dec 14, 2019

@rytilahti , sorry for what is potentially a stupid question, but is this resolved now? I have a ct2 bulb on 2.0.6_0041 which no longer does mDNS but still responds to SSDP (and is found by python yeelight's discover_bulbs() ) but isn't being found by HA.

@rytilahti
Copy link
Member

@mikeage I don't think this is resolved yet. The current yeelight integration should be converted to be a fullblown component with support for discovery, which also requires a modification to the backend library to make targeted discovery possible. The good thing is, with that we can finally have unique ids and make the devices renameable from the UI.

@mikeage
Copy link
Contributor

mikeage commented Dec 17, 2019

Thanks. I saw people claiming that 2.0.6_0065 "fixed" whatever problems happened in 2.0.6_0051, but I guess that just means that they were defining explicit IPs, since mDNS based discovery didn't come back. Thanks for the clarification.

@TheZoker
Copy link
Contributor

TheZoker commented Feb 16, 2020

@rytilahti Any news regarding this topic?
Is anyone working on the custom SSDP discovery?

@rytilahti
Copy link
Member

@TheZoker alas no, I have had no time and won't have any in the near future to work on that. Nor have I heard anyone working on converting the platform to a proper integration which is required for that. The backend library supports the discovery, but it will require adaptation to allow unicast discovery (for manually configured ones).

@stale
Copy link

stale bot commented May 16, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 16, 2020
@rytilahti
Copy link
Member

rytilahti commented May 16, 2020

This is still a legit issue, however, #35448 will pave the path towards a proper discovery support!

edit: fixed the link..

@royasulin
Copy link

I have 6 Yeelight both module color 1 and 2 running Home Assistant 0.111.4 both discovery and YAML configuration are not working anymore.

@valpackett
Copy link

Here's a silly hack "solution" piggybacking on the homekit announcements:

--- /tmp/yeelight.py    2020-06-24 20:51:51.206289000 +0300
+++ lib/python3.8/site-packages/netdisco/discoverables/yeelight.py      2020-06-24 21:09:14.761612000 +0300
@@ -2,7 +2,7 @@
 from . import MDNSDiscoverable
 from ..const import ATTR_DEVICE_TYPE

-DEVICE_NAME_PREFIX = 'yeelink-light-'
+DEVICE_NAME_PREFIX = 'YeelightColorBulb-'


 class Discoverable(MDNSDiscoverable):
@@ -10,15 +10,16 @@

     def __init__(self, nd):
         """Initialize the Yeelight discovery."""
-        super(Discoverable, self).__init__(nd, '_miio._udp.local.')
+        super(Discoverable, self).__init__(nd, '_hap._tcp.local.')

     def info_from_entry(self, entry):
         """Return most important info from mDNS entries."""
         info = super().info_from_entry(entry)

-        # Example name: yeelink-light-ceiling4_mibt72799069._miio._udp.local.
-        info[ATTR_DEVICE_TYPE] = \
-            entry.name.replace(DEVICE_NAME_PREFIX, '').split('_', 1)[0]
+        # Example name: YeelightColorBulb-1337._hap._tcp.local.
+        info[ATTR_DEVICE_TYPE] = "color2"
+
+        info["properties"]["mac"] = info["properties"]["id"]

         return info

Would be possible to determine the model based on info["properties"]["md"] I guess (for my color2s it's 'YLDP06YL') but I only have one type of bulb so w/e.

@rishav95
Copy link

+1 Bulb firmware 2.0.6_0065 is not being discovered, neither automatically nor manually through configuration.yaml

@MoshiBin
Copy link

MoshiBin commented Aug 14, 2020

I just got a Yeelight bulb and it was not getting discovered in HomeAssistant. Playing around with ssdp (shameless self plug for https://github.com/MoshiBin/ssdpy) I realized two things:

  1. The light is working on port 1982 rather than SSDP's default 1900.
  2. The light is not responding to the ssdp:all ST - only to wifi_bulb.
    So this works:
$ ssdpy-discover -p 1982 wifi_bulb -j | jq
[
  {
    "cache-control": "max-age=3600",
    "date": "",
    "ext": "",
    "location": "yeelight://X.X.X.X:55443",
    "server": "POSIX UPnP/1.0 YGLC/1",
    "id": "0x0000000010XXXXXX",
    "model": "ceiling1",
    "fw_ver": "24",
    "support": "get_prop set_default set_power toggle set_bright set_scene cron_add cron_get cron_del start_cf stop_cf set_ct_abx set_name set_adjust adjust_bright adjust_ct",
    "power": "on",
    "bright": "100",
    "color_mode": "2",
    "ct": "3500",
    "rgb": "0",
    "hue": "0",
    "sat": "0",
    "name": ""
  }
]

I checked the discovery code (https://github.com/home-assistant/core/blob/dev/homeassistant/components/discovery/__init__.py) but couldn't find a way to replace the port number.

@valpackett
Copy link

@MoshiBin this is known. #37191 implements upnp discovery and everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.