Log errors from template syntax in automation

My log files are blowing up with errors like this:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1378
First occurred: 11:35:38 PM (85 occurrences)
Last logged: 11:35:42 PM

Template variable error: ‘dict object’ has no attribute ‘payload_json’ when rendering ‘{{ trigger.payload_json.Button3 == { “Action”: “SINGLE” } }}’
Template variable error: ‘dict object’ has no attribute ‘payload_json’ when rendering ‘{{ trigger.payload_json.Button3 == { “Action”: “DOUBLE” } }}’
Template variable error: ‘dict object’ has no attribute ‘payload_json’ when rendering ‘{{ trigger.payload_json.Button3 == { “Action”: “TRIPLE” } }}’
Template variable error: ‘dict object’ has no attribute ‘payload_json’ when rendering ‘{{ trigger.payload_json.Button3 == { “Action”: “HOLD” } }}’
Template variable error: ‘dict object’ has no attribute ‘event’ when rendering ‘{{ trigger.event.data.args.press_type == “hold” }}’

I believe they are driven from my automations where I have condition templates like below. But I am not sure why I am getting the error. I thought I was following the automation template guide properly.

  - conditions:
      - condition: template
        value_template: '{{ trigger.payload_json.Button2 == { "Action": "DOUBLE" } }}'
    sequence:
      - data:
          brightness: 127.5
          color_temp: 425
        entity_id: light.office_lamp
        service: light.turn_on
  - conditions:
      - condition: template
        value_template: '{{ trigger.payload_json.Button2 == { "Action": "TRIPLE" } }}'
    sequence:
      - data:
          brightness: 255
          color_temp: 150
        entity_id: light.office_lamp
        service: light.turn_on

It’s near impossible to tell without more complete examples. My guesses are:

  1. You have multiple triggers on the automation(s) and for some of them the payload doesn’t exist.
  2. There is some trick I saw recently somewhere on the forum that one should use if your JSON payload is “very large” (I think bigger than 256 but maybe it was 64). Try searching the forum for that.