Timer on ESPHome

Hi All,

I’m trying to build a thermostat. I have something in mind. I have a LCD display 2004But first I have 4 tasks to implement:
1 display temperature (a zigbee sensor connected to HA) DONE
2 display the state of the relay who is controlling the heating system DONE
3 display a timer set up in HA
4 adjust climate component (increase or decrease temperature) using 2 buttons (pins from ESP board).

I’m stuck on point 3 who should be easy:

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    lambda: |-
      it.printf(0, 0, "Stare centrala: %3s", id(switchcentrala).state ? "ON" : "OFF");
      it.printf(0, 1, "TempDormitor: %2.0f gr", id(temperaturadormitor).state);
      **it.printf(0, 2, "Ramas %s", id(timercentrala).state.c_str());**
      it.printf(0, 3, "Consum %2.0f W %2.0f dbi", id(consuminstant).state, id(wifisensor).state);
sensor:
  - platform: homeassistant
    id: timercentrala
    name: timercentrala
    entity_id: timer.incalzire

So…what can I do to display on ** line the timer? I tried many variants on the internet but it is not working. I found a version with some if…but it is ytoo complicated for my understanding :frowning:

Any help will me much appreciated. The last task (4) I will let it for later :slight_smile:

Thanks

How does the timer sensor value appear in the ESPHome logs?

The Timer docs suggests the state of a timer is not numeric. So maybe you need to import it as say a text sensor?

Thank you for replay.

21:26:09	[D]	[homeassistant.text_sensor:017]	

'timer.incalzire': Got state 'active'

21:26:09	[D]	[text_sensor:064]	

'timercentrala': Sending state 'active'

As text sensor it send: Active or idle, so no numbers…

As previous setup, I get: Sending state nan with 1 decimals of accuracy

And is that the information you want to display for the timer?

Are you ok with printing the text sensor from there? I can dig out an example if you get stuck…

Thank you. Actually I want to print the remaining time so, if I have a timer set up at 7 minutes, I want to see:
6:59, 6:58…0:01 and then 0:00.
Now, I can print “idle” or “active”.

Thanks for your support.

Is that countdown information actually available for the Home Assistant Timer? From memory it isn’t?

So you might need to dig around on the forum and solve that problem first in HA and then import that solution into ESPHOME?

Yes, it seems that you are right.

    timer_incalzire_remaining:
      value_template: "{{ state_attr('timer.incalzire', 'remaining') }}"
      friendly_name: 'Timer Incalzire Remaining'  

I tried to create a sensor but it is displaying the total time, not remainig.
Screenshot 2023-10-23 155442

It seems that this is not an easy task…but you are right. begore going to ESPHome, I need to solve problem in HA.
You helped me a lot. now, I know that I didn’t searched in the right way the solution.
Thank you!

1 Like

I remember looking at timer countdowns before and thought it was a bit involved for what I thought was going to be straight forward.

Google Homes for example display timers very well out of the box.

I bought a standard thermostat with wifi. Maybe is better.
Thanks for support.