question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[homeassistant] Error doing job: Task was destroyed but it is pending!

See original GitHub issue

The problem

For something like a year I have seen this in the log every single time I start Home Assistant.

[homeassistant] Error doing job: Task was destroyed but it is pending!

I cannot trace what causes it. Last year people reported it as related to automations but I tried to remove all automations that run at start and it did not make a difference.

I have enabled debugging in the HA log and pasted the entire log below

What is version of Home Assistant Core has the issue?

2021.5.2

What was the last working version of Home Assistant Core?

At least a year ago

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Harmony

Link to integration documentation on our website

https://www.home-assistant.io/integrations/harmony/

Example YAML snippet

N/A

Anything in the logs that might be useful for us?

021-05-11 23:05:17 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(None):8009] Resolved service ServiceInfo(type='mdns', data='Google-Home-Mini-ad732ef4ef84f7a56c4399774142397e._googlecast._tcp.local.') to 192.168.1.76:8009
2021-05-11 23:05:17 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(192.168.1.76):8009] Connecting to 192.168.1.76:8009
2021-05-11 23:05:17 DEBUG (MainThread) [homeassistant.helpers.translation] Cache miss for en-GB: sensor.deconz, sensor.amcrest, sensor.mobile_app, switch.deconz, binary_sensor.amcrest, light.deconz, binary_sensor.deconz, camera.amcrest, device_tracker.mobile_app
2021-05-11 23:05:17 DEBUG (MainThread) [aioesphomeapi.connection] 192.168.1.93: Got message of type <class 'api_pb2.ConnectResponse'>: 
2021-05-11 23:05:17 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473529230624] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "media_player.ultracast_bedroom", "old_state": {"entity_id": "media_player.ultracast_bedroom", "state": "unavailable", "attributes": {"friendly_name": "Ultracast Bedroom", "supported_features": 152449}, "last_changed": "2021-05-11T21:05:17.454290+00:00", "last_updated": "2021-05-11T21:05:17.454290+00:00", "context": {"id": "b2e95a68c3274fff9e402b24439fec60", "parent_id": null, "user_id": null}}, "new_state": {"entity_id": "media_player.ultracast_bedroom", "state": "off", "attributes": {"friendly_name": "Ultracast Bedroom", "supported_features": 152461}, "last_changed": "2021-05-11T21:05:17.980836+00:00", "last_updated": "2021-05-11T21:05:17.980836+00:00", "context": {"id": "5d8f151df0712d26ca31308606307e83", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.980836+00:00", "context": {"id": "5d8f151df0712d26ca31308606307e83", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:17 DEBUG (Thread-17) [pychromecast.socket_client] [(None):8009] connection listener: ffff9a046ca0 (CastStatusListener) ConnectionStatus(status='CONNECTING', address=NetworkAddress(address=None, port=8009))
2021-05-11 23:05:17 DEBUG (Thread-17) [homeassistant.components.cast.media_player] [media_player.bedroom_display Bedroom Display] Received cast device connection status: CONNECTING
2021-05-11 23:05:17 DEBUG (Thread-17) [pychromecast.dial] get_info_from_service resolved service ServiceInfo(type='mdns', data='Google-Nest-Hub-1951c793118fe9b7c821907a48a42ed1._googlecast._tcp.local.') to service_info ServiceInfo(type='_googlecast._tcp.local.', name='Google-Nest-Hub-1951c793118fe9b7c821907a48a42ed1._googlecast._tcp.local.', addresses=[b'\xc0\xa8\x01G'], port=8009, weight=0, priority=0, server='1951c793-118f-e9b7-c821-907a48a42ed1.local.', properties={b'id': b'1951c793118fe9b7c821907a48a42ed1', b'cd': b'87BE3FA9506216A9626E2C5A8B66F886', b'rm': b'5D0AFBCA4344906C', b've': b'05', b'md': b'Google Nest Hub', b'ic': b'/setup/icon.png', b'fn': b'Bedroom Display', b'ca': b'233477', b'st': b'0', b'bs': b'FA8FCA609DBA', b'nf': b'1', b'rs': b''})
2021-05-11 23:05:17 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(None):8009] Resolved service ServiceInfo(type='mdns', data='Google-Nest-Hub-1951c793118fe9b7c821907a48a42ed1._googlecast._tcp.local.') to 192.168.1.71:8009
2021-05-11 23:05:17 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(192.168.1.71):8009] Connecting to 192.168.1.71:8009
2021-05-11 23:05:17 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473384830864] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "media_player.ultracast_bedroom", "old_state": {"entity_id": "media_player.ultracast_bedroom", "state": "unavailable", "attributes": {"friendly_name": "Ultracast Bedroom", "supported_features": 152449}, "last_changed": "2021-05-11T21:05:17.454290+00:00", "last_updated": "2021-05-11T21:05:17.454290+00:00", "context": {"id": "b2e95a68c3274fff9e402b24439fec60", "parent_id": null, "user_id": null}}, "new_state": {"entity_id": "media_player.ultracast_bedroom", "state": "off", "attributes": {"friendly_name": "Ultracast Bedroom", "supported_features": 152461}, "last_changed": "2021-05-11T21:05:17.980836+00:00", "last_updated": "2021-05-11T21:05:17.980836+00:00", "context": {"id": "5d8f151df0712d26ca31308606307e83", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.980836+00:00", "context": {"id": "5d8f151df0712d26ca31308606307e83", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:18 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473529230624] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.living_room_camera_ptz_preset", "old_state": null, "new_state": {"entity_id": "sensor.living_room_camera_ptz_preset", "state": "4", "attributes": {"friendly_name": "Living room camera PTZ Preset", "icon": "mdi:camera-iris"}, "last_changed": "2021-05-11T21:05:17.986699+00:00", "last_updated": "2021-05-11T21:05:17.986699+00:00", "context": {"id": "b92419c1db45017dfa7003670cebf94d", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.986699+00:00", "context": {"id": "b92419c1db45017dfa7003670cebf94d", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:18 DEBUG (SyncWorker_1) [homeassistant.components.amcrest.sensor] Updating Kitchen camera PTZ Preset sensor
2021-05-11 23:05:18 DEBUG (SyncWorker_1) [amcrest.http] <Amcrest2:AMC00104161DE28N5K> HTTP query 5: http://192.168.1.78:80/cgi-bin/ptz.cgi?action=getPresets&channel=0
2021-05-11 23:05:18 DEBUG (SyncWorker_1) [amcrest.http] <Amcrest2:AMC00104161DE28N5K> Running query 5 attempt 1
2021-05-11 23:05:18 DEBUG (SyncWorker_13) [homeassistant.components.amcrest.binary_sensor] Updating Kitchen camera Motion Detected binary sensor
2021-05-11 23:05:18 DEBUG (SyncWorker_13) [amcrest.http] <Amcrest2:AMC00104161DE28N5K> HTTP query 6: http://192.168.1.78:80/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion
2021-05-11 23:05:18 DEBUG (SyncWorker_13) [amcrest.http] <Amcrest2:AMC00104161DE28N5K> Running query 6 attempt 1
2021-05-11 23:05:18 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473529230624] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "binary_sensor.living_room_camera_online", "old_state": null, "new_state": {"entity_id": "binary_sensor.living_room_camera_online", "state": "on", "attributes": {"friendly_name": "Living room camera Online", "device_class": "connectivity"}, "last_changed": "2021-05-11T21:05:17.987521+00:00", "last_updated": "2021-05-11T21:05:17.987521+00:00", "context": {"id": "07c21e71b81a025b48198c95a9b0710e", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.987521+00:00", "context": {"id": "07c21e71b81a025b48198c95a9b0710e", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:18 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473384830864] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.living_room_camera_ptz_preset", "old_state": null, "new_state": {"entity_id": "sensor.living_room_camera_ptz_preset", "state": "4", "attributes": {"friendly_name": "Living room camera PTZ Preset", "icon": "mdi:camera-iris"}, "last_changed": "2021-05-11T21:05:17.986699+00:00", "last_updated": "2021-05-11T21:05:17.986699+00:00", "context": {"id": "b92419c1db45017dfa7003670cebf94d", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.986699+00:00", "context": {"id": "b92419c1db45017dfa7003670cebf94d", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(192.168.1.71):8009] connection listener: ffff9a046ca0 (CastStatusListener) ConnectionStatus(status='CONNECTED', address=NetworkAddress(address='192.168.1.71', port=8009))
2021-05-11 23:05:18 DEBUG (Thread-17) [homeassistant.components.cast.media_player] [media_player.bedroom_display Bedroom Display] Received cast device connection status: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-17) [homeassistant.components.cast.media_player] [media_player.bedroom_display Bedroom Display] Cast device availability changed: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.controllers] Receiver:Updating status
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(192.168.1.71):8009] Sending: Message urn:x-cast:com.google.cast.tp.connection from sender-0 to receiver-0: {'type': 'CONNECT', 'origin': {}, 'userAgent': 'PyChromecast', 'senderInfo': {'sdkType': 2, 'version': '15.605.1.3', 'browserVersion': '44.0.2403.30', 'platform': 4, 'systemVersion': 'Macintosh; Intel Mac OS X10_10_3', 'connectionType': 1}}
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(192.168.1.71):8009] Sending: Message urn:x-cast:com.google.cast.receiver from sender-0 to receiver-0: {'type': 'GET_STATUS', 'requestId': 1}
2021-05-11 23:05:18 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473384830864] Sending {"id": 2, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "binary_sensor.living_room_camera_online", "old_state": null, "new_state": {"entity_id": "binary_sensor.living_room_camera_online", "state": "on", "attributes": {"friendly_name": "Living room camera Online", "device_class": "connectivity"}, "last_changed": "2021-05-11T21:05:17.987521+00:00", "last_updated": "2021-05-11T21:05:17.987521+00:00", "context": {"id": "07c21e71b81a025b48198c95a9b0710e", "parent_id": null, "user_id": null}}}, "origin": "LOCAL", "time_fired": "2021-05-11T21:05:17.987521+00:00", "context": {"id": "07c21e71b81a025b48198c95a9b0710e", "parent_id": null, "user_id": null}}}
2021-05-11 23:05:18 INFO (MainThread) [homeassistant.components.esphome] Successfully connected to 192.168.1.93
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.socket_client] [Bedroom Display(192.168.1.71):8009] Connected!
2021-05-11 23:05:18 DEBUG (Thread-17) [pychromecast.socket_client] Thread started...
2021-05-11 23:05:18 DEBUG (MainThread) [aioesphomeapi.connection] 192.168.1.93: Sending <class 'api_pb2.DeviceInfoRequest'>: 
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] [Office Speaker(192.168.1.70):8009] connection listener: ffff977425e0 (CastStatusListener) ConnectionStatus(status='CONNECTED', address=NetworkAddress(address='192.168.1.70', port=8009))
2021-05-11 23:05:18 DEBUG (Thread-15) [homeassistant.components.cast.media_player] [media_player.office_speaker Office Speaker] Received cast device connection status: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-15) [homeassistant.components.cast.media_player] [media_player.office_speaker Office Speaker] Cast device availability changed: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.controllers] Receiver:Updating status
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] [Office Speaker(192.168.1.70):8009] Sending: Message urn:x-cast:com.google.cast.tp.connection from sender-0 to receiver-0: {'type': 'CONNECT', 'origin': {}, 'userAgent': 'PyChromecast', 'senderInfo': {'sdkType': 2, 'version': '15.605.1.3', 'browserVersion': '44.0.2403.30', 'platform': 4, 'systemVersion': 'Macintosh; Intel Mac OS X10_10_3', 'connectionType': 1}}
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] [Office Speaker(192.168.1.70):8009] Sending: Message urn:x-cast:com.google.cast.receiver from sender-0 to receiver-0: {'type': 'GET_STATUS', 'requestId': 1}
2021-05-11 23:05:18 DEBUG (SyncWorker_9) [amcrest.http] <AMC000EW_KT531F:AMC000EWK7SWKT531F> Query 12 worked. Exit code: <200>
2021-05-11 23:05:18 DEBUG (SyncWorker_9) [amcrest.http] <AMC000EW_KT531F:AMC000EWK7SWKT531F> HTTP query 13: http://192.168.1.61:80/cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect
2021-05-11 23:05:18 DEBUG (SyncWorker_9) [amcrest.http] <AMC000EW_KT531F:AMC000EWK7SWKT531F> Running query 13 attempt 1
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] [Office Speaker(192.168.1.70):8009] Connected!
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] Thread started...
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(192.168.1.76):8009] connection listener: ffff97685280 (CastStatusListener) ConnectionStatus(status='CONNECTED', address=NetworkAddress(address='192.168.1.76', port=8009))
2021-05-11 23:05:18 DEBUG (Thread-16) [homeassistant.components.cast.media_player] [media_player.workshop_speaker Workshop Speaker] Received cast device connection status: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-16) [homeassistant.components.cast.media_player] [media_player.workshop_speaker Workshop Speaker] Cast device availability changed: CONNECTED
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.controllers] Receiver:Updating status
2021-05-11 23:05:18 ERROR (Thread-16) [homeassistant] Error doing job: Task was destroyed but it is pending!
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(192.168.1.76):8009] Sending: Message urn:x-cast:com.google.cast.tp.connection from sender-0 to receiver-0: {'type': 'CONNECT', 'origin': {}, 'userAgent': 'PyChromecast', 'senderInfo': {'sdkType': 2, 'version': '15.605.1.3', 'browserVersion': '44.0.2403.30', 'platform': 4, 'systemVersion': 'Macintosh; Intel Mac OS X10_10_3', 'connectionType': 1}}
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.socket_client] [Office Speaker(192.168.1.70):8009] Received: Message urn:x-cast:com.google.cast.receiver from receiver-0 to sender-0: {'requestId': 1, 'status': {'userEq': {'high_shelf': {'frequency': 4500.0, 'gain_db': 0.0, 'quality': 0.707}, 'low_shelf': {'frequency': 150.0, 'gain_db': 0.0, 'quality': 0.707}, 'max_peaking_eqs': 0, 'peaking_eqs': []}, 'volume': {'controlType': 'master', 'level': 0.44999998807907104, 'muted': False, 'stepInterval': 0.019999999552965164}}, 'type': 'RECEIVER_STATUS'}
2021-05-11 23:05:18 DEBUG (Thread-15) [pychromecast.controllers] Received status: CastStatus(is_active_input=None, is_stand_by=None, volume_level=0.44999998807907104, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='', icon_url=None, volume_control_type='master')
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(192.168.1.76):8009] Sending: Message urn:x-cast:com.google.cast.receiver from sender-0 to receiver-0: {'type': 'GET_STATUS', 'requestId': 1}
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.socket_client] [Workshop Speaker(192.168.1.76):8009] Connected!
2021-05-11 23:05:18 DEBUG (Thread-16) [pychromecast.socket_client] Thread started...

