question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Still some problems with permission denied

See original GitHub issue

System Health details

System Health

version core-2022.4.7
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.103-v8
arch aarch64
timezone Europe/Stockholm
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4950
Installed Version 1.24.5
Stage running
Available Repositories 1101
Downloaded Repositories 7
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 7.6
update_channel stable
supervisor_version supervisor-2022.05.0
docker_version 20.10.9
disk_total 931.4 GB
disk_used 19.7 GB
healthy true
supported true
board rpi3-64
supervisor_api ok
version_api ok
installed_addons Z-Wave JS (0.1.58), MariaDB (2.4.0), File editor (5.3.3), Let’s Encrypt (4.12.2), Samba share (9.6.1), Terminal & SSH (9.4.0)
Dashboards
dashboards 2
resources 2
views 2
mode storage

Huawei Solar Setup

Inverter: SUN2000-8KTL-M1 (Software version: V100R001C00SPC141) Smart Power Meter (3-phase) Luna 2000 - 5 kWh battery

Describe the issue

There is still some problem after fixing bug #57 , unfortunately. I did not have debug-logging, but the log seems a bit different than last time anyways. I have turned on debug-logging and will add those to this report as soon as the error reappears. But maybe the exceptions can give a clue to what has happened. According to the logs, I had some kind of network glitch, and my automation that run at 05:00 to set the battery-config failed with permission denied. I also got a permission denied when trying from the UI when I woke up. After reloading the integration, everything works again.

Reproduction steps

  1. Reload integration or restart home assistant
  2. Setting battery parameters works fine
  3. Some kind of network glitch
  4. Permission denied until a new reload/restart

Relevant debug logs

2022-05-05 23:21:57 ERROR (MainThread) [huawei_solar.huawei_solar] Could not read register value, has another device interrupted the connection?
2022-05-05 23:21:57 ERROR (MainThread) [custom_components.huawei_solar] Error fetching BT21A0216315_data_update_coordinator data: Could not update BT21A0216315 values: Could not read register value, has another device interrupted the connection?
2022-05-05 23:21:57 WARNING (MainThread) [pymodbus.client.asynchronous.async_io] Failed to connect: [Errno 111] Connect call failed ('192.168.0.180', 6607)
2022-05-05 23:21:58 WARNING (MainThread) [pymodbus.client.asynchronous.async_io] Failed to connect: [Errno 111] Connect call failed ('192.168.0.180', 6607)
2022-05-05 23:21:58 WARNING (MainThread) [pymodbus.client.asynchronous.async_io] Failed to connect: [Errno 111] Connect call failed ('192.168.0.180', 6607)
2022-05-05 23:21:59 WARNING (MainThread) [pymodbus.client.asynchronous.async_io] Failed to connect: [Errno 111] Connect call failed ('192.168.0.180', 6607)

2022-05-06 05:00:00 ERROR (MainThread) [homeassistant.components.automation.anvand_sol_batteriet] Använd sol-batteriet: Error executing script. Unexpected error for call_service at pos 1: Permission denied
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 266, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 379, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 582, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1634, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1671, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 955, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 75, in async_set_value
    await entity.async_set_value(value)
  File "/config/custom_components/huawei_solar/number.py", line 197, in async_set_value
    if await self.bridge.set(self.entity_description.key, int(value)):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 275, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied
2022-05-06 05:00:00 ERROR (MainThread) [homeassistant.components.automation.anvand_sol_batteriet] While executing automation automation.anvand_sol_batteriet
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 266, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 515, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1275, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 379, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 582, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1634, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1671, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 955, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 75, in async_set_value
    await entity.async_set_value(value)
  File "/config/custom_components/huawei_solar/number.py", line 197, in async_set_value
    if await self.bridge.set(self.entity_description.key, int(value)):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 275, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied
2022-05-06 06:22:31 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 334, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='Pause on PRI/Upgrade'
2022-05-06 07:37:09 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547750506256] Permission denied
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 266, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1634, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1671, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 955, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 75, in async_set_value
    await entity.async_set_value(value)
  File "/config/custom_components/huawei_solar/number.py", line 197, in async_set_value
    if await self.bridge.set(self.entity_description.key, int(value)):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/bridge.py", line 275, in set
    return await self.client.set(name, value, slave=self.slave_id)
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 304, in set
    response = await self.write_registers(
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 335, in write_registers
    raise PermissionDenied("Permission denied")
huawei_solar.exceptions.PermissionDenied: Permission denied

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wlcrscommented, May 6, 2022

The good news: the fallback mechanism works as intended. The bad news: I forgot to add an ‘await’ in front of the login-calls, which means that they were not being executed (Python asyncio is a mess on that point imho). Fixed now: https://gitlab.com/Emilv2/huawei-solar/-/commit/f0d395291fbc5aa7ccf86d2ce431bb4018eebfda

Can you test by changing the value in requirements from /config/custom_components/huawei_solar/manifest.json to:

huawei-solar==2.0.2rc2

You might need to restart your HA twice before the download succeeds (due to how PyPI caches it’s downloads).

0reactions
wlcrscommented, May 25, 2022

I’ve released v1.0.2 which bumps the huawei-solar lib to 2.0.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix 'permission denied' error in Linux? [Solutions]
If you are not authorized to access the file or directory, executing any command on that will result as a “permission denied” error...
Read more >
How to resolve the "Permission Denied" error in Linux
While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make...
Read more >
How to Fix Shell Script Permission Denied Error in Linux
To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode)...
Read more >
Permission denied in Mac Terminal? Try this fix - MacPaw
The 'Permission denied' error in Terminal is usually caused by permission problems with the file or directory that you want to work on....
Read more >
Error: Permission denied (publickey) - GitHub Docs
A "Permission denied" error means that the server rejected your connection. There could be several reasons why, and the most common examples are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found