From 0a0e934fcd04c1b0a6e5801dcadda2917566c04a Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 3 Mar 2023 08:19:18 +0000 Subject: [PATCH 01/17] Add option for wildcard's on icon name for del_screen function --- README.md | 6 +++++- components/ehmtx/EHMTX.cpp | 30 ++++++++++++++++++++++++++++-- components/ehmtx/EHMTX.h | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c255c74..9dbc6cc 100644 --- a/README.md +++ b/README.md @@ -524,8 +524,12 @@ Service **del_screen** Removes a screen from the display by icon name. If this screen is actually display while sending this command the screen will be displayed until its "show_screen"-time has ended. +Optionally you can suffix a * to the icon name to perform a wildcard delete which will delete all screens beginning with the icon_name specified. + +For example if you have multiple icons named weather_sunny, weather_rain & weather_cloudy, you can issue a del_screen weather_* to remove whichever screen is currently in a slot and replace it with a new weather screen. + parameters: -- ```icon_name``` The name of the icons as in the yaml (see installation) +- ```icon_name``` The name of the icon as in the yaml (see installation) Service **indicator_on** diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index 532d4d2..a054d4a 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -85,6 +85,15 @@ namespace esphome ESP_LOGD(TAG, "text color r: %d g: %d b: %d", r, g, b); } + bool EHMTX::string_has_ending(std::string const &fullString, std::string const &ending) + { + if (fullString.length() >= ending.length()) { + return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); + } else { + return false; + } + } + uint8_t EHMTX::find_icon(std::string name) { for (uint8_t i = 0; i < this->icon_count; i++) @@ -300,8 +309,25 @@ namespace esphome void EHMTX::del_screen(std::string iname) { - uint8_t icon = this->find_icon(iname.c_str()); - this->store->delete_screen(icon); + // if has ending of * + if (this->string_has_ending(iname, "*")) { + // remove the * + std::string comparename = iname.substr(0, iname.length()-1); + + // iterate through the icons, comparing start only + for (uint8_t i = 0; i < this->icon_count; i++) + {` + std::string iconname = this->icons[i]->name.c_str(); + if (iconname.rfind(comparename, 0) == 0) + { + this->store->delete_screen(i); + } + } + } + else { + uint8_t icon = this->find_icon(iname.c_str()); + this->store->delete_screen(icon); + } } void EHMTX::add_screen(std::string iconname, std::string text, uint16_t duration, bool alarm) diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 6b387e3..6769c71 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -61,6 +61,7 @@ namespace esphome display::Font *font; int8_t yoffset, xoffset; uint8_t find_icon(std::string name); + bool string_has_ending(std::string const &fullString, std::string const &ending); uint16_t duration; // in minutes how long is a screen valid uint16_t scroll_intervall; // ms to between scrollsteps uint16_t anim_intervall; // ms to next_frame() From 2381c30cf72aade148799a83b2615bc3d75debe2 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 3 Mar 2023 08:19:18 +0000 Subject: [PATCH 02/17] Add option for wildcard's on icon name for del_screen function --- components/ehmtx/EHMTX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index a054d4a..c6fd36d 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -316,7 +316,7 @@ namespace esphome // iterate through the icons, comparing start only for (uint8_t i = 0; i < this->icon_count; i++) - {` + { std::string iconname = this->icons[i]->name.c_str(); if (iconname.rfind(comparename, 0) == 0) { From 9d3a6ccb6e6dba2b10cb34638555e087d76fc404 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Fri, 3 Mar 2023 13:29:08 +0100 Subject: [PATCH 03/17] Update README.md extended thanks section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dbc6cc..f5f8475 100644 --- a/README.md +++ b/README.md @@ -725,7 +725,7 @@ The integration works with the homeassistant api so, after boot of the device, i THE SOFTWARE IS PROVIDED "AS IS", use at your own risk! # Thanks -- **[andrew-codechimp](https://github.com/andrew-codechimp)** for his contribution (display on/off) +- **[andrew-codechimp](https://github.com/andrew-codechimp)** for his contribution (display on/off & del_screen "*") - **[jd1](https://github.com/jd1)** for his contributions - **[aptonline](https://github.com/aptonline)** for his work on the ulanzi hardware - **[wsbtak](https://github.com/wsbtak)** for the work on the ulanzi hardware From efbe546b0f20ade13ec73ffe80f522bb1376e17f Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Fri, 3 Mar 2023 13:44:01 +0100 Subject: [PATCH 04/17] Update README.md sponsors --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f5f8475..f4cae10 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # EspHoMaTriX (ehmtx) A simple DIY status display, build with a flexible 8x32 RGB LED panel implemented with [esphome.io](https://esphome.io) - # Introduction There are some "RGB-matrix" status displays/clocks out there, the commercial one from Lametric and some very good d.i.y.-alternatives. @@ -730,3 +729,5 @@ 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 + +# Special thanks to all sponsor's From aecab014d3ca52d178b6b83c9c6bc23990532af5 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Fri, 3 Mar 2023 13:55:29 +0100 Subject: [PATCH 05/17] Update README.md templating --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f4cae10..e286149 100644 --- a/README.md +++ b/README.md @@ -586,6 +586,9 @@ This service displays the running queue and a list of icons in the logs [13:10:10][I][EHMTX:186]: status icon: 4 name: rain ``` +## display precision after home assistant 2023.3.0 +See [templating](https://www.home-assistant.io/docs/configuration/templating/#states) for possibilities to optimize the output e.g. {{ states(sensor.solarpower, rounded=True) }} kWh + ### use in automations from homeassistant The easiest way to use ehmtx as a status display is to use the icon names as trigger id. In my example i have an icon named "wind" when the sensor.wind_speed has a new state this automation sends the new data to the screen with the icon named "wind" and so on. From 896a5186a613087ad2a6c8a03260306d87756ecd Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Fri, 3 Mar 2023 13:57:29 +0100 Subject: [PATCH 06/17] Update README.md awtrix discontinued --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e286149..0c4a383 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ There are some "RGB-matrix" status displays/clocks out there, the commercial one - [LaMetric](https://lametric.com/en-US/) commercial ~ 199€ - [Ulanzi TC001](https://de.aliexpress.com/item/1005005008682055.html) commercial ~ 50€ -- [Awtrix](https://awtrixdocs.blueforcer.de/#/) -- [PixelIt](https://docs.bastelbunker.de/pixelit/) +- [Awtrix](https://awtrixdocs.blueforcer.de/#/) (project has been discontinued after more than 4 years now in August 2022) +- [PixelIt](https://docs.bastelbunker.de/pixelit/) (project is under active development) The other d.i.y. solutions have their pros and cons. I tried both and used AwTrix for a long time. But the cons are so big (after my opinion) that i started an esphome.io variant. Targeted to an optimized homeassistant integration. The main reason, for me is the homeassistant integration! From 23fadcca7f8d2ffab00bbc050fc94512e6eb9ae3 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 10:57:58 +0100 Subject: [PATCH 07/17] Update EHMTX.h More Icons --- components/ehmtx/EHMTX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 6769c71..6cb75f1 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -3,7 +3,7 @@ #include "esphome.h" const uint8_t MAXQUEUE = 24; -const uint8_t MAXICONS = 64; +const uint8_t MAXICONS = 75; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); From 40436c062dc6c792d7ed508b4c47d838b5a22df8 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 10:59:36 +0100 Subject: [PATCH 08/17] Update EHMTX.h icons --- components/ehmtx/EHMTX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 6cb75f1..14702f2 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -3,7 +3,7 @@ #include "esphome.h" const uint8_t MAXQUEUE = 24; -const uint8_t MAXICONS = 75; +const uint8_t MAXICONS = 80; const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); From 2a0d062a1abfbfd88a2c5d6e97e9758d768be634 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 11:00:45 +0100 Subject: [PATCH 09/17] Update __init__.py --- components/ehmtx/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ehmtx/__init__.py b/components/ehmtx/__init__.py index e2fe388..d93fe2a 100755 --- a/components/ehmtx/__init__.py +++ b/components/ehmtx/__init__.py @@ -19,7 +19,7 @@ AUTO_LOAD = ["ehmtx"] IMAGE_TYPE_RGB565 = 4 MAXFRAMES = 20 -MAXICONS = 72 +MAXICONS = 80 ICONWIDTH = 8 ICONHEIGHT = 8 ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT From e1d5594cbbc6376181b5269c71c4573825063e79 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 11:01:51 +0100 Subject: [PATCH 10/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c4a383..9312a2d 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ font: ## icons/animations Download and install all needed icons (.jpg/.png)/animations (.gif) under the "ehmtx"-key. All icons are automagically scaled to 8x8 on compile-time. But this doesn't work well for gif's! You can also specify an url to directly download an image file. The urls will only be downloaded once at compile time, so there is no additional traffic on the hosting website. - +There are maximun 80 icons possible. ``` emhtx: icons: From 588f0ed3646726903b541d830587dc33db0b5599 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 13:50:46 +0100 Subject: [PATCH 11/17] added sample for del_screen --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 9312a2d..4ca7e92 100644 --- a/README.md +++ b/README.md @@ -617,6 +617,41 @@ mode: queued max: 10 ``` +### specific icons per e.g. weather condition + +Add an icon per weathercondition to the ehmtx component + +``` + - id: weather_clear_night + lameid: 52163 + - id: weather_cloudy + lameid: 25991 + - id: weather_fog + lameid: 52167 + ...... +``` + +Sample automation to show the weather with local temperature + +``` +alias: EHMTX weather +description: weather with icon per condition +trigger: + - platform: state + entity_id: weather.metno +action: + - service: esphome.ulanzi_del_screen + data: + icon_name: weather_* + - service: esphome.ulanzi_screen + data: + icon_name: weather_{{ trigger.to_state.state }} + text: >- + {{ states("sensor.external_actual_temperature") }}°C +``` + +Prerequisites: This works since 2023.3.1 thanx to @andrew-codechimp fpr the new del_screen + ### integrate in home assistant ui you can add some entities to home assistant to your ui for interactive control of your display From 09804eb82569a0e499dc0bb4d82992c468a56553 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 13:51:28 +0100 Subject: [PATCH 12/17] display precision --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4ca7e92..00d7f1a 100644 --- a/README.md +++ b/README.md @@ -617,6 +617,12 @@ mode: queued max: 10 ``` +### display precision after home assistant 2023.3.0 + +See [templating](https://www.home-assistant.io/docs/configuration/templating/#states) for possibilities to optimize the output +e.g. +```{{ states(sensor.solarpower, rounded=True) }} kWh``` + ### specific icons per e.g. weather condition Add an icon per weathercondition to the ehmtx component From b683fd853fc04a121ed7abc6e9c5ad88203d3863 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 15:26:58 +0100 Subject: [PATCH 13/17] sample for del_screen --- muellautomation.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 muellautomation.yaml diff --git a/muellautomation.yaml b/muellautomation.yaml new file mode 100644 index 0000000..c8fb9b6 --- /dev/null +++ b/muellautomation.yaml @@ -0,0 +1,33 @@ +alias: "EHMTX Müllanzeige" +description: Anzeige welche Tonne raus muss. iconnamen gekürzt +trigger: + - platform: time + at: + - "06:30" + - "08:30" + - "10:30" + - "15:00" + - "17:00" + - "19:00" +condition: + - condition: numeric_state + entity_id: sensor.mulltrigger + below: "3" +action: + - service: esphome.awtrix_del_screen + data: + icon_name: trash_* + - service: esphome.ulanzi_del_screen + data: + icon_name: trash_* + - data: + icon_name: >- + trash_{{ states("sensor.mulldetails") | replace("Biotonne", "brow")| + replace("Papiertonne","blue")| replace("Restmüll", "grey")| + replace("gelbe Tonne","yell|") | truncate(4,true,"") }} + text: >- + {{ states("sensor.mulldetails")|replace(" in","")|replace(" days"," + Tagen") | replace ("0 Tagen","heute") | replace ("1 Tagen","morgen")}} + duration: 120 + service: script.ehmtx_to_all +mode: single \ No newline at end of file From 89045218b9d4fcc5fd54e8c8ce84b14ba154dd33 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sat, 4 Mar 2023 15:29:06 +0100 Subject: [PATCH 14/17] sample for del_screen --- README.md | 34 ++++++++++++++++++++++++++++++++++ muellautomation.yaml | 33 --------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) delete mode 100644 muellautomation.yaml diff --git a/README.md b/README.md index 00d7f1a..2f099a4 100644 --- a/README.md +++ b/README.md @@ -655,6 +655,40 @@ action: text: >- {{ states("sensor.external_actual_temperature") }}°C ``` +or another sample automation for the trashcan type + +``` +alias: "EHMTX Müllanzeige" +description: Anzeige welche Tonne raus muss. iconnamen gekürzt +trigger: + - platform: time + at: + - "06:30" + - "08:30" + - "10:30" + - "15:00" + - "17:00" + - "19:00" +condition: + - condition: numeric_state + entity_id: sensor.mulltrigger + below: "3" +action: + - service: esphome.ulanzi_del_screen + data: + icon_name: trash_* + - data: + icon_name: >- + trash_{{ states("sensor.mulldetails") | replace("Biotonne", "brow")| + replace("Papiertonne","blue")| replace("Restmüll", "grey")| + replace("gelbe Tonne","yell|") | truncate(4,true,"") }} + text: >- + {{ states("sensor.mulldetails")|replace(" in","")|replace(" days"," + Tagen") | replace ("0 Tagen","heute") | replace ("1 Tagen","morgen")}} + duration: 120 + service: esphome.ulanzi_screen +mode: single +``` Prerequisites: This works since 2023.3.1 thanx to @andrew-codechimp fpr the new del_screen diff --git a/muellautomation.yaml b/muellautomation.yaml deleted file mode 100644 index c8fb9b6..0000000 --- a/muellautomation.yaml +++ /dev/null @@ -1,33 +0,0 @@ -alias: "EHMTX Müllanzeige" -description: Anzeige welche Tonne raus muss. iconnamen gekürzt -trigger: - - platform: time - at: - - "06:30" - - "08:30" - - "10:30" - - "15:00" - - "17:00" - - "19:00" -condition: - - condition: numeric_state - entity_id: sensor.mulltrigger - below: "3" -action: - - service: esphome.awtrix_del_screen - data: - icon_name: trash_* - - service: esphome.ulanzi_del_screen - data: - icon_name: trash_* - - data: - icon_name: >- - trash_{{ states("sensor.mulldetails") | replace("Biotonne", "brow")| - replace("Papiertonne","blue")| replace("Restmüll", "grey")| - replace("gelbe Tonne","yell|") | truncate(4,true,"") }} - text: >- - {{ states("sensor.mulldetails")|replace(" in","")|replace(" days"," - Tagen") | replace ("0 Tagen","heute") | replace ("1 Tagen","morgen")}} - duration: 120 - service: script.ehmtx_to_all -mode: single \ No newline at end of file From 5fb72546549442459100e9d2fe631912737a56bd Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 5 Mar 2023 11:19:33 +0100 Subject: [PATCH 15/17] Issue fixed: skip_screen function #47 --- components/ehmtx/EHMTX.cpp | 5 +++++ components/ehmtx/EHMTX.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/ehmtx/EHMTX.cpp b/components/ehmtx/EHMTX.cpp index c6fd36d..42e709f 100755 --- a/components/ehmtx/EHMTX.cpp +++ b/components/ehmtx/EHMTX.cpp @@ -252,6 +252,11 @@ namespace esphome this->duration = t; } + void EHMTX::skip_screen() + { + this->store->move_next(); + } + void EHMTX::get_status() { time_t ts = this->clock->now().timestamp; diff --git a/components/ehmtx/EHMTX.h b/components/ehmtx/EHMTX.h index 14702f2..66a8d8e 100755 --- a/components/ehmtx/EHMTX.h +++ b/components/ehmtx/EHMTX.h @@ -8,7 +8,7 @@ const uint8_t TEXTSCROLLSTART = 8; const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t TICKINTERVAL = 1000; // each 1000ms -static const char *const EHMTX_VERSION = "Version: 2023.3.0"; +static const char *const EHMTX_VERSION = "Version: 2023.3.1"; static const char *const TAG = "EHMTX"; namespace esphome From 070e0be1f4c219fdff5edb9b44f8b3e5cb5a3822 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 5 Mar 2023 11:21:42 +0100 Subject: [PATCH 16/17] doc --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f099a4..bd6e5b4 100644 --- a/README.md +++ b/README.md @@ -567,7 +567,20 @@ switch: Service **skip** -skips to the next screen +if there are more than on screens in the queue this skips to the next screen. + +e.g. on the Ulanzi TC001 + +``` +binary_sensor: + - platform: gpio + pin: + number: $left_button_pin + inverted: true + on_press: + lambda: + id(rgb8x32)->skip_screen(); +``` Service **status** From 7f0c3203ca211dc12fba00571ad816b1f110a9b4 Mon Sep 17 00:00:00 2001 From: LuBeDa Date: Sun, 5 Mar 2023 11:57:41 +0100 Subject: [PATCH 17/17] added changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bcae090 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +## 2023.3.1 + +added: del_screen with wildcards +changed: maximum icons to 80 +fixed: skip_next + +## 2023.3.0 + +see README.md for features \ No newline at end of file