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

Exception when light.turn_on/turn_off/toggle called with anything other than an entity

Open benley opened this issue 2 years ago • 2 comments

Version information:

adaptive-lighting 1.0.15 home-assistant 2022.3.3

Description:

In home-assistant, the light.turn_on/light.turn_off/light.toggle services can be called with entities, devices, areas, or groups as the target parameter. Adaptive-lighting handles entities just fine, but if these services are called for a device or an area (probably also groups, I haven't tested that) then switch.py breaks with an exception:

Service call:

service: light.turn_on
target:
  area_id: 3bd8860e5c8243339f6d4b4f7de2fc2d

Resulting exception:

2022-03-10 23:06:41 ERROR (MainThread) [homeassistant] 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'

benley avatar Mar 10 '22 23:03 benley

Same issue for me

Stuke00 avatar Mar 18 '22 13:03 Stuke00

Same for me. Strange is that it happens even on lights not in adaptive lightning

nikee73 avatar May 05 '22 18:05 nikee73

I fixed the problem in PR https://github.com/basnijholt/adaptive-lighting/pull/321.

I released 1.0.17 with the fix 🎉

basnijholt avatar Aug 30 '22 02:08 basnijholt