Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #50 from lubeda/2023.3.1
Browse files Browse the repository at this point in the history
2023.3.1
  • Loading branch information
lubeda authored Mar 5, 2023
2 parents 6ff5507 + b3e57ce commit 3dd740a
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 12 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
105 changes: 98 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# 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.

- [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!

Expand Down Expand Up @@ -85,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:
Expand Down Expand Up @@ -524,8 +523,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**

Expand Down Expand Up @@ -564,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**

Expand All @@ -583,6 +599,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.
Expand Down Expand Up @@ -617,6 +636,76 @@ See [templating](https://www.home-assistant.io/docs/configuration/templating/#st
e.g.
```{{ states(sensor.solarpower, rounded=True) }} kWh```

### 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
```
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


### integrate in home assistant ui

you can add some entities to home assistant to your ui for interactive control of your display
Expand Down Expand Up @@ -727,8 +816,10 @@ 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
- **[ofirsnb](https://github.com/ofirsnb)** for his contributions

# Special thanks to all sponsor's
35 changes: 33 additions & 2 deletions components/ehmtx/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -243,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;
Expand Down Expand Up @@ -300,8 +314,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)
Expand Down
5 changes: 3 additions & 2 deletions components/ehmtx/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include "esphome.h"

const uint8_t MAXQUEUE = 24;
const uint8_t MAXICONS = 64;
const uint8_t MAXICONS = 80;
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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion components/ehmtx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
AUTO_LOAD = ["ehmtx"]
IMAGE_TYPE_RGB565 = 4
MAXFRAMES = 20
MAXICONS = 72
MAXICONS = 80
ICONWIDTH = 8
ICONHEIGHT = 8
ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT
Expand Down

0 comments on commit 3dd740a

Please sign in to comment.