diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0cc06c5..181fc76 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Create a detailed report to help us improve +about: Create a report to help us improve EspHoMaTriXv2 title: "[BUG]" labels: bug assignees: '' @@ -12,13 +12,14 @@ assignees: '' ## Describe the bug -Add a description of the bug. Detail the expected behaviour in contrast with the behaviour you're observing. +Add a description of the bug. Detail the expected behavior in contrast with the behavior you're observing. ## Additional information - used Hardware: - ESP32 or ESP8266 - - EspHoMaTriXv2 version: [ eg. 2023.5.0 ] + - EspHoMaTriXv2 version: [e.g. 2023.5.0] + ## To Reproduce @@ -48,4 +49,4 @@ If applicable, add screenshots to help explain your problem. ```text (optional) The YAML of your service calls -``` \ No newline at end of file +``` diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index da09395..04dde9e 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -1,8 +1,9 @@ --- name: Question -about: Open an issue to ask something + +about: Open an issue to ask something about EspHoMaTriXv2 title: "[QUESTION]" -labels: question +labels: help wanted, question assignees: '' --- @@ -16,7 +17,8 @@ Add here your question. - used Hardware: - ESP32 or ESP8266 - - EspHoMaTriXv2 version: [ eg. 2023.5.0 ] + + - EspHoMaTriXv2 version: [e.g. 2023.5.0] ## Logs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f2c706e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,33 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: + - develop + - main + pull_request: + +jobs: + build: + name: Build ${{ matrix.firmware.name }} + runs-on: ubuntu-latest + strategy: + matrix: + firmware: + - file: tests/ulanzi-easy.yaml + name: Ulanzi-Easy + manifest_filename: ulanzi-easy-manifest.json + - file: tests/ehtmxv2-template.yaml + name: EHMTX template + manifest_filename: ehtmxv2-template-manifest.json + fail-fast: false + steps: + - name: Checkout source code + uses: actions/checkout@v3.3.0 + - name: Build firmware + uses: esphome/build-action@v1.8.0 + id: esphome-build + with: + yaml_file: ${{ matrix.firmware.file }} + version: latest diff --git a/.gitignore b/.gitignore index 7449912..26a9f37 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ venv .esphome/ _icons/ _fonts/ -secrets.yaml esphome.ps1 dev_*.yaml ehmtx8266.yaml @@ -27,3 +26,5 @@ ltr1.png ltr2.png ltr3.png 8x32 iMAGE.xcf + +.vscode/c_cpp_properties.json diff --git a/M5Stack-sample.md b/M5Stack-sample.md new file mode 100644 index 0000000..295f7e4 --- /dev/null +++ b/M5Stack-sample.md @@ -0,0 +1,15 @@ +# M5 Stack Sample + +## caution + +This is not the hardware paulus used in his videos for the demonstration. The M5Stack atom echo is sold **out**. So, I used another hardware without a speaker! + +The "M5Stack ATOM Lite ESP32 Development Kit" with "M5Stack PDM MEMS Microphone Unit (SPM1423)" were used. The M5Stack Atom Echo needs another pin configuration! + +The setup was just for demonstration, you should **never** power your matrix via the esp32!!! + +## video + +[Youtube](https://www.youtube.com/watch?v=CsOir14DCbM) + +**Use at your own risk!!!!** \ No newline at end of file diff --git a/M5withMIC.yml b/M5withMIC.yml new file mode 100644 index 0000000..b6e692c --- /dev/null +++ b/M5withMIC.yml @@ -0,0 +1,147 @@ +substitutions: + devicename: m5mic + +external_components: + - source: + type: git + url: https://github.com/lubeda/EsphoMaTrix + refresh: 60s + components: [ehmtxv2] + +web_server: + +esphome: + name: $devicename + comment: 8x32 Statusdisplay mit Microphone + on_boot: + lambda: |- + id(rgb8x32)->set_display_on(); + +esp32: + board: m5stack-atom + +i2s_audio: + i2s_lrclk_pin: GPIO32 + i2s_bclk_pin: GPIO19 # Egal + +microphone: + - platform: i2s_audio + id: echo_microphone + i2s_din_pin: GPIO26 + +voice_assistant: + microphone: echo_microphone + on_stt_end: + lambda: |- + id(rgb8x32)->icon_screen("home_assistant",x.c_str()); + id(rgb8x32)->force_screen("home_assistant"); + on_tts_start: + lambda: |- + id(rgb8x32)->icon_screen("mic",x.c_str()); + id(rgb8x32)->force_screen("mic"); + +binary_sensor: + - platform: status + name: "$devicename Status" + - platform: gpio + pin: + number: GPIO39 + inverted: true + name: ${devicename} Button + id: echo_button + on_press: + - voice_assistant.start: +on_release: + - voice_assistant.stop: +font: !include library/ehmtx_font.yaml + +switch: + - platform: template + name: "$devicename Display" + icon: "mdi:power" + restore_mode: ALWAYS_ON + lambda: |- + return id(rgb8x32)->show_display; + turn_on_action: + lambda: |- + id(rgb8x32)->set_display_on(); + turn_off_action: + lambda: |- + id(rgb8x32)->set_display_off(); + +logger: + level: DEBUG + +api: + +ota: + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +light: + - platform: neopixelbus + id: ehmtx_light + type: GRB + variant: WS2812 + pin: GPIO25 + num_leds: 256 + color_correct: [30%, 30%, 30%] + name: "$devicename Light" + restore_mode: ALWAYS_OFF + on_turn_on: + lambda: |- + id(ehmtx_display)->set_enabled(false); + on_turn_off: + lambda: |- + id(ehmtx_display)->set_enabled(true); + +time: + - platform: homeassistant + id: ehmtx_time + +display: + - platform: addressable_light + id: ehmtx_display + addressable_light_id: ehmtx_light + width: 32 + height: 8 + pixel_mapper: |- + if (x % 2 == 0) { + return (x * 8) + y; + } + return (x * 8) + (7 - y); + rotation: 0° + update_interval: 16ms + auto_clear_enabled: true + lambda: |- + id(rgb8x32)->tick(); + id(rgb8x32)->draw(); + +ehmtxv2: + id: rgb8x32 + matrix_component: ehmtx_display + time_component: ehmtx_time + icons2html: true + default_font_id: ehmtx_font + special_font_id: ehmtx_font + icons: + - id: error + lameid: 40530 + - id: home_assistant + lameid: 47693 + - id: temperature + lameid: 2056 + - id: lightbulb + lameid: 1762 + - id: music + lameid: 45625 + - id: phone + lameid: 1232 + - id: car + lameid: 2819 + - id: sleep8x32 + url: https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.gif + \ No newline at end of file diff --git a/README.md b/README.md index 3c07f29..ecbcba0 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ A simple but very flexible DIY status display, built with a flexible 8x32 RGB LE ![sample image](./images/sample.png) +If you like to tinker you can use the custom component even as a satelit voice control microphone. [Youtube](https://www.youtube.com/watch?v=CsOir14DCbM) + ## Background There are some "RGB-matrices" status displays/clocks out there, the commercial ones from LaMetric and Ulanzi, also some very good DIY-alternatives. @@ -546,7 +548,7 @@ Numerous features are accessible with services from home assistant and lambdas y |service|parameter|result| |---|---|---| -|`status`|none|write some status information to the esphome logs| +|`get_status`|none|write some status information to the esphome logs| |`display_on`|none|turn display off| |`display_off`|none|turn display on| |`hold_screen`|none|show the screen that is currently displayed for the number of seconds longer| @@ -556,9 +558,9 @@ Numerous features are accessible with services from home assistant and lambdas y |`show_gauge"`|"percent", "r", "g", "b"|set the height of the gauge according to the percentage in the given color| |`show_alarm`|"r", "g", "b", "size"|shows the color with the given size in the upper-right corner| |`show_indicator`|"r", "g", "b", "size"|shows the color with the given size in the lower-right corner| -|`clock_color`|"r", "g", "b"|set the default color for the clock/date display| -|`today_color"`|"r", "g", "b"|set the special color for today in the day of week line| -|`weekday_color"`|"r", "g", "b"|set the default color in the day of week line| +|`set_clock_color`|"r", "g", "b"|set the default color for the clock/date display| +|`set_today_color"`|"r", "g", "b"|set the special color for today in the day of week line| +|`set_weekday_color"`|"r", "g", "b"|set the default color in the day of week line| |`del_screen`|"icon_name", "mode"|deletes the specified icon screen from the queue, the [mode](#modes) is a filter| |`force_screen`|"icon_name", "mode"|displays the selected the specified icon screen from the queue, the [mode](#modes) is a filter| |`full_screen`|"icon_name", "lifetime", "screen_time"|show the specified 8x32 icon as full screen| @@ -572,6 +574,18 @@ Numerous features are accessible with services from home assistant and lambdas y |`date_screen`|"lifetime", "screen_time", "default_font", "r", "g", "b"|show the date| |`brightness`|"value"|set the display brightness| +#### Parameter description + +"r", "g", "b": Color components for red, green and blue 0..255 +"size": The size of the indicator or alarm, 1-3 +"percent": values from 0..100 +"icon_name": the id of the icon to show, as defined in the YAML file +"text": a text message to display +"lifetime": how long does this screen stay in the queue (minutes) +"screen_time": how long is this screen display in the loop (seconds). For short text without scrolling it is shown the defined time, longer text is scrolled at least `scroll_count` times. +"default_font": use the default font (true) or the special font (false) +"value": the brightness 0..255 + ### Local lambdas #### Add screen to your display queue @@ -823,7 +837,7 @@ binary_sensor: id(rgb8x32)->hold_screen(120); ``` -**(D)** Service **status** +**(D)** Service **get_status** This service displays the running queue and a list of icons in the logs diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index a739f6f..9df7e45 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -157,7 +157,7 @@ namespace esphome void EHMTX::setup() { ESP_LOGD(TAG, "Setting up services"); - register_service(&EHMTX::get_status, "status"); + register_service(&EHMTX::get_status, "get_status"); register_service(&EHMTX::set_display_on, "display_on"); register_service(&EHMTX::set_display_off, "display_off"); register_service(&EHMTX::hold_screen, "hold_screen", {"time"}); @@ -168,9 +168,9 @@ namespace esphome register_service(&EHMTX::show_alarm, "show_alarm", {"r", "g", "b", "size"}); register_service(&EHMTX::show_indicator, "show_indicator", {"r", "g", "b", "size"}); - register_service(&EHMTX::set_clock_color, "clock_color", {"r", "g", "b"}); - register_service(&EHMTX::set_today_color, "today_color", {"r", "g", "b"}); - register_service(&EHMTX::set_weekday_color, "weekday_color", {"r", "g", "b"}); + register_service(&EHMTX::set_clock_color, "set_clock_color", {"r", "g", "b"}); + register_service(&EHMTX::set_today_color, "set_today_color", {"r", "g", "b"}); + register_service(&EHMTX::set_weekday_color, "set_weekday_color", {"r", "g", "b"}); register_service(&EHMTX::del_screen, "del_screen", {"icon_name", "mode"}); register_service(&EHMTX::force_screen, "force_screen", {"icon_name", "mode"}); @@ -223,7 +223,7 @@ namespace esphome void EHMTX::update() // called from polling component { if (!this->is_running){ - if (this->clock->now().timestamp > 6000) { + if (this->clock->now().timestamp > 15) { ESP_LOGD(TAG, "time sync => starting"); this->is_running = true; } @@ -504,20 +504,35 @@ namespace esphome } EHMTX_queue *screen = this->find_icon_queue_element(icon); - int x, y, w, h; + int x, y, pixel, h; if (default_font) { - this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &w, &h); + this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); } else { - this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &w, &h); + this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); } - screen->set_text(text, icon, w, lifetime, screen_time); + if (pixel < 23) + { + screen->centerx_ = ceil((22 - pixel) / 2); + screen->screen_time = screen_time; + } + else + { + screen->centerx_ = 0; + int display_duration = ceil((this->scroll_count * (TEXTSTARTOFFSET + pixel) * this->scroll_interval) / 1000); + screen->screen_time = (display_duration > screen_time) ? display_duration : screen_time; + } + screen->text = text; + screen->pixels_ = pixel; + screen->endtime = this->clock->now().timestamp + lifetime * 60; + screen->shiftx_ = 0; screen->text_color = Color(r, g, b); screen->default_font = default_font; screen->mode = MODE_ICON_SCREEN; screen->icon_name = iconname; + screen->icon = icon; for (auto *t : on_add_screen_triggers_) { t->process(screen->icon_name,(uint8_t)screen->mode); @@ -526,6 +541,59 @@ namespace esphome screen->status(); } +void EHMTX::rainbow_icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font) + { + uint8_t icon = this->find_icon(iconname.c_str()); + + if (icon >= this->icon_count) + { + ESP_LOGW(TAG, "icon %d not found => default: 0", icon); + icon = 0; + for (auto *t : on_icon_error_triggers_) + { + t->process(iconname); + } + } + EHMTX_queue *screen = this->find_icon_queue_element(icon); + + int x, y, pixel, h; + if (default_font) + { + this->display->get_text_bounds(0, 0, text.c_str(), this->default_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); + } + else + { + this->display->get_text_bounds(0, 0, text.c_str(), this->special_font, display::TextAlign::LEFT, &x, &y, &pixel, &h); + } + if (pixel < 23) + { + screen->centerx_ = ceil((22 - pixel) / 2); + screen->screen_time = screen_time; + } + else + { + screen->centerx_ = 0; + int display_duration = ceil((this->scroll_count * (TEXTSTARTOFFSET + pixel) * this->scroll_interval) / 1000); + screen->screen_time = (display_duration > screen_time) ? display_duration : screen_time; + } + screen->text = text; + screen->pixels_ = pixel; + screen->endtime = this->clock->now().timestamp + lifetime * 60; + screen->shiftx_ = 0; + screen->default_font = default_font; + screen->mode = MODE_RAINBOW_ICON; + screen->icon_name = iconname; + screen->icon = icon; + for (auto *t : on_add_screen_triggers_) + { + t->process(screen->icon_name,(uint8_t)screen->mode); + } + ESP_LOGD(TAG, "rainbow icon screen icon: %d iconname: %s text: %s lifetime: %d screen_time: %d", icon, iconname.c_str(), text.c_str(), lifetime, screen_time); + screen->status(); + } + + + void EHMTX::rainbow_clock_screen(int lifetime, int screen_time, bool default_font) { EHMTX_queue *screen = this->find_free_queue_element(); @@ -550,38 +618,6 @@ namespace esphome screen->status(); } - - - void EHMTX::rainbow_icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font) - { - uint8_t icon = this->find_icon(iconname.c_str()); - - if (icon >= this->icon_count) - { - ESP_LOGW(TAG, "icon %d not found => default: 0", icon); - icon = 0; - for (auto *t : on_icon_error_triggers_) - { - t->process(iconname); - } - } - EHMTX_queue *screen = this->find_icon_queue_element(icon); - screen->icon_name = iconname; - screen->icon = icon; - screen->text = text; - screen->endtime = this->clock->now().timestamp + lifetime * 60; - screen->screen_time = screen_time; - screen->default_font = default_font; - screen->mode = MODE_RAINBOW_ICON; - screen->calc_scroll_time(); - for (auto *t : on_add_screen_triggers_) - { - t->process(screen->icon_name,(uint8_t)screen->mode); - } - ESP_LOGD(TAG, "rainbow_icon_screen icon: %d iconname: %s text: %s lifetime: %d screen_time: %d", icon, iconname.c_str(), text.c_str(), lifetime, screen_time); - screen->status(); - } - void EHMTX::text_screen(std::string text, int lifetime, int screen_time, bool default_font, int r, int g, int b) { EHMTX_queue *screen = this->find_free_queue_element(); diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 7ed5507..c07c1ca 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -37,7 +37,7 @@ namespace esphome class EHMTX : public PollingComponent, public api::CustomAPIDevice { protected: - float get_setup_priority() const override { return esphome::setup_priority::WIFI; } + float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; } uint8_t brightness_; uint32_t boot_anim=0; uint8_t screen_pointer; diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 143c643..327dd14 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -127,7 +127,7 @@ namespace esphome case MODE_CLOCK: if (this->config_->clock->now().timestamp > 6000) // valid time { - color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->text_color; + color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; this->config_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER, this->config_->time_fmt.c_str(), this->config_->clock->now()); @@ -148,7 +148,7 @@ namespace esphome case MODE_DATE: if (this->config_->clock->now().timestamp > 6000) // valid time { - color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->text_color; + color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->config_->clock_color; time_t ts = this->config_->clock->now().timestamp; this->config_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER, this->config_->date_fmt.c_str(), this->config_->clock->now()); @@ -238,7 +238,7 @@ namespace esphome this->shiftx_ = 0; float display_duration = ceil((this->config_->scroll_count * (TEXTSTARTOFFSET + pixel) * this->config_->scroll_interval) / 1000); this->screen_time = (display_duration > screen_time) ? display_duration : screen_time; - ESP_LOGD(TAG, "display text: %s pixels %d calculated: %d screen_time: %d", text.c_str(), pixel, this->screen_time, screen_time); + ESP_LOGD(TAG, "display text: %s pixels %d display_duration %d calculated: %d screen_time: %d", text.c_str(), pixel,display_duration, this->screen_time, screen_time); this->endtime = this->config_->clock->now().timestamp + et * 60; this->icon = icon; } diff --git a/copy2esphome/ehtmxv2-template.yaml b/copy2esphome/ehtmxv2-template.yaml deleted file mode 100644 index 9ba87bb..0000000 --- a/copy2esphome/ehtmxv2-template.yaml +++ /dev/null @@ -1,110 +0,0 @@ -substitutions: - devicename: ehmtxv2 - friendly_name: LED Matrix - board: esp32dev - matrix_pin: GPIO32 - -external_components: - - source: - type: git - url: https://github.com/lubeda/EspHoMaTriXv2 - ref: release - refresh: 60s - components: [ ehmtxv2 ] - -esphome: - comment: "EHMTXv2 from LuBeDa" - name: $devicename - -esp32: - board: esp32dev - -font: - - file: EHMTXv2.ttf - size: 16 - id: default_font - glyphs: | - !?"%()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ß§€/ - -binary_sensor: - - platform: status - name: "$devicename Status" - -logger: - level: WARN - -api: - -sensor: - -ota: - password: !secret ota_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - -web_server: - -light: - - platform: neopixelbus - id: ehmtx_light - type: GRB - internal: true - variant: WS2812 - pin: $ledpin - num_leds: 256 - color_correct: [30%, 30%, 30%] - gamma_correct: 2.0 - name: "$devicename Light" - restore_mode: ALWAYS_OFF - -time: - - platform: homeassistant - id: ehmtx_time - -display: - - platform: addressable_light - id: ehmtx_display - addressable_light_id: ehmtx_light - width: 32 - height: 8 - pixel_mapper: |- - if (y % 2 == 0) { - return (y * 32) + x; - } - return (y * 32) + (31 - x); - rotation: 0° - update_interval: 16ms - auto_clear_enabled: true - lambda: |- - id(rgb8x32)->tick(); - id(rgb8x32)->draw(); - -ehmtxv2: - id: rgb8x32 - icons2html: true - matrix_component: ehmtx_display - time_component: ehmtx_time - time_format: "%H:%M" - date_format: "%d.%m." - show_seconds: false - default_font_id: default_font - special_font_id: default_font - icons: - - id: error - lameid: 40530 - - id: home_assistant - lameid: 47693 - - id: temperature - lameid: 2056 - - id: lightbulb - lameid: 1762 - - id: music - lameid: 45625 - - id: phone - lameid: 1232 - - id: car - lameid: 2819 - - id: sleep8x32 - url: https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.gif diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index c0a0f7e..1a2a49f 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -253,5 +253,5 @@ ehmtxv2: - homeassistant.event: event: esphome.new_screen data_template: - iconname: !lambda "return x.c_str();" - text: !lambda "return y.c_str();" + iconname: !lambda "return icon.c_str();" + text: !lambda "return text.c_str();" diff --git a/tests/EHMTXv2.ttf b/tests/EHMTXv2.ttf new file mode 100644 index 0000000..0709311 Binary files /dev/null and b/tests/EHMTXv2.ttf differ diff --git a/tests/ehtmxv2-template.yaml b/tests/ehtmxv2-template.yaml new file mode 100644 index 0000000..245595a --- /dev/null +++ b/tests/ehtmxv2-template.yaml @@ -0,0 +1,157 @@ +substitutions: + devicename: ehmtxv2 + friendly_name: LED Matrix + board: esp32dev + matrix_pin: GPIO32 + +external_components: + - source: + type: local + path: ../components + components: [ ehmtxv2 ] + +esphome: + comment: "EHMTXv2 TEXT from LuBeDa" + name: $devicename + on_boot: + lambda: |- + id(rgb8x32)->show_indicator(255,100,50,2); + id(rgb8x32)->hide_indicator(); + id(rgb8x32)->show_alarm(255,0,150,3); + id(rgb8x32)->hide_alarm(); + id(rgb8x32)->icon_screen("error","Hallo Text",false,237,20,100,200,150); + id(rgb8x32)->force_screen("error"); + id(rgb8x32)->del_screen("error"); + id(rgb8x32)->del_screen("error",5); + id(rgb8x32)->rainbow_icon_screen("error","Hallo Text",true,237,20); + id(rgb8x32)->get_status(); + id(rgb8x32)->set_display_on(); + id(rgb8x32)->set_display_off(); + id(rgb8x32)->hold_screen(); + id(rgb8x32)->show_gauge(100,0,200); + id(rgb8x32)->hide_gauge(); + id(rgb8x32)->set_clock_color(200,100,50); + id(rgb8x32)->set_today_color(200,100,50); + id(rgb8x32)->set_weekday_color(200,100,50); + id(rgb8x32)->full_screen("scale"); + id(rgb8x32)->rainbow_icon_screen("error","Oh ein Text"); + id(rgb8x32)->text_screen("text",30); + id(rgb8x32)->rainbow_text_screen("text",30); + id(rgb8x32)->clock_screen(30,5); + id(rgb8x32)->rainbow_clock_screen(30,5); + id(rgb8x32)->date_screen(30,5); + id(rgb8x32)->rainbow_date_screen(30,5); + id(rgb8x32)->blank_screen(30,5); + id(rgb8x32)->set_brightness(20); + +esp32: + board: esp32dev + +font: + - file: EHMTXv2.ttf + size: 16 + id: default_font + glyphs: | + !?"%()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ß§€/ + +binary_sensor: + - platform: status + name: "$devicename Status" + +logger: + level: WARN + +api: + +sensor: + +ota: + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +web_server: + +light: + - platform: neopixelbus + id: ehmtx_light + type: GRB + internal: true + variant: WS2812 + pin: $matrix_pin + num_leds: 256 + color_correct: [30%, 30%, 30%] + gamma_correct: 2.0 + name: "$devicename Light" + restore_mode: ALWAYS_OFF + +time: + - platform: homeassistant + id: ehmtx_time + +display: + - platform: addressable_light + id: ehmtx_display + addressable_light_id: ehmtx_light + width: 32 + height: 8 + pixel_mapper: |- + if (y % 2 == 0) { + return (y * 32) + x; + } + return (y * 32) + (31 - x); + rotation: 0° + update_interval: 16ms + auto_clear_enabled: true + lambda: |- + id(rgb8x32)->tick(); + id(rgb8x32)->draw(); + +ehmtxv2: + id: rgb8x32 + icons2html: true + matrix_component: ehmtx_display + time_component: ehmtx_time + time_format: "%H:%M" + date_format: "%d.%m." + show_seconds: false + default_font_id: default_font + special_font_id: default_font + icons: + - id: error + lameid: 40530 + - id: scale + file: scale.gif + resize: 32x8 + - id: sleep8x32 + url: https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.gif + on_next_screen: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: !lambda "return icon.c_str();" + text: !lambda "return text.c_str();" + on_add_screen: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: !lambda "return icon.c_str();" + mode: !lambda "return mode;" + on_next_clock: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: "Hallo" + on_expired_screen: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: !lambda "return icon.c_str();" + text: !lambda "return text.c_str();" + on_icon_error: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: !lambda "return icon.c_str();" \ No newline at end of file diff --git a/tests/scale.gif b/tests/scale.gif new file mode 100644 index 0000000..c877064 Binary files /dev/null and b/tests/scale.gif differ diff --git a/tests/secrets.yaml b/tests/secrets.yaml new file mode 100644 index 0000000..fd4d5d8 --- /dev/null +++ b/tests/secrets.yaml @@ -0,0 +1,4 @@ +# This is just a a sample for CI/CD!! +ota_password: itsecret +wifi_password: itsecret +wifi_ssid: itsecret \ No newline at end of file diff --git a/tests/ulanzi-easy.yaml b/tests/ulanzi-easy.yaml new file mode 100644 index 0000000..1a2a49f --- /dev/null +++ b/tests/ulanzi-easy.yaml @@ -0,0 +1,257 @@ +substitutions: + devicename: ulanzi + ledpin: GPIO32 + buzzerpin: GPIO15 + friendly_name: LED Matrix + board: esp32dev + # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi + battery_pin: GPIO34 + ldr_pin: GPIO35 + matrix_pin: GPIO32 + left_button_pin: GPIO26 + mid_button_pin: GPIO27 + right_button_pin: GPIO14 + buzzer_pin: GPIO15 + scl_pin: GPIO22 + sda_pin: GPIO21 + +switch: + - platform: template + name: "Auto-Adjust Brightness" + id: switch_autobrightness + icon: mdi:brightness-auto + restore_mode: RESTORE_DEFAULT_ON + lambda: |- + if (id(aab_enable)) { + return true; + } else { + return false; + } + turn_on_action: + lambda: |- + id(aab_enable) = true; + turn_off_action: + lambda: |- + id(aab_enable) = false; + +globals: + # aab = auto-adjustable brightness + - id: aab_enable + type: "bool" + restore_value: true + initial_value: "true" + - id: aab_add + type: int + initial_value: '10' + - id: aab_max + type: int + initial_value: '220' + - id: aab_min + type: int + initial_value: '20' + +external_components: + - source: + type: git + url: https://github.com/lubeda/EspHoMaTriXv2 + ref: main + refresh: 60s + components: [ ehmtxv2 ] + +esphome: + comment: "EHMTXv2 from LuBeDa" + name: $devicename + on_boot: + then: + - ds1307.read_time: + +esp32: + board: esp32dev + +font: + - file: EHMTXv2.ttf + size: 16 + id: default_font + glyphs: | + !?"%()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ß§€/ + +binary_sensor: + - platform: status + name: "$devicename Status" + - platform: gpio + pin: + number: $left_button_pin + inverted: true + name: "Left button" + - platform: gpio + pin: + inverted: true + number: $mid_button_pin + mode: INPUT_PULLUP + name: "Middle button" + - platform: gpio + pin: + number: $right_button_pin + inverted: true + name: "Right button" + +logger: + level: WARN + +api: + services: + - service: tune + variables: + tune: string + then: + - rtttl.play: + rtttl: !lambda 'return tune;' + +sensor: + - platform: sht3xd + temperature: + name: "$devicename Temperature" + humidity: + name: "$devicename Relative Humidity" + update_interval: 60s + - platform: adc + pin: $battery_pin + name: "$devicename Battery" + id: battery_voltage + update_interval: 10s + device_class: battery + accuracy_decimals: 0 + attenuation: auto + filters: + - sliding_window_moving_average: + window_size: 15 + send_every: 15 + send_first_at: 1 + - multiply: 1.6 + - lambda: |- + auto r = ((x - 3) / 0.69 * 100.00); + if (r >= 100) return 100; + if (r > 0) return r; + if (r <= 0) return 1; + return 0; + unit_of_measurement: '%' + - platform: adc + id: light_sensor + name: "$devicename Illuminance" + pin: $ldr_pin + update_interval: 10s + attenuation: auto + unit_of_measurement: lx + device_class: illuminance + accuracy_decimals: 0 + filters: + - lambda: |- + return (x / 10000.0) * 2000000.0 - 15 ; + on_value: + then: + - lambda: |- + if ( id(aab_enable) ) { + int n = x / 4 + id(aab_add); // new_value + if (n > id(aab_max)) n = id(aab_max); + if (n < id(aab_min)) n = id(aab_min); + int c = id(rgb8x32)->get_brightness(); // current value + int d = (n - c) * 100 / c; // diff in % + if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n); + } + +ota: + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +web_server: + +output: + - platform: ledc + pin: $buzzerpin + id: rtttl_out + +rtttl: + output: rtttl_out + +i2c: + sda: $sda_pin + scl: $scl_pin + scan: true + id: i2cbus + +light: + - platform: neopixelbus + id: ehmtx_light + type: GRB + internal: true + variant: WS2812 + pin: $ledpin + num_leds: 256 + color_correct: [30%, 30%, 30%] + gamma_correct: 2.0 + name: "$devicename Light" + restore_mode: ALWAYS_OFF + +time: + - platform: homeassistant + on_time_sync: + then: + ds1307.write_time: + - platform: ds1307 + update_interval: never + id: ehmtx_time + +display: + - platform: addressable_light + id: ehmtx_display + addressable_light_id: ehmtx_light + width: 32 + height: 8 + pixel_mapper: |- + if (y % 2 == 0) { + return (y * 32) + x; + } + return (y * 32) + (31 - x); + rotation: 0° + update_interval: 16ms + auto_clear_enabled: true + lambda: |- + id(rgb8x32)->tick(); + id(rgb8x32)->draw(); + +ehmtxv2: + id: rgb8x32 + icons2html: true + matrix_component: ehmtx_display + time_component: ehmtx_time + time_format: "%H:%M" + date_format: "%d.%m." + show_seconds: false + default_font_id: default_font + special_font_id: default_font + icons: + - id: error + lameid: 40530 + - id: home_assistant + lameid: 47693 + - id: temperature + lameid: 2056 + - id: lightbulb + lameid: 1762 + - id: music + lameid: 45625 + - id: phone + lameid: 1232 + - id: car + lameid: 2819 + - id: sleep8x32 + url: https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.gif + on_next_screen: + - homeassistant.event: + event: esphome.new_screen + data_template: + iconname: !lambda "return icon.c_str();" + text: !lambda "return text.c_str();"