Message malformed: extra keys not allowed @ data['0']

Hello,

I try to create an automatization to receive on telegram the exact name of last event of the litter box but I receive the same error continuously: Message malformed: extra keys not allowed @ data[‘0’]

Any ideas?

- alias: Testing
  trigger:
    - platform: state
      entity_id: sensor.petkit_pura_max_last_event
  action:
    - service: telegram_bot.send_message
      data: 
          message: "{{ trigger.name }}"
          title: Activity
  mode: single

Thx!

trigger.name doesn’t exist. Try trigger.to_state.name I think.

More likely your formatting (indentation) is wrong in data. Should be

- alias: Testing
  trigger:
    - platform: state
      entity_id: sensor.petkit_pura_max_last_event
  action:
    - service: telegram_bot.send_message
      data: 
        message: "{{ trigger.name }}"
        title: Activity
  mode: single

Thank you
@jeffcrum to_state is a step forward
@msp1974 also the indentation was a problem, I did not noticed the extra space used.

Now I receive messages but still I am not receiving the name of last state:
image

I am receiving the friendly_name, instead the triggerd state like manual_odor_completed and I think I can not obtain that.

Thx!

trigger.to_state.state

I tried that already, some errors from logs:

You are probably better off asking at the integration’s thread where the developer can help.
PetKit Custom Integration - Share your Projects! / Custom Integrations - Home Assistant Community (home-assistant.io)

1 Like

Given you are using a state change trigger, you could just use.

message: "{{ states('sensor.petkit_pura_max_last_event') }}"
2 Likes

Thank you @msp1974, now I receive the notification each time when new event is triggered.

Thank you all for help!

Have a good day!