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

Xiaomi Mi Bedside Lamp 2 - MJCTD02YL - socket error #46997

Closed
Krzemq opened this issue Feb 24, 2021 · 24 comments
Closed

Xiaomi Mi Bedside Lamp 2 - MJCTD02YL - socket error #46997

Krzemq opened this issue Feb 24, 2021 · 24 comments
Assignees

Comments

@Krzemq
Copy link

Krzemq commented Feb 24, 2021

The problem

I have problem with adding my Xiaomi Mi Bedside Lamp 2. After I installed HA OS it automatically discovered another Yeelight Bulb that I have: YLDP23YL, but it has problems with my bedside lamp. In integration description there is a hint that I should enable LAN control in Yeelight app. Unfortunately I don't have this option in my app, even after updating bedside lamp firmware to the latest. Maybe that's the problem? Maybe there is different option to add Bedside Lamp 2 to HA? Please help :<

What is version of Home Assistant Core has the issue?

core-2021.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Yeelight

Link to integration documentation on our website

https://www.home-assistant.io/integrations/yeelight/

Example YAML snippet

# Put your YAML below this line


yeelight:
  devices:
    192.168.1.27:
      name: Lampka
      model: bslamp1
    192.168.1.24:
      name: Lampa w salonie
      model: bslamp1

Anything in the logs that might be useful for us?

# Put your logs below this line


2021-02-24 10:58:05 ERROR (MainThread) [homeassistant.components.yeelight.config_flow] Failed to get properties from 192.168.1.27: A socket error occurred when sending the command.
2021-02-24 10:58:05 ERROR (MainThread) [homeassistant.components.yeelight.config_flow] Failed to import 192.168.1.27: cannot connect
@probot-home-assistant
Copy link

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

@shenxn
Copy link
Contributor

shenxn commented Feb 25, 2021

Seems LAN control option is removed in latest versions of the Yeelight app. Try using an earlier version of the app. I tried 3.1.98 on Android and that works.

@Krzemq
Copy link
Author

Krzemq commented Feb 25, 2021

I have LAN control option in Yeelight app, but only to YLDP23YL. Not in Bedside Lamp :<

#EDIT
I installed older Yeelight app version. Now I have LAN control option in my Bedside Lamp, but im can't enable it :/ I found that Yeelight disabled LAN control option, because of Xiaomi and in the newest Bedside Lamp firmware it's not possible to turn it on. Anyone have idea how to downgrade Xiaomi Bedside Lamp II firmware? Is it posible?

@P6g9YHK6
Copy link

P6g9YHK6 commented Mar 8, 2021

I have been able to get it to work with:
Yeelight app 3.2.00
firmware 2.0.6_0030
Lamp MJCTD02YL

Indeed the button for the lan integration has been removed but it worked fine after i toggled it in the old version.

config:

yeelight: devices: 192.168.1.212: name: Bedside Light

One full day lost in this mess it's just ridiculous xiaomi need to get their shit together.

Edit:
I also wanted to add that the integration works fine from the UI i got rid of the config in the file.

@rytilahti
Copy link
Member

