fishbigger / HomeAssistant-Tapo-P100-Control

A custom integration for home assistant to control the Tapo P100 plugs
MIT License
208 stars 69 forks source link

[Bug] NameError: name 'ast' is not defined #48

Closed pvillaverde closed 2 years ago

pvillaverde commented 2 years ago

Hey there! Thanks for fixing the previous error. I'm testing it with a L530 bulb. Already setup the integration and I can switch it off, but when I try to switch on the light I got the following error:

[140323122419888] name 'ast' is not defined

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 494, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 948, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/tapo_p100_control/light.py", line 89, in turn_on
    self._l530.setBrightness(newBrightness)
  File "/usr/local/lib/python3.9/site-packages/PyP100/PyL530.py", line 38, in setBrightness
    if ast.literal_eval(decryptedResponse)["error_code"] != 0:
NameError: name 'ast' is not defined

I'm also trying to see if I can change color and other stuff, but didn't find anything yet. We'll keep searching arround!

mngad commented 2 years ago

I'm also getting this error with the L510 bulb.

fishbigger commented 2 years ago

Thanks for reporting this. I have fixed it now :)

mngad commented 2 years ago

I've updated from this error - I'm now getting this error: Failed to call service light/turn_on. Error Code: -1003, JSON formatting error