Subtract time from IOS notification

Hi All

I finally got my Home detection working reliable but it takes around 6 min for the detection to be Registered
So I would like to correct the time difference in the notifications

action:
  - service: notify.ios_group_caspersen_home
    data:
      message: "Left at {{ states('sensor.time') }}"

I have searched the forum but I haven’t found anything working in the yaml file
So now it says:

Left at 08:05 --> Left at 07:59

As always your help and input is much appreciated!

it’s a PITA, the proper way to do the following:

action:
  - service: notify.ios_group_caspersen_home
    data_template:
      message: >
        {% set offset_minutes = 6 %}
        {% set t = (now().timestamp() - offset_minutes * 60) | timestamp_local %}
        Left at {{ strptime(t,'%Y-%m-%d %H:%M:%S').strftime('%H:%M') }}

This converts the current time into seconds, subtracts the offset (converted to seconds) and stores the value as a string time stamp. Then it converts the string timestamp into a datetime object and pulls out the hour and minute as a string.

There are other ways to do it, this way handles any time transition.

i forgot about timestamp_custom… this would also work:

action:
  - service: notify.ios_group_caspersen_home
    data_template:
      message: >
        {% set offset_minutes = 6 %}
        Left at {{ (now().timestamp() - offset_minutes * 60) | timestamp_custom('%H:%M') }}

Excellent worked perfectly!
Thanks allot

1 Like