ljmerza / ha-email-sensor

Email Sensor for collecting tracking numbers from over 40 providers.
MIT License
90 stars 24 forks source link

Setup Issues #49

Open Selim042 opened 1 year ago

Selim042 commented 1 year ago

Version of the custom_component

3.6.0

Configuration

sensor:
  - platform: email
    email: !secret google_email
    password: !secret google_email_password

Describe the bug

After configuring the integration and restarting it doesn't create the entities and has this error in the logs. I tried setting this up in December and kept running into issues, and it went on the back burner for a while.

Debug log

023-01-27 11:19:26.775 ERROR (MainThread) [homeassistant.components.sensor] email: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 503, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 729, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/email/sensor.py", line 320, in update
self._attr[ATTR_TRACKING_NUMBERS][ATTR] = list(map(lambda x: find_carrier(x, EMAIL_DOMAIN), tracking_numbers))
File "/config/custom_components/email/sensor.py", line 320, in <lambda>
self._attr[ATTR_TRACKING_NUMBERS][ATTR] = list(map(lambda x: find_carrier(x, EMAIL_DOMAIN), tracking_numbers))
File "/config/custom_components/email/sensor.py", line 159, in find_carrier
'tracking_number': tracking_number['tracking_number'],
KeyError: 'tracking_number'
ljmerza commented 1 year ago

should be fixed now

Selim042 commented 1 year ago

I updated to 3.7.0, same issue.

Selim042 commented 1 year ago

Same issue also on 3.8.0.

Selim042 commented 1 year ago

@ljmerza Any updates on this?

ljmerza commented 1 year ago

ill need more info like what tracking sites are being parsed

Selim042 commented 1 year ago

What is the best way to determine what is being parsed that is causing issues? I don't really delete emails, so there are lots of options.

ljmerza commented 1 year ago

updated to 3.9.0 to add more debug logging for you to track this down

Selim042 commented 1 year ago

Sorry about the delay, looks like Georgia Power? There is lots more data from before this in the log as well, just put a few lines from before the error. I didn't see any other errors from you. Is there a way to pinpoint exactly what email did it from them? They did recently change their formatting some.

2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] []
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] parsing tracking numbers for luzernsolutions
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] []
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] parsing tracking numbers for google.com
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] []
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] parsing tracking numbers for wdc.com
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] []
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] parsing tracking numbers for monoprice.com
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] []
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] parsing tracking numbers for southernco.com
2023-06-13 14:31:34.221 DEBUG (SyncWorker_4) [custom_components.email.sensor] find_carrier email_domain: southernco.com
2023-06-13 14:31:34.222 ERROR (MainThread) [homeassistant.components.sensor] email: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 537, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/email/sensor.py", line 332, in update
self._attr[ATTR_TRACKING_NUMBERS][ATTR] = list(map(lambda x: find_carrier(x, EMAIL_DOMAIN), tracking_numbers))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/email/sensor.py", line 332, in <lambda>
self._attr[ATTR_TRACKING_NUMBERS][ATTR] = list(map(lambda x: find_carrier(x, EMAIL_DOMAIN), tracking_numbers))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/email/sensor.py", line 168, in find_carrier
'tracking_number': tracking_number['tracking_number'],
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'tracking_number'

Semi-related question. As I don't really delete emails, will old emails with formatting that no longer matches cause issues? Or does it only parse recent emails?

ljmerza commented 1 year ago

should be fixed in 3.10.0

Selim042 commented 1 year ago

Not sure if it is related, but Southern Power is now getting this in the attributes. But an entity is published, so that's a huge improvement.

georgia_power:
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''
  - tracking_number: ''
    carrier: southernco.com
    origin: southernco.com
    link: ''