Additional information

I cannot see what it is that causes the issue. I have several Google Assistant devices. 7 to be exact

The ERROR is in an area of the log where HA inits connection to a Google Assistant box.

But is it related? I cannot see anything failing. It just spits out the single error in the middle of the log with nothing I can see that fails afterwards

EDIT. See discussion below. Issue seems related to the Harmony integration and not at all Google.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:28 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
MEKadancommented, Oct 8, 2022

Hi,

I have never even heard about Logitech Harmony, but I started to get these after update to 2022.10. Looks like it (probably) has something to do with History stats?

EDIT: Copied a wrong error message here accidentally. Removed and posted the correct one(s) There are actually 2 similar messages, only difference is, that the error seems to be generated in different line of the python script

Logger: homeassistant Source: runner.py:96 First occurred: 05:45:39 (114 occurrences) Last logged: 13:59:30 Error doing job: Task was destroyed but it is pending!

Logger: homeassistant Source: runner.py:119 First occurred: 07:31:54 (54 occurrences) Last logged: 12:28:54 Error doing job: Task was destroyed but it is pending!

1reaction
bdracocommented, Feb 1, 2022

If you turn off xmpp support on the hub, it should avoid using the xml library and the problem should go away.

We previously advised to enable xmpp support since we were worried websocket support might go away, but since logi has discoed harmony, I don’t think thats a concern anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automation caused "Task was destroyed but it is pending!"
Hi, when the automation below is executed, I get the error “Task was destroyed but it is pending!” in log. The automation is...
Read more >
Task was destroyed but it is pending! : r/homeassistant - Reddit
The problem comes from closing the loop immediately after cancelling the tasks.
Read more >
How can i fix Task was destroyed but it is pending?
I think your problem is that the asyncio event loop is being terminated early before your tasks complete and resulting in the error....
Read more >
Docker template for Home Assistant - Python 3 home automation
I am about to setup Home Assistant but need USB for a device. ... Error doing job: Task was destroyed but it is...
Read more >
hacs-pyscript
A state trigger can be any Python expression using state variables - the trigger is evaluated only when a state variable it references...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found