core: TP-Link RGB blub: Failed to call service light/turn_off. 'on_off'

The problem

When turning on a TP-Link KL130, the light will turn on/off but an error is logged: Failed to call service light/turn_off. ‘on_off’ or Failed to call service light/turn_on. ‘on_off’ This error also causes an issue with Google Assistant reporting “Something went wrong for devicename” when trying to turn the bulb on / off

The bulb is hardware v2 and firmware v1.06

This issue has been going on as long as I have had this bulb, a few months

What is version of Home Assistant Core has the issue?

core-2021.3.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

TP-Link

Link to integration documentation on our website

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

Example YAML snippet

# Put your YAML below this line
tplink:
  discovery: false
  light:
    - host: 192.168.1.22

Anything in the logs that might be useful for us?

# Put your logs below this line
Logger: homeassistant.components.websocket_api.http.connection
Source: components/tplink/light.py:311
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 7:32:04 PM (5 occurrences)
Last logged: 7:36:04 PM

[140094974973840] 'on_off'
[140094915845712] 'on_off'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 136, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 595, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 632, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/tplink/light.py", line 205, in async_turn_off
    await self._async_set_light_state_retry(
  File "/usr/src/homeassistant/homeassistant/components/tplink/light.py", line 397, in _async_set_light_state_retry
    self._light_state = self._light_state_from_params(light_state_params)
  File "/usr/src/homeassistant/homeassistant/components/tplink/light.py", line 311, in _light_state_from_params
    state = bool(light_state_params[LIGHT_STATE_ON_OFF])
KeyError: 'on_off'

Screenshots of errors in the frontend image image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

The device is not reporting the new state here and that is why it’s failing.

A simple quick fix would be to ignore the response when the expected payload is not there, and wait until it gets updated by the regular update cycle (will cause some delay).

Second option (which would require refactoring from the looks of it) would be to keep track on what was the wanted change and update the internal values directly when the executed call change caused no error.

Is there anything I can do to fix it for now?

Thanks very much for your time.

Updated to the beta now that it is released and confirmed this is resolved! thanks