If you are able to obtain the xiaomi token (e.g., from the yeelight backup on android: https://python-miio.readthedocs.io/en/latest/yeelight.html#token-extraction), you can enable the lan mode using miiocli yeelight set_developer_mode 1 as long as support for it doesn't get removed from the firmware.

@robbiet480
Copy link
Member

We just received a report on Twitter of this issue so I thought I’d dig a bit. I’ll leave it to @balloob to see if we want to make a big stink about this publicly to try to pressure Xiaomi (who forced Yeelight to remove local control according to Yeelight on Twitter) to re-add local control but did want to point people of this issue to this thread on our forums where @mmakaay has done a great job of documenting his work to reverse engineer his Yeelight bedside lamp to install ESPHome on it. That may be your best bet for now instead of trying to maintain LAN control on a product whose creator doesn’t want it maintained.

@sym0nd0
Copy link

sym0nd0 commented Apr 1, 2021

Well, this explains why I can't get a Yeelight bulb I've had for years working with HA again, after it conveniently messed up. I'll see if I can get ESPHome on it, if not it can go in the bin.

@pplucky
Copy link

pplucky commented Apr 2, 2021

Has anyone noticed this?

Does this mean this is not going forward?
image

@mmakaay
Copy link

mmakaay commented Apr 2, 2021

Interesting statement. Seeing the LAN support disappear from my lamps and app does not match this statement, but it would be great if they changed their mind and brought back the support (without having to jump hoops like having devices whitelisted to receive working firmware).

What this does not change, are my efforts to come up with my own firmware for the BS2. It likely will bring me more options than the original firmware, and I am really looking forward to those, amongst which:

  • no phone home activity from my devices
  • independent use of the front panel (e.g. to do a house power down when long pressing my bedside lamp's power button)
  • a fix for the device getting disconnected from HA, because of stringent rate limiting
  • easier control of the night light feature.
  • options for adding extra sensors to the device, nicely tucked away inside the enclosure

@Golab
Copy link

Golab commented Apr 8, 2021

If you are able to obtain the xiaomi token (e.g., from the yeelight backup on android: https://python-miio.readthedocs.io/en/latest/yeelight.html#token-extraction), you can enable the lan mode using miiocli yeelight set_developer_mode 1 as long as support for it doesn't get removed from the firmware.

Can you explain how I runt that command from my HA?

@Progaros
Copy link

Progaros commented Apr 9, 2021

If you are able to obtain the xiaomi token (e.g., from the yeelight backup on android: https://python-miio.readthedocs.io/en/latest/yeelight.html#token-extraction), you can enable the lan mode using miiocli yeelight set_developer_mode 1 as long as support for it doesn't get removed from the firmware.

Can you explain how I runt that command from my HA?

Usage
To use yeelight, first enable "development mode" on your bulb through the YeeLight app.
Then, just import the library into your project like so:

Seems like it doesn't work if you did the update...

@rytilahti
Copy link
Member

Can you explain how I runt that command from my HA?

I think you can do that using this addon to access the shell: https://github.com/hassio-addons/addon-ssh

You can first verify the current settings by executing:

miiocli yeelight --ip <address> --token <token> status

And the full command to change the developer mode is (use 0 to disable):

miiocli yeelight --ip <address> --token <token> set_developer_mode 1

@Progaros
Copy link

Can you explain how I runt that command from my HA?

I think you can do that using this addon to access the shell: https://github.com/hassio-addons/addon-ssh

You can first verify the current settings by executing:

miiocli yeelight --ip <address> --token <token> status

And the full command to change the developer mode is (use 0 to disable):

miiocli yeelight --ip <address> --token <token> set_developer_mode 1

The addon didn't accept the tokens I got from my night lamp 2 and desk lamp 1s

@Codestian
Copy link

Interesting statement. Seeing the LAN support disappear from my lamps and app does not match this statement, but it would be great if they changed their mind and brought back the support (without having to jump hoops like having devices whitelisted to receive working firmware).

What this does not change, are my efforts to come up with my own firmware for the BS2. It likely will bring me more options than the original firmware, and I am really looking forward to those, amongst which:

  • no phone home activity from my devices
  • independent use of the front panel (e.g. to do a house power down when long pressing my bedside lamp's power button)
  • a fix for the device getting disconnected from HA, because of stringent rate limiting
  • easier control of the night light feature.
  • options for adding extra sensors to the device, nicely tucked away inside the enclosure

Do your lamps have the name Xiaomi in their product name? I read that only products with the Xiaomi branding will no longer have LAN control, so "Pure" Yeelight products such as the bulbs and ceiling lights won't be affected.

@mmakaay
Copy link

mmakaay commented Apr 19, 2021

Yes, these lamps are Xiaomi Mijia lamps, which are produced by Yeelight.
This is specifically an issue for the Bedside Lamp 2.
The naming was a bit confusing to me, and I even made it an issue for my repository to decide on its naming.
But one thing is a constant factor: if there is "Bedside Lamp 2" in the name, then the LAN control option is affected.

@Codestian
Copy link

Codestian commented Apr 21, 2021

It seems products starting with MJC are affected while YLD retains local control.

The question is, should these products have a separate integration in Home Assistant?

@mmakaay
Copy link

mmakaay commented Apr 21, 2021

Without LAN control, there's not much you can do, except for using a separate integration, right?

Personally, I don't mind having separate integrations where needed. The fact that I can switch an integration, while the front end end automations remain intact, is one of the beauties of Home Assistant. I can use the integration that best fits my needs.

@rytilahti
Copy link
Member

The devices that are controlled with mi home app are using either miio or miot for communication. The library implementing support for such devices is python-miio, which is used by the xiaomi_miio integration. That library has some basic support to yeelight devices (miiocli yeelight can be used from console), so extending xiaomi_miio.light to provide at least some basic support to the devices without lan mode would be doable.

Also, there is a custom component using the miio protocol that is separate from the lan mode, I have asked if its author has interest in adding support for that to xiaomi_miio: #44540 (comment)

@Strit
Copy link

Strit commented May 23, 2021

So, if I bought a Yeelight Color bulb today, I wouldn't be able to use it with Home Assistant, or has the change been reverted?

@Progaros
Copy link

the yeelight bulbs should be unaffected from the problem - only xiaomi branded products

@chriss158
Copy link
Contributor

I was able to turn the developer mode on, thanks to @rytilahti tip. It also worked for my yeelight ceiling light.

I have obtained my tokens for the device that are needed for miiocli. Here are a few ways listed to get the tokens. https://github.com/Maxmudjon/com.xiaomi-miio/blob/master/docs/obtain_token.md

After that I could activate the developer mode via miiocli (https://python-miio.readthedocs.io/en/latest/).

miiocli yeelight --ip <address> --token <token> set_developer_mode

@rytilahti
Copy link
Member

@chriss158 glad you got yours working! If you don't mind, please feel free to create a PR to improve the python-miio docs on obtaining the tokens /assuming that was the tricky part, iirc the developer mode is already documented) :-)

@jhancuff
Copy link

Just lost control of all of my Yeelight Color2 bulbs. All at once. All other devices remain unaffected. Firmware update hit these as well?

@bdraco
Copy link
Member

bdraco commented Aug 28, 2021

I'm going to close this out as we can't do anything about lan support being removed from the firmware.

The yeelight integration has been significant refactored in 2021.9 to use local push which addresses a whole class of connectivity issues. If there is still a problem after updating to 2021.9 and its not because lan support is missing, please open a new issue as previous logs and troubleshooting will not longer be relevant.

@bdraco bdraco closed this as completed Aug 28, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests