IMAP Sensor

I with help from some great people here created a sensor. it uses IMAP integration to plot position on map card using GPS coordinates received via email.

template:
  - trigger:
      - platform: event
        event_type: "imap_content"
        id: "GPSposition"
        event_data:
          subject: pos
    sensor:
      - name: boatgps
        state: "{{ trigger.event.data['date'] }}"
        icon: mdi:home-circle-outline
        attributes:
          latitude: "{{(trigger.event.data['text']|from_json)['latitude'] }}"
          longitude: "{{(trigger.event.data['text']|from_json)['longitude'] }}"

it works really great until i wanted to add Speed & destination as attributes too. I´m not an expert in yaml so i asked claude.ai , but what ever i do sensor goes totally unavailable. Can some body shed some light how to add another two or more attributes to above code please?

currently receiving email message is just a text message like below.

{"latitude": 8.08, "longitude": 74.31, "speed": 12.0 knots, "destination": dubai}

If there is no destination or speed in the email, how would you expect to get the data? Speed is something an integration might be able to accomplish if the gps position updates are frequent enough (but I highly doubt it will get a meaningful value), but the destination requires more information than you get.

Sorry i forgot to mention. I can add speed and destination to the message.

{"latitude": 8.08, "longitude": 74.31, "speed" 12.0 knots, "destination"}

Well, then the idea is similar to lattitude and longitude. But you’ll have to fix the syntax errors in the email. The one you edited in in your first post looks a lot better than the one below. But still, 12.0 knots is neither a number nor a string. So either just 12.0 or “12.0 knots” should work, but if you can I’d go for the first one, as that is really a number and not a text.Also the destination dubai needs quotes.

Oh the quotes. that’s what went wrong. Thank you very much sir.

1 Like