Files
buttonplus-esphome-generator/README.md
T

3.2 KiB

buttonplus-esphome-generator

A python script that generates a full ESPHome config for the Button+ with V2 PCB

Features

  • Notification Action: esphome.<name>_notification
    • Shows a notification, which has to be dismissed
  • Clear notification Action: esphome.<name>_notification_clear
  • Toast Action: esphome.<name>_toast
    • Shows a quick toast message which dissapears after a timeout
    • Perfect for confirming actions
  • Get info Action: esphome.<name>_get_info
    • Shows data needed for the set_page_led action
    • Including the available effects, led names and page names
  • Set Led per page Action: esphome.<name>_set_page_led
    • Allows you to set the LED for a specific page
    • So that you don't need to keep track of which page is active when setting a LED
    • All fields are required, because optionality is not possible at this moment
      • Effect can be set to None
      • RGB and Brightness should be values between 0 and 255
  • Reset all LEDS: esphome.<name>_reset_all_page_leds
    • Every LED config for every page will be set back to off and clear all data
  • Show web image: esphome.<name>_show_web_jpeg_image
    • Must be a url to a JPG image!
    • Will be resized to 320x240 pixels.
    • Will disappear after the timeout and be removed from memory
    • Will look absolutely horrendous
  • Show HA image: esphome.<name>_show_ha_jpeg_image
    • Only available if a Home Assistant --token TOKEN is set during generation
    • Allows loading of images which require login from Home Assistant
    • Sets the Authorization: Bearer <token> header
    • All other things from the web image action
  • Clear images before their timeout: esphome.<name>_clear_image
    • Will clear both web or HA image immediatly and release the memory
  • Generates pages and all buttons and events belonging to each page
  • Breathe and Blink effect for all LEDs
  • Confirmation LED pulse on button press

And all of that is split into two files for convenience. Everything you can and should edit or create manually in the top level file, while everything else is in the secondary file.

Setup

Project uses pipenv (Optional)

run pipenv install to setup the project the first time.

run pipenv shell after that to open the virtual environment.

Run script

You can then use python src/main.py --help to run the generator

Example run commands

python src/main.py -v 1 -b 3 -p Start Music Lights Security -c single double hold --token EXAMPLE_TOKEN --no-click-confirm python src/main.py --device-name Generated_ButtonPlus --version 2 --bars 1 --pages Home Living --click-types single hold --no-split --output buttonplus

Config example

The configuration (handmade) on which this generator was initially based, can be found in the esphome folder. There is also an example of the output of this generator.

Credits

Initially based on the configuration of https://github.com/dixi83/ESPhome_ButtonPlus, all initial effort for this was done by dixi83 and balk77

More information (in Dutch) can be found here on Tweakers.net

Todo

Ideas

None

Missing config

None