You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.1 KiB

3 years ago
  1. # esphome-yeelight_bs2
  2. ## Warning: this code is still under heavy development
  3. This code is not yet production-ready. Most of the work goes into reverse
  4. engineering the original firmware and coming up with ways to re-implement
  5. a device firmware based on ESPHome.
  6. The main focus for now lies on driving the LED circuitry, to make sure that
  7. the light quality meets that of the original firmware. While I thought this
  8. would be the easy part, it turned out to be quite a beast, since driving the
  9. LEDs is quite different from a regular RGBWW-style light.
  10. The light functionality is getting close to completion. After this, I will
  11. work on implementing the front panel buttons. The hard work for this was
  12. already done: reverse engineering the protocol that is used to talk to the
  13. main board. Therefore, finishing up the firmware should not take much time
  14. once I get to this point.
  15. With those two out of the way, we can move towards a stable release of the
  16. firmware. I have some more ideas to work on, but those can and will be
  17. extensions to the stable release code.
  18. ## Is it safe to install this firmware on my device?
  19. As long as you keep a backup of the original Yeelight firmware, this is
  20. quite safe :-)
  21. I have two lamps that both are running the latest development firmware and
  22. they are functioning very well as far as the light feature is concerned.
  23. I sometimes see API disconnection issues, but those can all be traced back
  24. to the underlying frameworks. For the most prevalent issue, I did some
  25. debugging and wrote a fix (it is mentioned below).
  26. For each commit of the code, I will do my best to commit it in a working
  27. state. Once a first completed stable release is cooked up, I will tag
  28. production releases of the code to make it easier to pick the safe version
  29. for production purposes.
  30. ## Installation
  31. Create a folder named `custom_components` in the folder where your
  32. device's yaml configuration file is stored. Then clone the the Github
  33. repo into a subfolder `yeelight_bs2`. For example on the command line:
  34. ```
  35. # mkdir custom_components
  36. # cd custom_components
  37. # git clone https://github.com/mmakaay/esphome-yeelight_bs2 yeelight_bs2
  38. ```
  39. Your folder structure should now look like:
  40. ```
  41. config
  42. ├── yourdevice.yaml
  43. ├── custom_components/
  44. │ ├── yeelight_bs2/
  45. │ . ├── README.md
  46. . . ├── yeelight_bs2_light_output.h
  47. . . .
  48. ```
  49. Then add the required configuration to your device's yaml configuration file.
  50. For an example file, take a look at `doc/example.yaml` in this repository.
  51. On a Rapsbery Pi with HomeAssistant and ESPHome as a plugin, the directory should be:
  52. /config/esphome/custom_components/yeelight_bs2/
  53. ```
  54. config
  55. ├── epshome
  56. │ ├── yourdevice.yaml
  57. │ ├── custom_components/
  58. | . ├── yeelight_bs2/
  59. │ . . ├── README.md
  60. . . . ├── yeelight_bs2_light_output.h
  61. . . . .
  62. ```
  63. See [doc/FLASHING.md](doc/FLASHING.md) for hints for opening and flashing the light.
  64. ## Issue: the device keeps losing its connection to Home Assistant
  65. This is not a problem with the device or the custom firmware, but a problem
  66. in the upstream library "AsyncTCP". I did identify the issue and have a
  67. proposed fix for it. The issue was reported at:
  68. https://github.com/me-no-dev/AsyncTCP/issues/116
  69. If you want to try out this change, then create a `libs` folder in the
  70. folder where your device's yaml configuration file is stored, and clone the
  71. following repository into that folder:
  72. https://github.com/mmakaay/AsyncTCP
  73. For example on the command line:
  74. ```
  75. # mkdir libs
  76. # cd libs
  77. # git clone://github.com/mmakaay/AsyncTCP
  78. ```
  79. Then add a pointer to this folder from within your device's yaml
  80. configuration file, using the `lib_extra_dirs` option. Provide it with the
  81. absolute path to your `libs` folder. The relevant part of the config change
  82. looks like this:
  83. ```yaml
  84. esphome:
  85. platformio_options:
  86. lib_extra_dirs: /config/libs
  87. ```
  88. This way, the repository version of the library will override the version of
  89. the library that is bundled with ESPHome. Build the device firmware and
  90. flash the device like you would normally do.