Error in describing trigger: Cannot read properties of undefined (reading 'includes')

I’ve been using HA merrily for multiple years, it’s a great piece of software, when it works. When it doesn’t, and I hope you don’t mind me saying so but, the error reporting leaves something to be desired.
I have an issue which has just jumped up and bit me unexpectedly. I no longer get a notify action (is a script) called in an automation. Instead I get this error:

Error in describing trigger: Cannot read properties of undefined (reading ‘includes’)

This is an automation which has been working fine for the last year or more, and nothing has been explictly changed that I’m aware of. I do keep the HA system up-to-date most of the time, this is the only thing I can think of which may have changed recently. The trace seems to have failed here:

data:
  message: >-
    Alert triggered by {{ state_attr(trigger.entity_id,
    'friendly_name') }}
  title: Alert for {{ state_attr(trigger.entity_id, 'friendly_name') }}
action: script.notify_via_ha_in_app

The error is mysterious to me, there is no script name, nor line number, to refer to, nada. Just this “there was an error reading something” - what?!
The automation was created in the UI and the YAML looks like this:

alias: Alert on motion occupancy if away
description: ""
triggers:
  - type: occupied
    device_id: gcc53asdfce7da8adbf29373f3c1fsdf
    entity_id: e70c214asd5608c84ff2318b0a421243
    domain: binary_sensor
    enabled: true
    trigger: device
conditions:
  - condition: state
    entity_id: alarm_control_panel.ha_alarm
    state: armed_away
actions:
  - data:
      message: Inner occupancy alert triggered by entrance or lounge motion sensors
      title: Inner occupancy for entrance or lounge motion sensors
    action: script.notify_via_ha_in_app

If anyone has any helpful suggestions for debugging/demystifying this, I’d be very pleased to hear about them.
Many thanks in advance for any assistance.
R. (an HA fan)

Suggestion: avoid using device triggers. It basically makes debugging impossible.

From de error message, could it be that the device_id / entity_id pair is not valid anymore?

1 Like

I removed the old entries, and created new entries using the UI (so as not to make any mistake). The device and entity IDs are the same.

If you’re suggesting that I should use the UI to create the automation, and then manually remove the device id/s, I could try that, but it seems daft to not believe the HA UI itself :wink:

The UI is more than capable of creating entity_id state based automations.

2 Likes

Thanks Chris, and Sir Goodenough too,

Having read the docs. I see that although the Device is at the top of the suggestions for the UI->Add_Trigger automation process, then the next item on the list is Entity. Choosing the latter appears to be less intuitive but perhaps actually makes more sense. Eg; is safer as it’s more predictable.

Thanks for your (prompt) feedback folks, am off to experiment. :wave:

R.