Closed naamah75 closed 1 year ago
I have no idea, this is an issue with the Tapo integration in HA. The measure tool just calls service to turn on the light and set to a given brightness.
Could you try to call that service from HA developer tools and see if you get similar error?
Looking at the error again:
plugp100.responses.tapo_exception.TapoException: Returned unknown error_code: -1008 msg: No message
Plug P100 is a smart plug. Did you somehow set your light entity to the smart plug?
this is my .env file ... so, why it take P100 as light?
# Set the power meter to use (hass, shelly, tuya, kasa, manual, tasmota)
POWER_METER=hass
# Set the light controller to use (hass, hue)
LIGHT_CONTROLLER=hass
# Set the media controller to use (for measuring smart speakers).
MEDIA_CONTROLLER=hass
# Set the log level (CRITICAL, ERROR, WARNING, INFO, DEBUG)
LOG_LEVEL=INFO
# time between changing the light params and taking the measurement
SLEEP_TIME=3
# time between taking multiple samples for the same light setting
SLEEP_TIME_SAMPLE=3
# additional time to wait for each significant change in hue
SLEEP_TIME_HUE=2
# additional time to wait for each significant change in saturation
SLEEP_TIME_SAT=2
# additional time to wait for each significant change in color temperature
SLEEP_TIME_CT=1
# Set to a value higher than 1 to take multiple samples to reduce noise
SAMPLE_COUNT=2
# Power Meter Nudging configuration (Useful if PM doesn't report a new reading if readings are unchanged)
# How many times should nudging the Power Meter be attempted?
MAX_NUDGES=3
# When Nudging, how long to hold the non-desired state for?
PULSE_TIME_NUDGE=6
# How long to wait for the Power Meter to settle on the desired measurement after nudging
SLEEP_NUDGE=30
# Precision for the HS mode loop. You can increase it up to 4 to improve the precision
# of the profile by taking more measurements
HS_BRI_PRECISION=1.0
HS_HUE_PRECISION=1.0
HS_SAT_PRECISION=1.0
# Shelly
SHELLY_IP=x.x.x.x
SHELLY_TIMEOUT=60
# Tuya
TUYA_DEVICE_ID=aaaaaaaaad89682385bbb
TUYA_DEVICE_IP=x.x.x.x
TUYA_DEVICE_KEY=aaaaaaaae1b8abb
TUYA_DEVICE_VERSION=3.3
# Hue
HUE_BRIDGE_IP=x.x.x.x
# Home assistant
HASS_URL=http://10.0.0.221:8123/api
#HASS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI2N2M0YmQzMjIzZTU0MTRiYjQzNzJjMTlmYjQ5ZDBkOCIsImlhdCI6MTY4NDA4MzA5OCwiZXhwIjoxOTk5NDQzMDk4fQ.E-mSGB4QYzUEc1uo1kH3K2K9xxdI0bmnYFcg5bzhmEk
HASS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkNDdlNzkzN2NiODI0OGZhODY2YzFjOWUxMzg4OWUzMyIsImlhdCI6MTY4NDY1NDU1NiwiZXhwIjoyMDAwMDE0NTU2fQ.WVD0IWw8SPYcd11lY_EOATYiRMVn4s0k9xdJAzOeXaQ
# Set to true when you want to call update_entity service before requesting a power value.
# This can help when your power sensor does not update frequently enough
HASS_CALL_UPDATE_ENTITY_SERVICE=false
# Tasmota
TASMOTA_DEVICE_IP=x.x.x.x
# Kasa
KASA_DEVICE_IP=x.x.x.x
# Predefine answers to questions
COLOR_MODE=color_temp
GENERATE_MODEL_JSON=true
GZIP=true
MULTIPLE_LIGHTS=false
LIGHT_ENTITY_ID=light.lampadina_smart_5
MEASURE_DEVICE=Tapo P110
NUM_LIGHTS=1
LIGHT_MODEL_ID=L630
MODEL_NAME=Tapo L630
DUMMY_LOAD=false
POWERMETER_ENTITY_ID=sensor.presa_smart_8_current_power
RESUME=true
this the output from docker cli:
2023-07-12 08:38:41,084 [INFO] Starting measurements. Estimated duration: 3.6h
Traceback (most recent call last):
File "//measure.py", line 330, in <module>
main()
File "//measure.py", line 322, in main
measure.start()
File "//measure.py", line 127, in start
runner_result = self.runner.run(answers, export_directory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/runner/light.py", line 109, in run
self.light_controller.change_light_state(
File "/light_controller/hass.py", line 40, in change_light_state
self.client.trigger_service("light", "turn_on", **json)
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 262, in trigger_service
data = self.request(
^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 108, in request
return self.response_logic(response=resp, decode_bytes=decode_bytes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 113, in response_logic
return Processing(response=response, decode_bytes=decode_bytes).process()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/processing.py", line 103, in process
raise InternalServerError(status_code, content)
homeassistant_api.errors.InternalServerError: Home Assistant returned a response with an error status code 500.
'500 Internal Server Error\n\nServer got itself in trouble'
Please try in HA first:
In developer tools call service:
service: light.turn_on
data:
color_temp: 257
brightness: 50
transition: 0
target:
entity_id: light.lampadina_smart_5
Does this work correctly?
The bulb goes out, but there is no error
The bulb shouldn't go out, it should when using light.turn_off
service, but obviously not when using light.turn_on
.
Btw I checked powercalc measure code and it sets the light to brightness level 1 without a color temperature first in the beginning of measure script. That would be the following HA service call:
service: light.turn_on
data:
brightness: 1
transition: 0
target:
entity_id: light.lampadina_smart_5
Could you try executing that one manually please and see if you get the same error in HA?
p100 is correct btw, it's just the underlying library used by Tapo integration in HA, which is named that way. Also several reports are there to be found with error 1008. https://github.com/fishbigger/TapoP100/issues/110
I think is the same error:
websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Returned unknown error_code: -1008 msg: No message
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
return await cast(
^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 848, in entity_service_call
response_data = task.result() # pop exception if have
^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1192, in async_request_call
return await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 602, in async_handle_toggle_service
await async_handle_light_on_service(light, call)
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 582, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/config/custom_components/tapo/light.py", line 165, in async_turn_on
await self._change_brightness(brightness)
File "/config/custom_components/tapo/light.py", line 185, in _change_brightness
value_or_raise(await self.coordinator.device.set_brightness(brightness_to_set))
File "/config/custom_components/tapo/utils.py", line 15, in value_or_raise
value_or_error: Union[T, Exception] = either.fold(lambda x: x, lambda y: y)
^^^^^^^^^^^^^^^^^^^^
plugp100.responses.tapo_exception.TapoException: Returned unknown error_code: -1008 msg: No message
I removed the initial call setting brightness to 1 in the measure tool (as this caused issues with your Tapo integration).
Are you able to try again by running latest master docker container? bramgerritsen/powercalc-measure:master
.
Make sure to pull first when you were already using the same docker container version.
Sorry for the delayed reply! Same error :(
Following error from HA logs.
Logger: aiohttp.server
Source: custom_components/tapo/helpers.py:11
Integration: TP-Link Tapo (documentation, issues)
First occurred: 15:12:52 (3 occurrences)
Last logged: 15:17:13
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/api/__init__.py", line 349, in post
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 580, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/config/custom_components/tapo/light.py", line 167, in async_turn_on
await self._change_brightness(brightness)
File "/config/custom_components/tapo/light.py", line 187, in _change_brightness
value_or_raise(await self.coordinator.device.set_brightness(brightness_to_set))
File "/config/custom_components/tapo/helpers.py", line 11, in value_or_raise
raise value_or_error
plugp100.responses.tapo_exception.TapoException: Returned error_code: TapoError.ERR_PARAMS: Request params error
Following the response from command line:
PS C:\Users\webma\powercalc-measure> docker run --rm --name=measure --env-file=my.env -v ${pwd}/export:/app/export -v ${pwd}/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest
Powercalc measure: v1.8.5:docker
2023-08-03 12:33:37,065 [INFO] Selected powermeter: hass
2023-08-03 12:33:37,065 [INFO] Selected light controller: hass
[?] What kind of measurement session do you want to run?: Light bulb(s)
> Light bulb(s)
Smart speaker
Recorder
Average
2023-08-03 12:33:38,484 [INFO] Starting measurements. Estimated duration: 3.6h
2023-08-03 12:33:38,652 [INFO] Start taking measurements for color mode: color_temp
2023-08-03 12:33:38,653 [INFO] Waiting 10 seconds...
2023-08-03 12:33:48,653 [INFO] Progress: 0%, Estimated time left: 3.6h
2023-08-03 12:33:48,653 [INFO] Changing light to: ColorTempVariation(bri=1, ct=153)
Traceback (most recent call last):
File "//measure.py", line 330, in <module>
main()
File "//measure.py", line 322, in main
measure.start()
File "//measure.py", line 127, in start
runner_result = self.runner.run(answers, export_directory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/runner/light.py", line 126, in run
self.light_controller.change_light_state(
File "/light_controller/hass.py", line 40, in change_light_state
self.client.trigger_service("light", "turn_on", **json)
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 262, in trigger_service
data = self.request(
^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 108, in request
return self.response_logic(response=resp, decode_bytes=decode_bytes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/rawclient.py", line 113, in response_logic
return Processing(response=response, decode_bytes=decode_bytes).process()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/homeassistant_api/processing.py", line 103, in process
raise InternalServerError(status_code, content)
homeassistant_api.errors.InternalServerError: Home Assistant returned a response with an error status code 500.
'500 Internal Server Error\n\nServer got itself in trouble'
You get a different error now and on another place. The measure tool uses HA service to change the light to brightness 1 and color temperature 153. However the Tapo integration is misbehaving on that again.
Let's try manually executing the same service call in HA and see if you get similar error in HA logs:
service: light.turn_on
data:
brightness: 1
color_temp: 153
transition: 0
target:
entity_id: light.lampadina_smart_5
The bulb turn on but this is the error on the log (I've moved change from light.lampadina_smart_5
to light.lampadina_smart_9
):
Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/tapo/helpers.py:11
Integration: TP-Link Tapo ([documentation](https://github.com/petretiandrea/home-assistant-tapo-p100), [issues](https://github.com/petretiandrea/home-assistant-tapo-p100/issues))
First occurred: 07:57:03 (1 occurrences)
Last logged: 07:57:03
websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Returned error_code: TapoError.ERR_PARAMS: Request params error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 580, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/config/custom_components/tapo/light.py", line 167, in async_turn_on
await self._change_brightness(brightness)
File "/config/custom_components/tapo/light.py", line 187, in _change_brightness
value_or_raise(await self.coordinator.device.set_brightness(brightness_to_set))
File "/config/custom_components/tapo/helpers.py", line 11, in value_or_raise
raise value_or_error
plugp100.responses.tapo_exception.TapoException: Returned error_code: TapoError.ERR_PARAMS: Request params error
That's what I already suspected. You get the exact same error when doing the service call directly from HA.
It's really an issue with Tapo integration. I cannot give support on that, so I suggest you to create an issue at that custom component issue tracker. https://github.com/petretiandrea/home-assistant-tapo-p100
You could try playing around with the parameters, and see if that makes any difference.
For example increase brightness
. As I see the error is raised during set_brightness
call in tapo integration.
Let me know your findings.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
System Health details
Home Assistant 2023.7.1 Supervisor 2023.07.1 Operating System 10.3 Frontend 20230705.1 - latest
Checklist
Describe the issue
Got this error when start light measurement: (updated both HA and powercal-measure docker image)
Reproduction steps
docker run --rm --name=measure --env-file=.env -v ${pwd}/export:/app/export -v ${pwd}/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest
...
Debug logs
Diagnostics dump or YAML config
No response