Problem integration mi desk lamp 1s

Hello
i was using the yeelight integration to control 2 lightbulb and 1 mi desk lamp 1s, few weeks ago i noticed that the lan was not workin in HA and i was not able to enable the lan control in the yeelight app, after few emails with yeelight they told me that after xiaomi request they have disabled in new firmware the lan control option
while i’m trying to understand if there is any solution to this firmware (downgrade, custom firmware…) i tried to control the lamp via the homekit controller, so i went in the HA integration, added homekit controller, it find the lamp but it ask me a pin code (format XXX-XX-XXX), i didn’t know that, so i foun a sticker on the bottom of the lamp but it just have 8 number and a qrcode so i tried to add the 8 digit number as pin (with format XXXXXXXX and XXX-XX-XXX) but HA say that it can not connect

so, as i don’t have any apple device, any idea on how to connect this lamp to HA? or how to use the homekit controller ??

thanks a lot

EDIT: here the log:

2021-01-28 08:22:31 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 310, in async_step_pair

    pairing = await self.finish_pairing(code)

  File "/usr/local/lib/python3.8/site-packages/aiohomekit/controller/ip/discovery.py", line 99, in finish_pairing

    request, expected = state_machine.send(response)

  File "/usr/local/lib/python3.8/site-packages/aiohomekit/protocol/__init__.py", line 176, in perform_pair_setup_part2

    handle_state_step(response_tlv, TLV.M4)

  File "/usr/local/lib/python3.8/site-packages/aiohomekit/protocol/__init__.py", line 81, in handle_state_step

    raise InvalidError(f"Exepected state {expected_state} but got {actual_state}")

aiohomekit.exceptions.InvalidError: Exepected state bytearray(b'\x04') but got bytearray(b'\x02')

I use this lamp with Esphome. on the other hand, it must be opened and 5 wires soldered while the esphome firmware is updated. This lamp is great.

1 Like

If you want I have created a tutorial for our French community.

My tutorial French

1 Like

Did you resolve this?

Does this firmware work stable an relliable?
Want to flash this to my 1S because, yeah → yeelight/xiaomi have dropped the LAN feature.

Will follow your guide and hope it works.

thx a lot

It’s stable but no solution for the remote control. I don’t have the skills to integrate it. You can make a backup of your current firmware to roll back if that doesn’t work for you.

1 Like

What do you mean for the remote control?
What i want: COntrol the light with the button on the lamp and ofer wifi througth HA.

I dont care about the Yeelight/Xiaomi Home app.

Did you mean that with “remote”?

thx

This means that you can only control the light with hassio. which is a shame because the remote is good too.

Ok, thx.
Question about the yaml.
I cant Compile it because of it cant find the Tool chain.

INFO Reading configuration /config/esphome/schreibtisch.yaml...
WARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
  File "/esphome/esphome/__main__.py", line 825, in main
    return run_esphome(sys.argv)
  File "/esphome/esphome/__main__.py", line 812, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
  File "/esphome/esphome/__main__.py", line 326, in command_compile
    exit_code = write_cpp(config)
  File "/esphome/esphome/__main__.py", line 159, in write_cpp
    generate_cpp_contents(config)
  File "/esphome/esphome/__main__.py", line 171, in generate_cpp_contents
    CORE.flush_tasks()
  File "/esphome/esphome/core/__init__.py", line 613, in flush_tasks
    self.event_loop.flush_tasks()
  File "/esphome/esphome/coroutine.py", line 245, in flush_tasks
    next(task.iterator)
  File "/esphome/esphome/core/config.py", line 283, in _add_platformio_options
    cg.add_platformio_option(key, val)
  File "/esphome/esphome/cpp_generator.py", line 594, in add_platformio_option
    CORE.add_platformio_option(key, value)
  File "/esphome/esphome/core/__init__.py", line 707, in add_platformio_option
    assert isinstance(value, list)
AssertionError

An new generated device of esphome is working.

Am I missing something?

Thx

Got it to compile.
Replace the top portion of the yaml:

esphome:
  name: mi_desk_lamp_1s
  platform: ESP32
  board: esp32doit-devkit-v1
  platformio_options:
    platform: [email protected]
    platform_packages: |-4
          framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.4

With:

esphome:
  name: midesklamp1s
  platformio_options:
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.4
    platform:
      - [email protected]
  
esp32:
  board: esp32doit-devkit-v1

There was a change on the esphome side which needed’s to change the platform yaml part.

After this there was an compile error:

Compiling /data/midesklamp1s/.pioenvs/midesklamp1s/src/esphome/components/esp32/gpio_arduino.cpp.o
src/esphome/components/esp32/core.cpp:8:29: fatal error: esp_idf_version.h: No such file or directory

After switching to the newest 1.0.6 branch, the issue is gone.
So the FINAL yaml top part is:

esphome:
  name: midesklamp1s
  platformio_options:
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/pauln/arduino-esp32.git#solo-no-mac-crc/1.0.6
    platform:
      - [email protected]
  
esp32:
  board: esp32doit-devkit-v1

Thanks a lot
pOpY

2 Likes