I’ve done a decent amount of searching and haven’t found quite what I’m looking for, so hoping for some help here. What I’m trying to do is set up a script where, when run, it adds an hour to the existing value of a datetime helper - so, if the current value is 6pm, when run it changes that to 7pm. However, as written, the value is set to an hour from now, not an hour from the current value. I’m quite certain I’ve got something wrong in the code, so I’m hoping someone can point out what that is.
I’m trying to adjust the time of an input_datetime entity via a Mushroom card. I’m attempting to subtract 15 minutes from the current time set on the entity, but I’m running into an error.
Invalid time specified: {{ (as_timestamp(states('input_datetime.bedroom_blind_tilt')) - 900) | timestamp_custom('%H:%M:%S', false) }} for dictionary value @ data['time']
Entity attributes:
has_date: false
has_time: true
editable: true
hour: 7
minute: 0
second: 0
timestamp: 25200
friendly_name: Bedroom Blind Tilt
The entity input_datetime.bedroom_blind_tilt is set to store only time.
I am trying to understand why this error occurs despite the format appearing correct and the calculations seemingly accurate. Does anyone have insights on how to properly format the time adjustment, or is there a better method to accomplish this within a Mushroom card?
Pasting exactly the same into template card service caller still responds with Invalid time specified, so my assumption is there service caller is not able to parse templates, which is a bummer, but at least I can get it to work with the script
Are the two single quotes after tilt intentional here?
I think I know what your problem is: You’re setting this from a card, meaning it’s the frontend doing the parsing. While that field supports Jinja templates, it’s only evaluated on the server.
This would confirm the above: scripts are evaluated server-side.