Automation and Script Debugging?

@petro I’ve noticed another little problem with the automation.

Whenever I press any of the Opple switch buttons, the following error appears in the logs:

2021-12-02 14:50:33 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: homeassistant.helpers.template.Wrapper object has no element -2 when rendering '{{ items[-2] }}'

Could this be happening when the action playload is empty?

yep, change the event variable to

      event: >
        {{ trigger.payload_json.action or 'button_0_invalid' }}

That fixed it - thank you again!

Thanks for editing your post with the fix - could you add the right arrow ‘>’ next to the button variable too please?

Github issue for the ‘show trace’ link bug for reference.

1 Like

And if going back to see another original problem in the message, only storing 5 traces, you can store as many traces as you would like now. Here is the Docs on the subject: