Track repetitive tasks with NFC tags

Hey @rfep2016 , I’m getting the same negative days_since_last_completed value because the helper stores the due date instead of the last completed date. Could you fix it?

BTW, @nwithan8 , thanks for the blueprint, it’s awesome

Ok, I was able to fix it with a simple change. There was a bug when the date tracker was being updated. The correct code is the following:

sequence:
          - alias: Update date tracker to next due date
            entity_id: input_datetime.date_the_plant_was_watered
            data:
              datetime: |
                {% if rolling_completion %}
                  {% set last_date = states(date_tracker) | as_datetime %}
                  {{ last_date.date() + timedelta(days=task_interval) }}
                {% else %}
                  {{ now().date() }}
                {% endif %}
            action: input_datetime.set_datetime

Note that when rolling_completition is false, we need to set date as today date.

1 Like

Thanks for the debugging help, all. Seems I confused myself and was sometimes storing the past last completed date in the date helper, while other times storing the next future due date. I believe I’ve cleaned up the logic and am storing/calculating things correctly now. Blueprint is updated above and via the import link.

1 Like

Since this update the automation broke. Getting the following error:

 Error rendering variables: UndefinedError: 'str object' has no attribute 'date' 

Also, with the change I did earlier, I had the next date set in the helper and this gave me an easy overview of upcoming tasks. I reverted the update for now.

Welp.

Thanks for letting me know, I’ll take a look ASAP

1 Like

Hey, I haven’t been able to recreate this issue on my end. I updated the blueprint with some guard clauses, but they really shouldn’t be necessary. I might recommend deleting and recreating the datetime helper you’re using for this automation, as it might contain an invalid date in it, that’s all I can think.

Ah, that might be the case: my helpers contain a date in the future whilst you now need an date in the past?

Weird occurence:

Logger: homeassistant.components.automation.clean_robot
Source: components/automation/__init__.py:701
integration: Automation (documentation, issues)
First occurred: 6:46:31 PM (22 occurrences)
Last logged: 7:00:08 PM
Error rendering variables: TypeError: unsupported operand type(s) for -: 'str' and 'datetime.date'

Here is my helper, I tried date and Date&Time

Alright, I think I got it now. I did almost a full rewrite of the logic. Turns out the issue was string vs datetime vs date variable types, that are hard to debug when the “Templates” tool in Home Assistant simply shows the string representation of any variable.

The automation has been updated accordingly.

1 Like

Seems to be working perfectly, thank you for your amazing work.

1 Like

Hi there! I like what you’ve done and am trying to implement it myself however I can’t seem to get the variables to show. It would just show up as empty, could you help provide some of your thoughts? Thanks!

due_action:
      - device_id: 1972676d2f55d1b57147a50487e6da5c
        domain: mobile_app
        type: notify
        message: Clean the kitchen vents! {{ task_due }}
      - action: notify.mobile_app_will_s_phone
        metadata: {}
        data:
          title: Reminders
          message: "{{ task_name }} Clean Exhausts {{ task_due_date }}"