Run vacuum if not used in the last 2 days

Hi all,

I would like to create an automation to run my robot vacuum if it did not run in the last 2 days
I’m new to yaml coding so it’s sometime a big learning curve

I’m getting an error when trying to save my code.

alias: 'Vacuum: Check if vacuum has run in the last 2 days'
description: ''
mode: single
trigger:
  - platform: template
    value_template: '{{ state_attr(''sensor.vacuum_last_clean_end'') | float == { (now() - as_datetime('1970-01-01 00:00:00-00:00')).days % 2 == 0 } }}
    event: start
condition: []
action:
  - service: script.1658143599996
    data: {}
  - service: script.vacuum_send_actionable_notification_to_run
    data: {}

What I’m trying to do is compare the last vacumm date is equal to 48 hours to trigger an actionable notification to run the vacuum.

Thanks in advance

ultimeus,

It looks like you don’t have an EVENT that called “start”

Indeed event was wrong.

I checked indentation and code validity it’s fine.
But still I got an error was trying to save the automation

Code:


alias: New Automation
description: ''
mode: single
trigger:
  - platform: template
    value_template: >-
      '{{ state_attr(sensor.vacuum_last_clean_end) | float == { (now() -
      as_datetime('1970-01-01 00:00:00-00:00')).days % 2 == 0 } }}'
condition: []
action:
  - service: script.1658143599996
    data: {}
  - service: script.vacuum_send_actionable_notification_to_run
    data: {}

Error:
Message malformed: invalid template (TemplateSyntaxError: expected token ‘:’, got ‘}’) for dictionary value @ data[‘value_template’]