Sensor Automation - Template Problem

I have added an automation to notify me when a recycling collection is expected the following day, but I am getting an error which I don’t understand.

This is my automation:

- alias: Grey Recycling Notification
  id: grey_recycling_notification
  mode: single
  trigger:
    - platform: template
      value_template: "{{ '1' in state_attr('sensor.grey' ,'days') }}"
  condition: time
  at: '16:00:00'
  action:
  - service: notify.mobile_app_martins_iphone
    data:
      message: "Recycling Reminder!  GREY bin"

This is the error in logs when I check configuration:

  • Invalid config for [automation]: Expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘value_template’]. Got None. (See /config/configuration.yaml, line 9).
  • Invalid config for [automation]: Expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘at’]. Got None. (See /config/configuration.yaml, line 9).

Can anyone please advise on where my automation has gone wrong?

- alias: Grey Recycling Notification
  id: grey_recycling_notification
  mode: single
  trigger:
    - platform: template
      value_template: "{{ '1' in state_attr('sensor.grey' ,'days') }}"
  condition:
    - condition: time
      at: '16:00:00'
  action:
    - service: notify.mobile_app_martins_iphone
      data:
        message: "Recycling Reminder!  GREY bin"

Thanks Tom. However, that now results in the below:

  • Invalid config for [automation]: Expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘value_template’]. Got None. (See /config/configuration.yaml, line 9).

The Time Condition is invalid. It doesn’t support an at option.

I suggest you do this instead:

- alias: Grey Recycling Notification
  id: grey_recycling_notification
  mode: single
  trigger:
    - platform: time
      at: '16:00:00'
  condition:
    - condition: template
      value_template: "{{ '1' in state_attr('sensor.grey' ,'days') }}"
  action:
    - service: notify.mobile_app_martins_iphone
      data:
        message: "Recycling Reminder!  GREY bin"

It triggers at 16:00 and if days contains 1 it sends a notification.

1 Like

Great spot, thank you for that. It works :smiley:

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions.

For more information, refer to guideline 21 in the FAQ.

I’m resurrecting this thread because I have encountered an issue.

I have slightly altered the template in this automation since the above post but, my issue is not with that…I don’t think.

I have tested the automation by running it via Settings and the notification reaches my phone, as expected so I’m guessing the action part of the automation is correct.

However, the automation doesn’t run automatically so I’m assuming the issue is with the trigger or condition. There are no errors logged when it fails to run automatically.

Can anyone please advise where the below may be going wrong?

  id: blue_recycling_notification
  mode: single
  trigger:
  - platform: time
    at: '15:30:00'
  condition:
  - condition: state
    entity_id: sensor.blue
    state: "Tomorrow"
  action:
  - service: notify.mobile_app_martins_iphone
    data:
      message: Recycling Reminder!  BLUE bin
      data:
        image: /local/blue_bin.png

Check the automation’s trace.

I don’t see any syntax errors in your example. It triggers at 15:30, if the state value of sensor.blue is “Tomorrow” it sends your phone a notification. I doubt there’s a problem with the Time Trigger so I would focus your attention on the result produced by the State Condition.

1 Like

Thanks for that info…I didn’t even know that trace existed.

On checking it, it shows:
Stopped because a condition failed at July 13, 2022 at 3:51:00 PM (runtime: 0.01 seconds)

As there was only one condition it was easy to check and I found I just needed to change the initial letter in “Tomorrow” to lower case. I’ve just tested it and it works now.

Thanks again.

1 Like