Bug? Setting input_datetime with timestamp adds an hour

Possible bug with input_datetime helpers? It seems if you set them with a timestamp rather than a formatted time, it adds 3600 to the total set in the service.

Replicate with the following:

service: input_datetime.set_datetime
data:
  timestamp: 60
target: 
  entity_id: input_datetime.test

Check the value of the entity in Developer Tools (sorry I am on mobile right now):


If you call the service by setting a formatted time, it sets correctly.

service: input_datetime.set_datetime
data:
  time: “00:01:00”
target: 
  entity_id: input_datetime.test

Check in Developer Tools:


Now I can set the time to the value I actually wanted.

Is this a bug or am I overlooking something obvious? Happy to report it on GitHub but I wasn’t sure which repo to be raising the issue in. I’m fully up to date on HAOS, Core V2024.5.1.

Timestamps are in UTC. You’re presumably in BST (+01:00) or equivalent.

Might not seem logical for a time-only helper, but that’s how it works. You’re setting the date/time to 00:01 on 1-Jan-1970, which is 01:01 BST, then discarding the date bit.

Thanks Troon. I am in BST, I had considered it was related to this but I lost track of where I am with time zones and daylight savings. I guess there is no way around this if you want to use the timestamp attribute, you just have to convert to a proper time format (00:01:00)?

Perhaps there’s a way to use now().replace but instead of replacing the hour or minute, replace the timezone correction (+01:00 bit)?

I am actually trying to work with just UTC for this anyway because I’m trying to fix the offset for my electricity meter which runs on UTC but drifts around the correct time.

Actually, it shouldn’t even be that complicated, I’m not using a template in the service call in this example. This still seems like weird behaviour. I’m explicitly saying I want to set the timestamp attribute to 60 but it is adding my time zone to that? What is it doing in the background to add my timezone to that value? It seems really weird to me.

I thought I’d answered that:

or am I missing something?

I understand what you’re saying about 00:01 being 1:01 in BST but it seems weird that if I’m saying “please set this value to 60” that HA is then going “okay, I’ll set that value to 3660”. It feels like what I’m requesting is pretty explicit. I don’t feel that HA should be doing any extra calculation if I’m already providing a value that I’m telling it I want to use.

In any case, it seems my best way around this is to use a timestamp_custom filter to convert to HH:MM format and set that instead. It just seems messy given I already have a specific timestamp value I want to use, but no one else is complaint so I’ll live with it. Thanks for your help with this.