adaptive-lighting icon indicating copy to clipboard operation
adaptive-lighting copied to clipboard

Error doing job: Task exception was never retrieved

Open cinghialino opened this issue 2 years ago • 11 comments

Version information:

Adaptive Lighting Release 1.0.15

installed on a Raspberry Pi 4 with Home Assistant Core 2022.5.2 Home Assistant Supervisor 2022.05.0 Home Assistant OS 7.6

Description:

there is this error lingering around my logs, everything seems to be working, but this error keeps coming up several times (most I've checked was 56 times) and it seems adding on itself indefinitely. Can't figure out what causes it.

Error message:

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/adaptive_lighting/switch.py:1257
Integration: Adaptive Lighting (documentation, issues)
First occurred: 12:23:31 PM (3 occurrences)
Last logged: 12:23:31 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/adaptive_lighting/switch.py", line 1257, in turn_on_off_event_listener
    entity_ids = cv.ensure_list_csv(service_data[ATTR_ENTITY_ID])
KeyError: 'entity_id'

cinghialino avatar May 08 '22 16:05 cinghialino

still happening, even after recent updates.

cinghialino avatar May 21 '22 12:05 cinghialino

Same here

marcokitzmann avatar May 21 '22 20:05 marcokitzmann

this error keeps turning back on the lights after I've turned them OFF via an automation or group

cinghialino avatar May 22 '22 10:05 cinghialino

Triage Notes

I did some digging and discovered the issue happens on when an Automation that turns on the lights uses an area_id and not entity_id.

Here is an example event that fails:

event: <Event call_service[L]: domain=light, service=turn_on, service_data=area_id=['pantry']>

And here is one that is fine:

event: <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.master_bedroom_lights_2, transition=45.0, brightness=255, color_temp=246>

Here id the problematic code:

service = event.data[ATTR_SERVICE]
service_data = event.data[ATTR_SERVICE_DATA]
entity_ids = cv.ensure_list_csv(service_data[ATTR_ENTITY_ID])

This code only attempts to read entity_id (service_data[ATTR_ENTITY_ID]) and not the other supported targets (area_id and device_id).

Workaround

Update all Automations to use Entities and not Areas. You can switch to the new Entity Groups which would allow controlling a collection of entities at the same time which are similar to using Areas.

jls5177 avatar May 22 '22 20:05 jls5177

Thank you for your triage. I hope the code gets updated as it would be a nightmare to use entity_id in my automations..

cinghialino avatar May 22 '22 23:05 cinghialino

@RubenKelevra is there anything that we can do to have this issue addressed?

cinghialino avatar Jun 19 '22 12:06 cinghialino

@cinghialino well, does it break anything for you?

I mean if it's just a logged error I wouldn't want to invest the time to debug and fix and and rather work on the rewrite of the whole output-module which obviously will replace the code causing this.

RubenKelevra avatar Jun 19 '22 12:06 RubenKelevra

Well, it does break stuff. Every time I send a turn_off, the lights are turning off but after a few seconds they turn back on. If I disable adaptive lighting or take out lights from it, everything works fine. It doesn't happen when I use entity_id, but as mentioned above, it's very inconvenient to use that to control lights of an entire area.

cinghialino avatar Jun 19 '22 12:06 cinghialino

Can we please have the code updated to use areas instead of entities?

cinghialino avatar Jul 14 '22 11:07 cinghialino

@cinghialino, I'll happily accept and review your pull request 😃

basnijholt avatar Jul 14 '22 19:07 basnijholt

I've had this error log for a good while, but good to know it's not causing any issues other than an error log.

I personally have far too many automations going on with area's to switch to the groups workaround, but thanks for detailing @jls5177 (I'm surprised more people aren't noting/:+1:'ing this issue, I would've thought groups were quite popular especially since HA has areas built into the UI editor lately.)

I think #75 is also a duplicate of this for what it's worth.

ahaverty avatar Jul 21 '22 22:07 ahaverty

I guess this won't be fixed. I give up.

cinghialino avatar Aug 28 '22 20:08 cinghialino

I fixed the problem in PR #321.

I will release 1.0.17 in a few minutes :tada:

basnijholt avatar Aug 30 '22 02:08 basnijholt

I fixed the problem in PR #321.

I will release 1.0.17 in a few minutes 🎉

Thanks @basnijholt, can confirm the issue is resolved.

Broekman avatar Aug 30 '22 11:08 Broekman