How to set ESPHome on_time using HA?

I need to be able to set the hours and minutes in and ESPHome on-time automation from HA.

When I try this…


  - platform: homeassistant
    name: "Heating on time 1 hours"
    entity_id: sensor.heating_on_time_1_hours
    id: heating_on_time_hours

  - platform: homeassistant
    name: "Heating on time 1 minutes"
    entity_id: sensor.heating_on_time_1_minutes
    id: heating_on_time_minutes

  - platform: homeassistant
    id: homeassistant_time
    # timezone: Europe//London
      - minutes: !lambda 'return id(heating_on_time_1_minutes).state;'
        hours: !lambda 'return id(heating_on_time_1_hours).state;'
          - switch.turn_on: boiler

…I get a validation error:

    - [source /config/esphome/heating_controller.yaml:171]
      This option is not templatable!.
      minutes: !lambda |-
        return id(heating_on_time_1_minutes).state; [source /config/esphome/heating_controller.yaml:171]

Is there a way to do this?

I’d like to keep the automation solely on the ESPHome device rather than control it from HA.

Additionally, I still can’t get my ESPHome time to be the same as HA. It’s one hour behind.

Any ideas?

For time sync uncomment your timezone line and delete the extra / ie




Thank you, Nick. I’d commented it out as, even without the additional ‘/’, it doesn’t fix the issue of time being off by one hour.

Time is correct in HA but one hour behind in all ESPHome devices.

I think it has something to do with the move to summer time but can’t figure how to correct it.

Like I said in another thread, I reboot my esp every 24 hours and it survived daylight saving switch - dunno if it is because I reboot it or because it just works.

Yes, what’s odd is how ESPHome is supposed to pick up the time from HA and HA auto corrected it’s time when the clocks changed.

What I don’t know, because at the time it wasn’t important, is if my ESPHomes were getting the correct time before the summer time change.

I’m going to play around with my HA time and see what ESPHome picks up.

Incidentally, or maybe coincidentally, with the timezone setting in ESPHome, I get API disconnects. Without it, all is fine.

I have this in my config:

- platform: time_date
    - 'time'
    - 'date'
    - 'date_time'
    - 'time_date'
    - 'time_utc'

It seems that ESPHome is using time equivalent to UTC time rather than the time HA is using.

Removing UCT from the configure, however, makes no difference. Still one hour out.

Changing my HA timezone to Europe/Paris (which is one hour ahead, makes no difference, ESPHomes are still using UTC time.

Any ideas where I may be going wrong with this?

When showing an ESPHome device log the time shows as UTC also.
Is the log supposed to be showing the event time from HA or the time from the device? Where does the ESPHome server pick up it’s time?

Every computer uses UTC at heart, what you see at the commandline is influenced by what you define as your timezone. I assume esphome isn’t different.