lubeda / EspHoMaTriXv2

A simple DIY status display with a 8x32 RGB LED matrix, implemented with esphome.io and Home Assistant.
MIT License
276 stars 25 forks source link

[BUG] The on_empty_queue event did not work #93

Closed andrewjswan closed 11 months ago

andrewjswan commented 11 months ago

Bug report

Describe the bug

Yesterday started preparatory work to modify the source code to create Pull Request, flashed for the correct config 2023.9, specified as in the documentation:

  on_empty_queue:
    then:
      lambda: |-
        id(rgb8x32)->clock_screen(10,10);
        id(rgb8x32)->date_screen(10,5);

  on_start_running:
     then:
       lambda: |-
          id(rgb8x32)->clock_screen(10,10);
          id(rgb8x32)->date_screen(10,5);

Also from HA, the weather is constantly displayed on the screen. I.e. constant 3 screens, clock, date, weather (updated often because it is tied not only to the weather, but also to the temperature). But this morning, there was only weather on the screen, no clock or date. It seems that the on_empty_queue event did not happen.

Additional information

lubeda commented 11 months ago

This night a had a similar effect :-(

omia commented 11 months ago

The on_empty_queue event should not happen. The queue was not empty. There was a screen in the queue.

andrewjswan commented 11 months ago

That's understandable, what's not so clear is where the date and time disappeared to.

omia commented 11 months ago

They don't disappear. They are created with 10minutes of live.

On my clock the date and time disappear after around 10 minutes but they reappear randomly.

omia commented 11 months ago

I see two possible ways for this.

  1. A second queue for permanent screens which don't have a live time.
  2. Permanent screens should only be created within the clock(pulling data)

A would favor number 1.

andrewjswan commented 11 months ago

Well, we basically have no screens that are permanent, since we already have at least two types of watches. Here it is necessary either to constantly extend the life of the screen,

    this->endtime = this->clock->now().timestamp + 300;

or to set the minimum starting set, which is immortal.

omia commented 11 months ago

What is the differenz between a permanent screen and a immortal one?

andrewjswan commented 11 months ago

Basically nothing, but we need to understand where the temporary screen is and where it is not, and when temporary can become permanent or vice versa.

andrewjswan commented 11 months ago

We could try replacing the on_empty_queue event with on_expired_screen, then as soon as the clock becomes obsolete it can be returned :)

omia commented 11 months ago

How do we know which screen expired?

andrewjswan commented 11 months ago

How do we know which screen expired?

Judging by the source code, the information about the screen is transmitted there, but we can not analyze it, just increase the life of the necessary screens, even by an hour, even by a day.

lubeda commented 11 months ago

Hi, on_expired_screen is the wrong approach! Since you decide with the lifetime-parameter how long a screen is alive.

My first implementation had a mandatory clock-screen, but some people wanted a normaly black-screen and only sometimes data to be displayed.

If you always wan't a clock in your queue you can' add e.g.:

  on_empty_queue:
    then:
      - lambda: |-
          id(rgb8x32).icon_clock("emptycal|day#1",1440,10,false); 

If you wan't a black screen you leave it empty.

omia commented 11 months ago

But if we have a weather screen running all the time even a life of a day will run out and the on_empty_screen should never be called. What a about a on_screen_death event. So we can put a function as a parameter. This would even be a possibility to make it more generic. So a timer for example would make a sound on screen death.

lubeda commented 11 months ago

Besides the clock I don't understand the concept of permanent screens. For me, e.g. the wind speed is pushed with a lifetime of two minutes to the display by an automation that triggers on every state change. So the wind speed is "permanent" on the screen but totally controlled by home assistant. If you need something like a "motto of the day" set the lifetime to 24*60 minutes triggers by an automation on home assistant at 12p.m..

andrewjswan commented 11 months ago

I have:

  on_empty_queue:
    then:
      lambda: |-
        id(rgb8x32)->clock_screen(1440,10);
        id(rgb8x32)->date_screen(1440,5);

And weather and temperature from HA, trigger state changes, lifetime 30 min

And a day, two days later, all I have is the weather on my screen. No clock or time

andrewjswan commented 11 months ago

triggers by an automation on home assistant at 12p.m

I'd like to avoid that, it's an internal mechanism, I think HA is unnecessary.

omia commented 11 months ago

The problem can also happen without any "permanent" screens. Ad some point in time the clock screen dies. An if then any screen is in the queue the clock is gone. And only if all screens are removed we get a trigger to renew the clock. So if we have homeassistant add 4 10min screens for fun things in the meantime we don't have the time on the clock. Sometimes it can be bad timing but it's a clock it should tell the time.

andrewjswan commented 11 months ago

Judging by the discussion it's not a bug, but that's how the queue works. I think we should close this Issue, and open a new one about permanent screens.