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.

126 lines
4.3 KiB

  1. # esphome-xiaomi_bslamp2
  2. ## Warning: this code is still under development
  3. This code might not yet be production-ready.
  4. At this point, it is declared beta-quality.
  5. The new firmware is currently being tested and depending on the actual
  6. use cases and issues that we might run into, breaking changes could still
  7. occur at some point.
  8. ## Is it safe to already install this firmware on my device?
  9. As long as you keep a backup of the original firmware, this is quite safe :-)
  10. I have two lamps that both are running the latest development firmware and
  11. they are functioning very well.
  12. I sometimes see API disconnection issues, but those can all be traced back
  13. to the underlying frameworks. For the most prevalent issue, I did some
  14. debugging and wrote a fix (it is mentioned below).
  15. For each commit of the code, I will do my best to commit it in a working
  16. state. Once a first completed stable release is cooked up, I will tag
  17. production releases of the code to make it easier to pick the safe version
  18. for production purposes.
  19. ## Installation
  20. The code must be compiled using ESPHome. Therefore, a prerequisite is that
  21. you have ESPHome up and running in some form (command line, docker container,
  22. web dashboard, possibly from within Home Assistant).
  23. For information on this, please refer to the documentation on the
  24. [ESPHome website](https://esphome.io).
  25. Create a folder named `custom_components` in the folder where your device's
  26. yaml configuration file is stored. Then clone the the Github repo into a
  27. subfolder `xiaomi_bslamp2`. For example on the command line:
  28. ```
  29. # mkdir custom_components
  30. # cd custom_components
  31. # git clone https://github.com/mmakaay/esphome-xiaomi_bslamp2 xiaomi_bslamp2
  32. ```
  33. Your folder structure should now look like:
  34. ```
  35. config
  36. ├── yourdevice.yaml
  37. ├── custom_components/
  38. │ ├── xiaomi_bslamp2/
  39. │ . ├── README.md
  40. . . ├── LICENSE.md
  41. . . .
  42. ```
  43. On a Rapsbery Pi with HomeAssistant and ESPHome as a plugin, the directory
  44. should be: `/config/esphome/custom_components/xiaomi_bslamp2/`
  45. ```
  46. config
  47. ├── esphome
  48. │ ├── yourdevice.yaml
  49. │ ├── custom_components/
  50. | . ├── xiaomi_bslamp2/
  51. │ . . ├── README.md
  52. . . . ├── LICENSE.md
  53. . . . .
  54. ```
  55. Then create the required configuration in your device's yaml configuration
  56. file. For an example file, take a look at the example file
  57. [doc/example.yaml](doc/example.yaml) in this repository.
  58. After these steps you can compile your firmware `firmware.bin` file.
  59. This firmware can then be flashed onto the device.
  60. Like normal with ESPHome, the first time you will have to flash the
  61. device using a serial interface. After this initial flashing operation, you
  62. can flash new versions of the firmware using the OTA (Over The Air) method.
  63. See [doc/FLASHING.md](doc/FLASHING.md) for hints on opening up the device and
  64. flashing its firmware using the serial interface.
  65. ## Issue: the device keeps losing its connection to Home Assistant
  66. This is not a problem with the device or the custom firmware, but a problem
  67. in the upstream library "AsyncTCP". I did identify an issue and my pull
  68. request for a fix was accepted and merged:
  69. https://github.com/OttoWinter/AsyncTCP/pull/4
  70. This fix will likely be available in the next release of ESPHome
  71. (the current version at the time of writing is 1.16.2).
  72. If you want to try out this fix on beforehand, then create a `libs` folder
  73. in the folder where your device's yaml configuration file is stored (e.g.
  74. when using the Home Assistant plugin: `/config/esphome/libs/`).
  75. Then clone the following repository into that folder:
  76. https://github.com/OttoWinter/AsyncTCP
  77. For example on the command line:
  78. ```
  79. # cd /config/esphome
  80. # mkdir libs
  81. # cd libs
  82. # git clone https://github.com/OttoWinter/AsyncTCP
  83. ```
  84. Then add a pointer to this folder from within your device's yaml
  85. configuration file, using the `lib_extra_dirs` option. Provide it with the
  86. absolute path to your `libs` folder. The relevant part of the config change
  87. looks like this (matching the example from above):
  88. ```yaml
  89. esphome:
  90. platformio_options:
  91. lib_extra_dirs: /config/esphome/libs
  92. ```
  93. This way, the repository version of the library will override the version of
  94. the library that is bundled with ESPHome. Build the device firmware and
  95. flash the device like you would normally do.