#Automation with IMAP and Google Sheets

1 messages · Page 1 of 1 (latest)

worn swan
#

Hi everyone, I've been trying to transfer email content from my IMAP integration (triggered by the imap_content event) to a Google Sheet for some time now and I'm stuck.

YAML code used:

```ymal
alias: mails transfer
description: 'Transfer IMAP emails to Google Sheet'
trigger:

  • platform: event
    event_type: imap_content
    action:
  • service: google_sheets.append_sheet
    data:
    config_entry: XXXXXX # My specific integration ID
    worksheet: Sheet1 # The exact name of my worksheet (verified multiple times)
    data:
    -
    - "{{ trigger.event.data.text }}"
    mode: single ```

I consistently receive error messages like:

Message malformed: extra keys not allowed @ data['actions'][0]['description']
Message malformed: value should be a string for dictionary value @ data['actions'][0]['action']
extra keys not allowed @ data['alias']

These errors indicate that the entire automation structure (alias, description, trigger, action, mode) is mistakenly ending up within the data parameter of the google_sheets.append_sheet service call, even though the code in the automation's YAML editor (based on my understanding and the examples shared here) appears to be correct. However, I only get the word created data transferred into my sheet.

I have tried:

  • Completely deleting and re-creating the automation.
  • Restarting Home Assistant.
  • Preparing the YAML code in a plain text editor to avoid invisible characters.
  • Various indentation attempts for the data parameter of the Google Sheets action.
  • Also used the UI editor and only populated the data field via YAML.

Thanks in advance for any help!

elfin bobcat
#

Where's the key for your data?

alias: mails transfer
description: 'Transfer IMAP emails to Google Sheet'
trigger:
  - platform: event
    event_type: imap_content
action:
  - service: google_sheets.append_sheet
    data:
      config_entry: XXXXXX # My specific integration ID
      worksheet: Sheet1 # The exact name of my worksheet (verified multiple times)
      data:
        - Text: "{{ trigger.event.data.text }}"
mode: single 
worn swan
#

The key for my data is the email text, which I'm writing directly as a string into the first cell of the row. It's a list of lists containing the Jinja2 template {{ trigger.event.data.text }}, structured as follows:

data:
  -
    - "{{ trigger.event.data.text }}"```

It's not a key-value structure within the data parameter, but rather a direct list of lists.