core: Automation trigger time offset not working

The problem

When using offset the automation does not run

What version of Home Assistant Core has the issue?

core-2021.11.0b2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

automation

Link to integration documentation on our website

No response

Example YAML snippet

alias: '[Home Task] Roborock'
trigger:
  - platform: time
    at: input_datetime.vacuum_time
    id: start_time
  - platform: time
    at:
      entity_id: input_datetime.vacuum_time
      offset: '-00:01:00'
    id: notificare

Anything in the logs that might be useful for us?

No response

Additional information

"start_time" is executed on time but "notificare" is never executed.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

OK, let’s discuss here since https://github.com/home-assistant/core/pull/58947 will be locked soon, or even better in a new PR, @RobertMe.

@hmmbob I agree. A time trigger fires every day the same time, I don’t really see how it’s confusing to let it fire with an offset.

For the DST quirks, a time trigger will:

  • Fire twice when leaving DST if configured to fire during the ambiguous local time, for example 02:30 in Europe
  • Not fire at all when entering DST if configured to fire during the skipped hour, for example 02:30 in Europe

This means a time trigger based on a time input configured for 01:55 with an offset of 10 minutes would:

  • Fire twice, at 02:05 when leaving DST
  • Not fire at all when entering DST

I think this is acceptable if documented.

Yes, that’s how I whould expect this to work as a user. And, if you have an input_datetime with only a date, I would expect it to trigger “offset” before/after 00:00:00 of that date, would you too?

So: an input_datetime set to only date 01-JAN-2022 with an offset of 15 minutes I’d expect to trigger at 01-JAN-2022 00:15:00 for a positive offset, and at 31-DEC-2021 23:45 for a negative offset.

FWIW: I think this would be a valuable addition to HA, and I feel no-one is debating that. It’s just about how we feel this should work - happy to add my thoughts on that here.

@RobertMe bringing discussion from here to this thread:

The issues identified in #58815 need to be fixed

I presume the fix would be for reusing the same entity id?

As described in my original PR I don’t think it makes sense to apply an offset to just a time. When you have a input_datetime set to 00:05:00 (so time only) it does IMO feel strange to apply for example an offset of -00:10:00 and make it execute at 23:55. (Or the other way around, input_datetime set to 23:55 and applying a positive 00:10:00 offset I wouldn’t expect 00:05:00).

That is actually exactly how I’d expect this to work.

If I have an input_datetime and ask for a -00:10 offset, I’d expect it to give me 10 mins before whatever the input_datetime is set to - regardless if this input_datetime has only a time, only a date (!), or a combination.

It should just do what I’m setting in yaml: trigger exactly 10mins before whatever the input is set to.

The reason it doesn’t work is indeed that the input_datetime.vacuum_time has only a time but no date.

input_datetime.vacuum_time: 17:09:00

has_date: false has_time: true editable: true hour: 17 minute: 9 second: 0 timestamp: 61740 friendly_name: Vacuum time icon: mdi:clock-time-four