mmakaay / esphome-xiaomi_bslamp2

ESPHome integration for the Xiaomi Mijia Bedside Lamp v2.
Other
204 stars 49 forks source link

Additional effects #128

Open ercsey opened 3 months ago

ercsey commented 3 months ago

Hello

Sorry for newbie question, but is it possible to add/include additional effects to the code? If yes then could you please tell me how? I need to include a "Blink" effect to the code because many of my HA scripts use the light.turn_on service with a blink effect. Thank you for your help.

mmakaay commented 2 weeks ago

The effects are part of the ESPHome code, not of this firmware. So no coding is required for this. What you want to do here, is customize the configuration of the lamp. As a quick start help, I wrote behaviors for the lamp that copy the behaviors of the original lamp's firmware. You can use your own configuration thought.

Steps:

In your device YAML file, remove / comment the line that includes the default behaviors. Here's a link to the specific line: https://github.com/mmakaay/esphome-xiaomi_bslamp2/blob/2a6944e2f9990fbea9a58d87bb57877ec607512c/example.yaml#L38 Doing so removes the default behaviors from the lamp's config.

Next, copy the code from the default behaviors into your device YAML file. This code can be found in the file: https://github.com/mmakaay/esphome-xiaomi_bslamp2/blob/dev/packages/behavior_default.yaml

After doing so, your lamp should work the same as before. The main difference is that you can now tweak the configuration to your likings. Inside the copied code, you will find the light definition that contains the possible effects. You can see that here: https://github.com/mmakaay/esphome-xiaomi_bslamp2/blob/2a6944e2f9990fbea9a58d87bb57877ec607512c/packages/behavior_default.yaml#L76

After updating, flash the lamp with the new firmware and enjoy your customized configuration.