Mail and Packages: Custom component for UPS, FEDEX, and USPS

Looks like the refresh did it, I found it, and it’s installing, thanks!

So weird, I rebooted the thing 5 times, and all I needed to do was a refresh xD

1 Like

So this has been working great for me until now. Not sure when it happened but all my entities are unavailable now. i went through the setup again 4 times now. That usually fixes it but not this time. Here’s the log.

## Log Details (ERROR)

Logger: homeassistant.components.sensor
Source: custom_components/mail_and_packages/sensor.py:878
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 3:02:49 PM (3 occurrences)
Last logged: 3:15:19 PM

Error while setting up mail_and_packages platform for sensor

Traceback (most recent call last): 
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform 
  await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) 
File "/usr/local/lib/python3.8/asyncio/tasks.py", line 483, in wait_for 
  return fut.result() 
File "/config/custom_components/mail_and_packages/sensor.py", line 71, in async_setup_entry 
  sensors.append(PackagesSensor(data, variable)) 
File "/config/custom_components/mail_and_packages/sensor.py", line 198, in __init__ 
  self.update() 
File "/config/custom_components/mail_and_packages/sensor.py", line 254, in update 
  self.data.update() 
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper 
  result = method(*args, **kwargs) 
File "/config/custom_components/mail_and_packages/sensor.py", line 139, in update 
  count[sensor] = get_items(account, ATTR_COUNT) 
File "/config/custom_components/mail_and_packages/sensor.py", line 878, in get_items 
  if len(found[0]) > 0 and found[0] not in orderNum: 
TypeError: 'NoneType' object is not subscriptable

What version of the component are you running?

Looks like 0.2.2-b15

Give b16 a run should fix you right up.

That didn’t seem to fix it. Log looks the same as well :slightly_frowning_face:

Forgot to mention I tried going through the setup again as well.

Don’t forget to restart Home Assistant after you update.

Did that too lol

I’ll try again

While fixing that Amazon sensor there was another fix, it’s now in b17.

Just switched from standard branch. B17 not working:

 File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
    return fut.result()
  File "/config/custom_components/mail_and_packages/sensor.py", line 71, in async_setup_entry
    sensors.append(PackagesSensor(data, variable))
  File "/config/custom_components/mail_and_packages/sensor.py", line 198, in __init__
    self.update()
  File "/config/custom_components/mail_and_packages/sensor.py", line 254, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 152, in update
    info = get_count(account, sensor, True)
  File "/config/custom_components/mail_and_packages/sensor.py", line 654, in get_count
    if len(tracking) < len(count):
TypeError: object of type 'int' has no len()

B18 is already out to fix that

1 Like

Ya b18 fixed that, don’t code without copious amounts of caffeine in your system. :stuck_out_tongue:

1 Like

Just updated to b18 and seeing this in my log:


2020-08-08 19:36:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140235629336368] Unable to serialize to JSON. Bad data found at $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages).attributes.order[0]=<re.Match object; span=(23, 43), match='#XXXXXXXXXX'>(<class 're.Match'>, $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages).attributes.order[1]=<re.Match object; span=(23, 43), match='#XXXXXXXXX'>(<class 're.Match'>

Causing HASS to crash loading unless I unload the Amazon sensor.

Thanks. B18 hangs my homeassistant, it won’t fully restart . Homeassistant starts fine on release version.

2020-08-08 19:28:35 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2940602496] Unable to serialize to JSON. Bad data found at $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages_delivered).attributes.order[0]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>, $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages_delivered).attributes.order[1]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>
2020-08-08 19:28:35 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2940602496] Unable to serialize to JSON. Bad data found at $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages).attributes.order[0]=<re.Match object; span=(22, 42), match='#1XXX'>(<class 're.Match'>, $.event(event: state_changed).data.new_state(state: sensor.mail_amazon_packages).attributes.order[1]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>

I restarted, now this error just repeats

2020-08-08 19:45:41 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2971110104] Unable to serialize to JSON. Bad data found at $.result[77](state: sensor.mail_amazon_packages_delivered).attributes.order[0]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>, $.result[77](state: sensor.mail_amazon_packages_delivered).attributes.order[1]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>, $.result[91](state: sensor.mail_amazon_packages).attributes.order[0]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>, $.result[91](state: sensor.mail_amazon_packages).attributes.order[1]=<re.Match object; span=(22, 42), match='#XXX'>(<class 're.Match'>

I’m testing a fix now hold on.

EDIT: b19 up, you may have to overwrite the files manual in your custom_component directory if your frontend isn’t loading.

Thanks… B19 Working now…

1 Like

Keep in mind it only effects the frontend, it doesn’t full stop Home Assistant, just killed the web UI :frowning:

I managed to reboot and have HASS working for long enough to downgrade to b15 and then reboot, then update to b19.

1 Like

Also, just an FYI for those looking for another way to get the Amazon emails into your “tracked” folder for the integration, my Amazon emails get sent to Protonmail. I’m sure I could configure the Proton Bridge and get it working that way on my server but that’s too much effort. Instead, I have the bridge running on my desktop and use Thunderbird. I set up a few Thunderbird filters/rules to copy the Amazon emails to the correct Gmail folder so the integration can see it. Works like a charm. Won’t work all the time as I shut down my desktop at night but it’s good enough.

1 Like

So I just updated to the b20 version. It still doesn’t work, and now I have a different log:

## Log Details (ERROR)

Logger: homeassistant.components.sensor
Source: custom_components/mail_and_packages/sensor.py:884
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 10:34:31 AM (2 occurrences)
Last logged: 10:42:34 AM

Error while setting up mail_and_packages platform for sensor

Traceback (most recent call last): 
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform 
  await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) 
File "/usr/local/lib/python3.8/asyncio/tasks.py", line 483, in wait_for 
  return fut.result() File "/config/custom_components/mail_and_packages/sensor.py", line 71, in async_setup_entry 
  sensors.append(PackagesSensor(data, variable)) 
File "/config/custom_components/mail_and_packages/sensor.py", line 198, in __init__ 
  self.update() 
File "/config/custom_components/mail_and_packages/sensor.py", line 254, in update 
  self.data.update() 
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper 
  result = method(*args, **kwargs) 
File "/config/custom_components/mail_and_packages/sensor.py", line 139, in update 
  count[sensor] = get_items(account, ATTR_COUNT) 
File "/config/custom_components/mail_and_packages/sensor.py", line 884, in get_items 
  if len(found[0]) > 0 and found[0] not in orderNum: 
IndexError: list index out of range