diff --git a/CHANGELOG.md b/CHANGELOG.md index 25d23fd1..a23d9d33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,18 @@ # Changelog +## 2023.6.3 + +- introduced `default_clock_font: true` +- changed *_interval to be set only on compile time +- change scroll_count to be set only on compile time +- change font_offsets to be set only on compile time +- change date/time_format to be set only on compile time +- remove unused frame_interval + ## 2023.6.2 - set rtl mode at compile time +- changed clock to default font ## 2023.6.1 diff --git a/README.md b/README.md index c1520ffa..f310c261 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ There are some “RGB-matrices” status displays/clocks out there, the commerci - [LaMetric](https://lametric.com/en-US/) commercial ~ €199 - [Ulanzi TC001](https://www.aliexpress.com/item/1005005008682055.html) commercial ~ €50 - [AWTRIX](https://awtrixdocs.blueforcer.de/#/) (project has been discontinued after more than 4 years in August 2022) -- [Pixel It](https://docs.bastelbunker.de/pixelit/) (project is under active development) +- [Pixel It](https://pixelit-project.github.io/) (project is under active development) - [AWTRIX-Light](https://github.com/Blueforcer/awtrix-light) From the developer of AWTRIX, optimized for the Ulanzi TC001 hardware The solutions have their pros and cons. I tried some and used AWTRIX for a long time. But the cons are so big (in my opinion) that I started an esphome.io variant. Targeted to an optimized Home Assistant integration, without paid blueprints and the need of MQTT or uploading files to the ESP. @@ -34,7 +34,7 @@ Based on a 8x32 RGB matrix, it displays a clock, the date and up to 24 other 'sc ### State -After the [old](https://github.com/lubeda/EsphoMaTrix) component became favorite, there were some feature requests, which indicated that my old code was a mess. I reworked the whole code and restructured it, so it is now hopefully more extensible. +After the [old](https://github.com/lubeda/EsphoMaTrix) component became favorite, there were some feature requests, which indicated that my old code was a mess. I reworked the whole code and restructured it, so it is now hopefully more extensible. **This software is still heavily in progress, before updating check the [breaking changes](#breaking-changes)** ### Advice @@ -504,7 +504,6 @@ ehmtxv2:   scroll_count: 2 # scroll long text at least two times   scroll_interval: 80 # milliseconds   rainbow_interval: 32 # milliseconds -  frame_interval: 192 # milliseconds   icons:   ..... ``` @@ -543,9 +542,9 @@ ehmtxv2: **week_start_monday** (optional, bool): default Monday is first day of week, false => Sunday -**scroll_interval** (optional, ms): the interval in ms to scroll the text (default=80), should be a multiple of the ```update_interval``` of the [display](https://esphome.io/components/display/addressable_light.html) +**default_clock_font** (optional, boolean): If true, use the default font for clock and date otherwise use the special font. (default = `true`) -**frame_interval** (optional, ms): the interval in ms to display the next animation/icon frame (default = 192), should be a multiple of the [display](https://esphome.io/components/display/addressable_light.html). It can be overwritten per icon/GIF, see [icons](#icons-and-animations) parameter `frame_duration` +**scroll_interval** (optional, ms): the interval in ms to scroll the text (default=80), should be a multiple of the ```update_interval``` of the [display](https://esphome.io/components/display/addressable_light.html) **clock_interval** (optional, s): the interval in seconds to force the clock display. By default, the clock screen, if any, will be displayed according to the position in the queue. **If you set the clock_interval close to the screen_time of the clock, you will only see the clock!** (default=0) @@ -1066,6 +1065,15 @@ sensor: ## Breaking changes +### 2023.6.3 + +**Due to this change these values are fixed, e.g. you can not change the date or timeformat during runtime anymore!!** + +- changed *_interval to be set only on compile time +- change scroll_count to be set only on compile time +- change font_offsets to be set only on compile time +- change date/time_format to be set only on compile time + ### 2023.5.0 - renamed `indicator` to `rindicator` because there is now also a `lindicator` @@ -1101,9 +1109,10 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk! - **[aptonline](https://github.com/aptonline)** for his work on the Ulanzi hardware - **[wsbtak](https://github.com/wsbtak)** for the work on the Ulanzi hardware - **[ofirsnb](https://github.com/ofirsnb)** for his contributions -- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts and user support +- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts and user support and work on the wiki - **[pplucky](https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.GIF)** for his 8x32 GIF animation - **[dennisse](https://github.com/dennisse)** Auto brightness for the Ulanzi +- **[hco](https://github.com/hco)** fixing documentation - **[geekofweek](https://github.com/geekofweek)** fixed sample YAML - **Everybody** who found bugs/issues and reported them! diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 239668fb..4143b35f 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -11,7 +11,6 @@ namespace esphome this->display_lindicator = 0; this->display_alarm = 0; this->clock_time = 10; - this->clock_interval = 90; this->hold_time = 10; this->icon_count = 0; this->hue_ = 0; @@ -35,16 +34,6 @@ namespace esphome ESP_LOGD(TAG, "Constructor finish"); } - void EHMTX::set_time_format(std::string s) - { - this->time_fmt = s; - } - - void EHMTX::set_date_format(std::string s) - { - this->date_fmt = s; - } - void EHMTX::show_rindicator(int r, int g, int b, int size) { if (size > 0) @@ -352,8 +341,8 @@ namespace esphome this->bitmap_screen(EHMTX_LOGO, 1, 10); this->bitmap_small(EHMTX_SLOGO, EHMTX_VERSION, 1, 10); #endif - this->clock_screen(14 * 24 * 60, this->clock_time, true, C_RED, C_GREEN, C_BLUE); - this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, true, C_RED, C_GREEN, C_BLUE); + this->clock_screen(14 * 24 * 60, this->clock_time, EHMTXv2_DEFAULT_CLOCK_FONT, C_RED, C_GREEN, C_BLUE); + this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, EHMTXv2_DEFAULT_CLOCK_FONT, C_RED, C_GREEN, C_BLUE); this->is_running = true; } } @@ -409,14 +398,14 @@ namespace esphome uint8_t EHMTX::find_last_clock() { uint8_t hit = MAXQUEUE; - if (this->clock_interval > 0) + if (EHMTXv2_CLOCK_INTERVALL > 0) { time_t ts = this->clock->now().timestamp; for (size_t i = 0; i < MAXQUEUE; i++) { if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK)) { - if (ts > (this->queue[i]->last_time + this->clock_interval)) + if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVALL)) { hit = i; } @@ -501,7 +490,7 @@ namespace esphome { time_t ts = this->clock->now().timestamp; - if (millis() - this->last_scroll_time >= this->scroll_interval) + if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVALL) { this->scroll_step++; this->last_scroll_time = millis(); @@ -582,8 +571,8 @@ namespace esphome this->clock->now().month, this->clock->now().year, this->clock->now().hour, this->clock->now().minute); ESP_LOGI(TAG, "status brightness: %d (0..255)", this->brightness_); - ESP_LOGI(TAG, "status date format: %s", this->date_fmt.c_str()); - ESP_LOGI(TAG, "status time format: %s", this->time_fmt.c_str()); + ESP_LOGI(TAG, "status date format: %s", EHMTXv2_DATE_FORMAT); + ESP_LOGI(TAG, "status time format: %s", EHMTXv2_TIME_FORMAT); ESP_LOGI(TAG, "status alarm_color: RGB(%d,%d,%d)", this->alarm_color.r, this->alarm_color.g, this->alarm_color.b); if (this->show_display) { @@ -621,21 +610,6 @@ namespace esphome this->special_font = font; } - void EHMTX::set_frame_interval(uint16_t fi) - { - this->frame_interval = fi; - } - - void EHMTX::set_scroll_interval(uint16_t si) - { - this->scroll_interval = si; - } - - void EHMTX::set_rainbow_interval(uint16_t si) - { - this->rainbow_interval = si; - } - void EHMTX::del_screen(std::string icon_name, int mode) { for (uint8_t i = 0; i < MAXQUEUE; i++) @@ -665,11 +639,6 @@ namespace esphome } } - void EHMTX::set_clock_interval(uint16_t t) - { - this->clock_interval = t; - } - void EHMTX::icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font, int r, int g, int b) { uint8_t icon = this->find_icon(iconname.c_str()); @@ -739,13 +708,13 @@ namespace esphome ESP_LOGD(TAG, "rainbow_clock_screen lifetime: %d screen_time: %d", lifetime, screen_time); screen->mode = MODE_RAINBOW_CLOCK; screen->default_font = default_font; - if (this->clock_interval == 0 || (this->clock_interval > screen_time)) + if (EHMTXv2_CLOCK_INTERVALL == 0 || (EHMTXv2_CLOCK_INTERVALL > screen_time)) { screen->screen_time_ = screen_time; } else { - screen->screen_time_ = this->clock_interval - 2; + screen->screen_time_ = EHMTXv2_CLOCK_INTERVALL - 2; } screen->endtime = this->clock->now().timestamp + lifetime * 60; screen->status(); @@ -896,17 +865,6 @@ namespace esphome } } -#ifdef EHMTXv2_USE_RTL - void EHMTX::set_rtl(bool b) - { - this->rtl = b; - if (b) - { - ESP_LOGI(TAG, "show text right to left"); - } - } -#endif - void EHMTX::set_show_seconds(bool b) { this->show_seconds = b; @@ -933,19 +891,6 @@ namespace esphome } } - void EHMTX::set_week_start(bool b) - { - this->week_starts_monday = b; - if (b) - { - ESP_LOGI(TAG, "weekstart: monday"); - } - else - { - ESP_LOGI(TAG, "weekstart: sunday"); - } - } - void EHMTX::set_brightness(int value) { if (value < 256) @@ -967,11 +912,6 @@ namespace esphome this->clock_time = t; } - void EHMTX::set_scroll_count(uint8_t c) - { - this->scroll_count = c; - } - void EHMTX::set_display(addressable_light::AddressableLightDisplay *disp) { this->display = disp; @@ -992,8 +932,8 @@ namespace esphome auto dow = this->clock->now().day_of_week - 1; // SUN = 0 for (uint8_t i = 0; i <= 6; i++) { - if (((!this->week_starts_monday) && (dow == i)) || - ((this->week_starts_monday) && ((dow == (i + 1)) || ((dow == 0 && i == 6))))) + if (((!EHMTXv2_WEEK_START) && (dow == i)) || + ((EHMTXv2_WEEK_START) && ((dow == (i + 1)) || ((dow == 0 && i == 6))))) { this->display->line(2 + i * 4, 7, i * 4 + 4, 7, this->today_color); } @@ -1005,28 +945,14 @@ namespace esphome } }; - void EHMTX::set_default_font_offset(int8_t y, int8_t x) - { - this->default_xoffset = x; - this->default_yoffset = y; - ESP_LOGD(TAG, "set_default_font_offset x: %d y: %d", x, y); - } - - void EHMTX::set_special_font_offset(int8_t y, int8_t x) - { - this->special_xoffset = x; - this->special_yoffset = y; - ESP_LOGD(TAG, "set_special_font_offset x: %d y: %d", x, y); - } - void EHMTX::dump_config() { ESP_LOGCONFIG(TAG, "EspHoMatriXv2 version: %s", EHMTX_VERSION); ESP_LOGCONFIG(TAG, "Icons: %d of %d", this->icon_count, MAXICONS); - ESP_LOGCONFIG(TAG, "Clock interval: %d s", this->clock_interval); - ESP_LOGCONFIG(TAG, "Date format: %s", this->date_fmt.c_str()); - ESP_LOGCONFIG(TAG, "Time format: %s", this->time_fmt.c_str()); - ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d frame: %d", this->scroll_interval, this->frame_interval); + ESP_LOGCONFIG(TAG, "Clock interval: %d s", EHMTXv2_CLOCK_INTERVALL); + ESP_LOGCONFIG(TAG, "Date format: %s", EHMTXv2_DATE_FORMAT); + ESP_LOGCONFIG(TAG, "Time format: %s", EHMTXv2_TIME_FORMAT); + ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d", EHMTXv2_SCROLL_INTERVALL); if (this->show_day_of_week) { ESP_LOGCONFIG(TAG, "show day of week"); @@ -1038,7 +964,7 @@ namespace esphome #ifdef EHMTXv2_USE_RTL ESP_LOGCONFIG(TAG, "RTL activated"); #endif - if (this->week_starts_monday) + if (EHMTXv2_WEEK_START) { ESP_LOGCONFIG(TAG, "weekstart: monday"); } diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 4d0e5c40..2b30accf 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -22,7 +22,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t POLLINGINTERVAL = 250; -static const char *const EHMTX_VERSION = "2023.6.2"; +static const char *const EHMTX_VERSION = "2023.6.3"; static const char *const TAG = "EHMTXv2"; #ifndef USE_ESP8266 static const char *const EHMTX_LOGO = "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"; @@ -62,7 +62,6 @@ namespace esphome uint8_t brightness_; uint32_t boot_anim = 0; uint8_t screen_pointer; - bool week_starts_monday; bool show_day_of_week; std::vector on_next_screen_triggers_; @@ -81,16 +80,12 @@ namespace esphome void dump_config(); #ifdef USE_ESP32 PROGMEM Color text_color, alarm_color, gauge_color, gauge_bgcolor, rindicator_color, lindicator_color,clock_color, today_color, weekday_color, rainbow_color; - PROGMEM std::string time_fmt; - PROGMEM std::string date_fmt; PROGMEM Color bitmap[256]; PROGMEM Color sbitmap[64]; PROGMEM EHMTX_Icon *icons[MAXICONS]; #endif #ifdef USE_ESP8266 - std::string time_fmt; - std::string date_fmt; Color text_color, alarm_color, gauge_color, gauge_bgcolor,rindicator_color,lindicator_color, clock_color, today_color, weekday_color, rainbow_color; EHMTX_Icon *icons[MAXICONS]; #endif @@ -102,25 +97,15 @@ namespace esphome bool display_gauge; bool is_running = false; bool show_date; - #ifdef EHMTXv2_USE_RTL - bool rtl; - #endif uint8_t gauge_value; uint16_t clock_time; uint16_t scroll_step; - uint8_t scroll_count; EHMTX_queue *queue[MAXQUEUE]; addressable_light::AddressableLightDisplay *display; time::RealTimeClock *clock; - int8_t default_yoffset, default_xoffset; - int8_t special_yoffset, special_xoffset; bool show_seconds; - uint16_t scroll_interval; // ms to between scrollsteps - uint16_t rainbow_interval; // ms to between scrollsteps - uint16_t frame_interval; // ms to next_frame() - uint16_t clock_interval; uint16_t hold_time; // seconds display of screen_time to extend uint8_t icon_count; // max iconnumber -1 @@ -147,31 +132,17 @@ namespace esphome void skip_screen(); void hold_screen(int t = 30); void set_display(addressable_light::AddressableLightDisplay *disp); - void set_clock_interval(uint16_t t = 90); void set_hold_time(uint16_t t = 30); void set_clock_time(uint16_t t = 10); void set_show_day_of_week(bool b=true); void set_show_seconds(bool b=false); void set_show_date(bool b=true); - #ifdef EHMTXv2_USE_RTL - void set_rtl(bool b=false); - #endif - void set_font_offset(int8_t x, int8_t y); - void set_week_start(bool b); void set_brightness(int b); - void set_default_font_offset(int8_t x, int8_t y); - void set_special_font_offset(int8_t x, int8_t y); void set_display_on(); void set_display_off(); void set_clock(time::RealTimeClock *clock); void set_default_font(display::Font *font); void set_special_font(display::Font *font); - void set_frame_interval(uint16_t interval); - void set_scroll_interval(uint16_t interval); - void set_rainbow_interval(uint16_t interval); - void set_scroll_count(uint8_t count); - void set_time_format(std::string s); - void set_date_format(std::string s); void show_rindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3); void show_lindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3); void set_clock_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 42cedea1..c6688b07 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -120,7 +120,7 @@ namespace esphome void EHMTX_queue::update_screen() { - if (millis() - this->config_->last_rainbow_time >= this->config_->rainbow_interval) + if (millis() - this->config_->last_rainbow_time >= EHMTXv2_RAINBOW_INTERVALL) { this->config_->hue_++; if (this->config_->hue_ == 360) @@ -143,8 +143,8 @@ namespace esphome void EHMTX_queue::draw() { display::Font *font = this->default_font ? this->config_->default_font : this->config_->special_font; - int8_t yoffset = this->default_font ? this->config_->default_xoffset : this->config_->special_xoffset; - int8_t xoffset = this->default_font ? this->config_->default_yoffset : this->config_->special_yoffset; + int8_t yoffset = this->default_font ? EHMTXv2_DEFAULT_FONT_OFFSET_Y : EHMTXv2_SPECIAL_FONT_OFFSET_Y; + int8_t xoffset = this->default_font ? EHMTXv2_DEFAULT_FONT_OFFSET_X : EHMTXv2_SPECIAL_FONT_OFFSET_X; int8_t extraoffset = 0; Color color_; if (this->config_->is_running) @@ -201,7 +201,7 @@ namespace esphome { 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_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER, EHMTXv2_TIME_FORMAT, this->config_->clock->now()); if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds) { @@ -223,7 +223,7 @@ namespace esphome { 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_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER,EHMTXv2_DATE_FORMAT , this->config_->clock->now()); if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds) { @@ -341,8 +341,8 @@ namespace esphome } else { - max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_; - display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000); + max_steps = (EHMTXv2_SCROLL_COUNT + 1) * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; + display_duration = ceil((max_steps * EHMTXv2_SCROLL_INTERVALL) / 1000); this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; } break; @@ -357,8 +357,8 @@ namespace esphome } else { - max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_; - display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000); + max_steps = (EHMTXv2_SCROLL_COUNT + 1) * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_; + display_duration = ceil((max_steps * EHMTXv2_SCROLL_INTERVALL) / 1000); this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; } break; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index c62012b3..6e583e5a 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -77,6 +77,7 @@ def rgb565_svg(x,y,r,g,b): CONF_FRAMEINTERVAL = "frame_interval" CONF_DEFAULT_FONT_ID = "default_font_id" CONF_DEFAULT_FONT = "default_font" +CONF_CLOCKFONT = "default_clock_font" CONF_DEFAULT_FONT_XOFFSET = "default_font_xoffset" CONF_DEFAULT_FONT_YOFFSET = "default_font_yoffset" CONF_SPECIAL_FONT_ID = "special_font_id" @@ -106,6 +107,9 @@ def rgb565_svg(x,y,r,g,b): ): cv.templatable(cv.positive_int), cv.Optional( CONF_HTML, default=False + ): cv.boolean, + cv.Optional( + CONF_CLOCKFONT, default=True ): cv.boolean, cv.Optional( CONF_RTL, default=False @@ -364,22 +368,28 @@ def thumbnails(frames): cg.add(var.set_special_font(f)) cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) - cg.add(var.set_scroll_interval(config[CONF_SCROLLINTERVAL])) - cg.add(var.set_rainbow_interval(config[CONF_SCROLLINTERVAL])) + + cg.add_define("EHMTXv2_SCROLL_INTERVALL",config[CONF_SCROLLINTERVAL]) + cg.add_define("EHMTXv2_RAINBOW_INTERVALL",config[CONF_RAINBOWINTERVAL]) + cg.add_define("EHMTXv2_FRAME_INTERVALL",config[CONF_FRAMEINTERVAL]) + cg.add_define("EHMTXv2_CLOCK_INTERVALL",config[CONF_CLOCKINTERVAL]) + cg.add_define("EHMTXv2_SCROLL_COUNT",config[CONF_SCROLLCOUNT]) + cg.add_define("EHMTXv2_WEEK_START",config[CONF_WEEK_START_MONDAY]) + cg.add_define("EHMTXv2_DEFAULT_FONT_OFFSET_X",config[CONF_DEFAULT_FONT_XOFFSET]) + cg.add_define("EHMTXv2_DEFAULT_FONT_OFFSET_Y",config[CONF_DEFAULT_FONT_YOFFSET]) + cg.add_define("EHMTXv2_SPECIAL_FONT_OFFSET_X",config[CONF_SPECIAL_FONT_XOFFSET]) + cg.add_define("EHMTXv2_SPECIAL_FONT_OFFSET_Y",config[CONF_SPECIAL_FONT_YOFFSET]) + cg.add_define("EHMTXv2_DEFAULT_CLOCK_FONT",config[CONF_CLOCKFONT]) + cg.add_define("EHMTXv2_DATE_FORMAT",config[CONF_DATE_FORMAT]) + cg.add_define("EHMTXv2_TIME_FORMAT",config[CONF_TIME_FORMAT]) + if config[CONF_RTL]: - cg.add(var.set_rtl(config[CONF_RTL])) cg.add_define("EHMTXv2_USE_RTL") - cg.add(var.set_scroll_count(config[CONF_SCROLLCOUNT])) - cg.add(var.set_frame_interval(config[CONF_FRAMEINTERVAL])) - cg.add(var.set_week_start(config[CONF_WEEK_START_MONDAY])) - cg.add(var.set_clock_interval(config[CONF_CLOCKINTERVAL])) - cg.add(var.set_time_format(config[CONF_TIME_FORMAT])) - cg.add(var.set_date_format(config[CONF_DATE_FORMAT])) + cg.add(var.set_show_day_of_week(config[CONF_SHOWDOW])) cg.add(var.set_show_date(config[CONF_SHOWDATE])) cg.add(var.set_show_seconds(config[CONF_SHOW_SECONDS])) - cg.add(var.set_default_font_offset(config[CONF_DEFAULT_FONT_XOFFSET], config[CONF_DEFAULT_FONT_YOFFSET] )) - cg.add(var.set_special_font_offset(config[CONF_SPECIAL_FONT_XOFFSET], config[CONF_SPECIAL_FONT_YOFFSET] )) + for conf in config.get(CONF_ON_NEXT_SCREEN, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await automation.build_automation(trigger, [(cg.std_string, "icon"), (cg.std_string, "text")], conf) diff --git a/copy2esphome/EHMTX_extended_state.yaml b/copy2esphome/EHMTX_extended_state.yaml index 8a1215f1..a47d7a3c 100644 --- a/copy2esphome/EHMTX_extended_state.yaml +++ b/copy2esphome/EHMTX_extended_state.yaml @@ -50,7 +50,7 @@ blueprint: default: 12 icon_name: name: The icon associated to this state screen? - description: If you use additional icons in your YAML, you have to add them to this blueprint. + description: If you use additional icons in your YAML, you have to add them to this blueprint. Valid only if icon is chosen. selector: select: mode: dropdown @@ -141,7 +141,7 @@ action: {{ def_color[2] }} else: - service: |- - esphome.{{ device_attr(display, "name") }}_rainbow_icon + esphome.{{ device_attr(display, "name") }}_rainbow_icon_screen data: icon_name: !input icon_name screen_time: !input screen_time @@ -170,7 +170,7 @@ action: {{ def_color[2] }} else: - service: |- - esphome.{{ device_attr(display, "name") }}_rainbow_text + esphome.{{ device_attr(display, "name") }}_rainbow_text_screen data: screen_time: !input screen_time lifetime: !input lifetime diff --git a/wiki/blueprint-extended-dialog.png b/wiki/blueprint-extended-dialog.png new file mode 100644 index 00000000..b515610a Binary files /dev/null and b/wiki/blueprint-extended-dialog.png differ diff --git a/wiki/blueprints.md b/wiki/blueprints.md new file mode 100644 index 00000000..aebcb21e --- /dev/null +++ b/wiki/blueprints.md @@ -0,0 +1,13 @@ +# introduction + +**Skill-level:** medium to advanced + +This component provides some blueprints. Because there are so many options and parameters it is sometimes hard to create manuall automations. + +## EHMTX_extended_state.yaml + +With this blueprint you can easily react on state changes of a sensor. + +![screenshot](https://github.com/lubeda/EspHoMaTriXv2/blob/develop/wiki/blueprint-extended-dialog.png?raw=true) + +## Bonus! They are free diff --git a/wiki/home.md b/wiki/home.md index d7b8e970..9b45131b 100644 --- a/wiki/home.md +++ b/wiki/home.md @@ -9,3 +9,5 @@ - [Ulanzi upside-down](rotate-ULANZI-display-180-degrees) - [Use all icons in your blueprint](use-icons-in-blueprints) +- [Time & Date Formats](time-format) +- [Blueprints for easier configuration](blueprints) diff --git a/wiki/time-format.md b/wiki/time-format.md new file mode 100644 index 00000000..92d228cd --- /dev/null +++ b/wiki/time-format.md @@ -0,0 +1,59 @@ +# introduction + +**Skill-level:** low + +In the ehmtxv2: section of your yaml, you can change the format that the date and time are displayed. + +There are some helpful hints on the [EspHome site](https://esphome.io/components/time/?highlight=strftime#strftime) but there are some undocumented ones, too. EspHome only uses a subset of [strftime](https://strftime.org/) but there are still some good tricks available. + +## Date formats + +Month.Day (02.28) + +```yaml + date_format: "%m.%d" +``` + +Day.Month (28.02) + +```yaml + date_format: "%d.%m" +``` + +Year.Month.Day (23.02.28) + +```yaml + date_format: "%y.%m.%d" +``` + +Abbreviated Month and Date (Feb 08) + +```yaml + date_format: "%b %d" +``` + +Abbreviated Day and Date (Tue 08) + +```yaml + date_format: "%a %d" +``` + +## Time formats + +24-hour time (23:15) + +```yaml + time_format: "%H:%M" +``` + +12-hour time with padded hour (01:25PM) + +```yaml + time_format: "%I:%M%p" +``` + +12-hour time with unpadded hour (1:25PM) + +```yaml + time_format: "%l:%M%p" +``` diff --git a/wiki/use-icons-in-blueprints.md b/wiki/use-icons-in-blueprints.md index 5e3dfc2a..6516fd6c 100644 --- a/wiki/use-icons-in-blueprints.md +++ b/wiki/use-icons-in-blueprints.md @@ -1,3 +1,7 @@ +P/1.1 200 OK" +2023-06-04 12:08:17.772 ERROR (MainThread) [homeassistant.components.automation] Failed to generate automation from blueprint: Invalid blueprint: Only one type can be specified. Found select, default for dictionary value @ data['blueprint']['input']['icon_name']['selector']. Got {'select': {'mode': 'dropdown', 'options': ['error', 'github', 'precipitation', 'nina', 'waschmaschine', 'lamp', 'headphone', 'print3d', 'internet', 'speaker', 'alien', 'temp', 'garage', 'door', 'wind', 'rain', 'phone', 'fire', 'tv', 'frost', 'muell', 'cookit', 'nature', 'work', 'bike', 'amazon', 'post', 'power', 'solar', 'yoga', 'startrek', 'energy', 'sun', 'diesel', 'benzine10', 'vacuum', 'rainprecip', 'iss', 'thunder', 'nina_warning', 'mic', 'birthday', 'firework', 'coffee', 'lightning', '... +2023-06-04 12:08:17.772 ERROR (MainThread) [homeassistant.components.automation] Failed to generate automation from blueprint: Failed to load blueprint: Unable to find lubeda/EHMTX_extended_state.yaml + # introduction **Skill-level:** advanced @@ -61,6 +65,38 @@ Take care that the indentation is correct Save the changed file and reload your automations +## step 4 + +After checking if it is working, repeat the procedure for all blueprints using the icon dropdown + +## sample for manual automation + +this automation example display states with icons and a rainbow colored text for state changes of multiple icons. +The icon is selected by the `trigger.id`, the text is dynamicaly build by the triggered state. + +```yaml +alias: EHMTX State display +trigger: + - platform: state + entity_id: sensor.001cac04_wind_speed + id: wind + - platform: state + entity_id: sensor.tankerkoenig_super + id: supere10 +condition: [] +action: + - service: esphome.ulanzi_rainbow_icon_screen + data: + icon_name: "{{trigger.id}}" + screen_time: 12 + lifetime: 2 + text: '{{trigger.to_state.attributes.friendly_name}}: {{trigger.to_state.state}} + {{trigger.to_state.attributes.unit_of_measurement}}|replace ("€","¼")| replace ("°C","¬")|replace ("℃","¬")| replace ("°F","¯")|replace ("℉","¯")|replace ("₴","¾")|replace ("₿","¨")|replace ("₩","½")|replace ("Ξ","¸")' + default_font: true +mode: parallel +max: 2 +``` + ## warnings - If you remove icons from your list, old automations will probably use these icons, resulting in displaying the default icon! diff --git a/wiki/weather-display.md b/wiki/weather-display.md index dd381190..90dc0e07 100644 --- a/wiki/weather-display.md +++ b/wiki/weather-display.md @@ -1,4 +1,4 @@ -# introduction +# Introduction **Skill-level:** medium @@ -11,13 +11,19 @@ Show weather state with icons that match the weather conditions. ehmtx: icons: - id: weather_clear_night - lameid: 52163 + lameid: 53383 - id: weather_cloudy frame_duration: 192 lameid: 25991 + - id: weather_exceptional + lameid: 16754 - id: weather_fog lameid: 52167 - - id: weather_lightingrainy + - id: weather_hail + lameid: 53288 + - id: weather_lightning + lameid: 23713 + - id: weather_lightning_rainy lameid: 49299 - id: weather_partlycloudy frame_duration: 210 @@ -32,10 +38,16 @@ ehmtx: lameid: 49301 - id: weather_sunny lameid: 11201 + - id: weather_windy + lameid: 15618 + - id: weather_windy_variant + lameid: 15618 + - id: weather_cloudy_night + lameid: 12195 ``` -## step 2: enter **home assistant automation:** +## Step 2: enter **home assistant automation:** ```yaml alias: EHMTXv2 Weather @@ -55,3 +67,47 @@ action: states("sensor.92bc04_wind_speed")}}km/h/{{ states("sensor.92bc04_humidity") }}% ``` + +## Alternate Step 2: **Home Assistant Automation: Temperature & Icon (with OpenWeatherMap integration)** + +```yaml + - if: + - condition: or + conditions: + - condition: state + entity_id: sensor.openweathermap_condition + state: cloudy + - condition: state + entity_id: sensor.openweathermap_condition + state: partlycloudy + - condition: or + conditions: + - condition: sun + after: sunset + - condition: sun + before: sunrise + then: + - service: esphome.pixelclock_icon_screen + data: + default_font: true + icon_name: cloudy_night + text: "{{ states('sensor.openweathermap_temperature')|round(1) }}°" + lifetime: 5 + screen_time: 3 + r: 192 + g: 192 + b: 192 + else: + - service: esphome.pixelclock_icon_screen + data: + default_font: true + icon_name: >- + weather_{{ states('sensor.openweathermap_condition')|replace("-", + "_") }} + text: "{{ states('sensor.openweathermap_temperature')|round(1) }}°" + lifetime: 5 + screen_time: 3 + r: 192 + g: 192 + b: 192 +```