Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadTimeout Error while running automation #214

Open
dennisduysak opened this issue Jun 17, 2024 · 24 comments
Open

ReadTimeout Error while running automation #214

dennisduysak opened this issue Jun 17, 2024 · 24 comments

Comments

@dennisduysak
Copy link

I am experiencing a ReadTimeout error with my Gardena integration in Home Assistant. This issue occurs while executing my automation, which is designed to start a new valve every 20 minutes. The error consistently occurs when starting the first valve, causing the entire automation to fail despite continue_on_error: true being set.

Effected device:

  • smart irrigation control

Environment:

  • Home Assistant version: 2024.5.2
  • Gardena integration version: 1.1.0
  • Python version: 3.12
  • Operating system: Running in Docker container

Additional Information:

  • Any insights or suggestions to resolve this issue would be greatly appreciated. Thank you for your assistance!
Logger: homeassistant.components.automation.bewasserung_neu
Quelle: components/automation/__init__.py:723
Integration: Automatisierung (Dokumentation, Probleme)
Erstmals aufgetreten: 16. Juni 2024 um 06:00:06 (2 Vorkommnisse)
Zuletzt protokolliert: 07:00:05

While executing automation automation.bewasserung_neu
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 373, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request
    raise exc from None
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request
    response = await connection.handle_async_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 143, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 113, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 186, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 224, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 32, in read
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/usr/local/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ReadTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 723, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 556, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 753, in _async_device_step
    await device_action.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 72, in async_call_action_from_config
    await platform.async_call_action_from_config(hass, config, variables, context)
  File "/usr/src/homeassistant/homeassistant/components/switch/device_action.py", line 36, in async_call_action_from_config
    await toggle_entity.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/toggle_entity.py", line 124, in async_call_action_from_config
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1680, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gardena_smart_system/switch.py", line 363, in turn_on
    ).result()
      ^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/gardena/devices/smart_irrigation_control.py", line 58, in start_seconds_to_override
    await self.location.smart_system.call_smart_system_service(valve_id, data)
  File "/usr/local/lib/python3.12/site-packages/gardena/smart_system.py", line 100, in call_smart_system_service
    r = await self.client.put(
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1929, in put
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 90, in request
    return await super().request(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1763, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 372, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout

Automation looks like:

alias: Bewässerung - Neu
description: ""
trigger:
  - platform: time
    at: "07:00:00"
condition:
  - condition: time
    weekday:
      - mon
      - wed
      - fri
      - sun
action:
  - type: turn_on
    continue_on_error: true
    device_id: 70ffb5e17a28fbd22e4f85b62678bab8
    entity_id: 49cb9b01357762d087cbc5364c2ffd91
    domain: switch
    enabled: true
  - delay:
      hours: 0
      minutes: 19
      seconds: 45
      milliseconds: 0
    enabled: true
  - type: turn_on
    continue_on_error: true
    device_id: 70ffb5e17a28fbd22e4f85b62678bab8
    entity_id: 80e998bb8f7328e5628638bb0242b23b
    domain: switch
  - delay:
      hours: 0
      minutes: 19
      seconds: 45
      milliseconds: 0
  - type: turn_on
    continue_on_error: true
    device_id: 70ffb5e17a28fbd22e4f85b62678bab8
    entity_id: aae5e10b34590f21e9f99b7b3595a424
    domain: switch
  - delay:
      hours: 0
      minutes: 19
      seconds: 45
      milliseconds: 0
  - type: turn_on
    continue_on_error: true
    device_id: 70ffb5e17a28fbd22e4f85b62678bab8
    entity_id: b4ae42a68ae7382a3683deb8f6ab2a44
    domain: switch
mode: single
@oliskippy
Copy link

I faced the same 2 days ago in a script opening the watering valves of the gardena smart irrigation control:
Error: ReadTimeout → script ends.
Any solution would be very appreciated.

domain: switch
service: turn_off
service_data: {}
target:
entity_id:
- switch.centrale_vanne_2

@Stoffl17
Copy link

Same for me!
Would be nice to get it solved as summer is coming soon :-)
If I can support with log-files just let me know!
THANKS!

@steyrblade
Copy link

Same issue. Any news?

@nopbop
Copy link

nopbop commented Jun 27, 2024

Same issue for me in version 2024.6.4

Executed: June 27, 2024 at 10:23:30 PM
Error: ReadTimeout
Result:
params:
domain: switch
service: turn_off
service_data: {}
target:
entity_id:
- switch.irrigation_control_1_plates_bandes_piscine
running_script: false

@Uwe1960
Copy link

Uwe1960 commented Jun 29, 2024

Same issue.

Effected device:

Gardena smart Water Control

Environment:

Home Assistant version: 2024.6.4
Gardena integration version: 1.1.1-rc3
Operating system: Running in Docker container

@mike4001
Copy link

mike4001 commented Jul 3, 2024

Same here

It´s a bit hit and miss.

Sometimes the integration works without any problems and sometimes it does not ...

@oliskippy
Copy link

To avoid missed opening/closing of watering valves I created (manual trick until the problem is hopefully solved) a slave script that only open/close valve (and allowed to fail) and a master script that keeps trying to open/close the valve until successful (by re-triggering the slave script). With 5 sec delay between each try. Until now worked with # of attempts between 1 and 3 ! But we still need a proper correction of the Gardena integration.

@ChrisHomeAssistant
Copy link

Could you please share how you set up this workaround using a slave script?
I also tried it with a script with continuing on error but it still fails.
Has anybody worked with the custom integration retry?

@oliskippy
Copy link

I use a single script for all valves, with a variable like 1,2,3,4 to open the valve 1,2,3,4 and 11,22,33,44 to close valve 1,2,3,4

Code for the slave script that "can" crash (duplicate for the other valves 2,3,4...) :

alias: Centrale Gardena on-off
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ choix == 1 }}"
        sequence:
          - type: turn_on
            device_id: 90eeefd7db817d489a7686dae7357730
            entity_id: 30050e150937b6f9a9853c4f43a8097c
            domain: switch
      - conditions:
          - condition: template
            value_template: "{{ choix == 11 }}"
        sequence:
          - type: turn_off
            device_id: 90eeefd7db817d489a7686dae7357730
            entity_id: 30050e150937b6f9a9853c4f43a8097c
            domain: switch
icon: mdi:water

The master script looks like:

alias: Centrale Gardena on-off Master
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ choixm == 1 }}"
        sequence:
          - repeat:
              sequence:
                - service: script.turn_on
                  target:
                    entity_id: script.centrale_gardena_on_off
                  data:
                    variables:
                      choix: 1
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 5
                    milliseconds: 0
                - if:
                    - condition: template
                      value_template: "{{ repeat.index >= 2 }}"
                  then:
                    - service: notify.mobile_app
                      metadata: {}
                      data:
                        message: choixm {{ choixm }} tentative {{ repeat.index }}
              until:
                - condition: or
                  conditions:
                    - condition: device
                      type: is_on
                      device_id: 90eeefd7db817d489a7686dae7357730
                      entity_id: 30050e150937b6f9a9853c4f43a8097c
                      domain: switch
                    - condition: template
                      value_template: "{{ repeat.index == 4 }}"
      - conditions:
          - condition: template
            value_template: "{{ choixm == 11 }}"
        sequence:
          - repeat:
              sequence:
                - service: script.turn_on
                  target:
                    entity_id: script.centrale_gardena_on_off
                  data:
                    variables:
                      choix: 11
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 5
                    milliseconds: 0
                - if:
                    - condition: template
                      value_template: "{{ repeat.index >= 2 }}"
                  then:
                    - service: notify.mobile_app
                      metadata: {}
                      data:
                        message: choixm {{ choixm }} tentative {{ repeat.index }}
              until:
                - condition: or
                  conditions:
                    - condition: device
                      type: is_off
                      device_id: 90eeefd7db817d489a7686dae7357730
                      entity_id: 30050e150937b6f9a9853c4f43a8097c
                      domain: switch
                    - condition: template
                      value_template: "{{ repeat.index == 4 }}"
icon: mdi:water

The masterscript is called in the regular watering script instead of opening the valve directly, like to open valve 1:

  - service: script.turn_on
    target:
      entity_id: script.centrale_gardena_on_off_master
    data:
      variables:
        choixm: 1

Maybe not very academic code but it works and this sends a notification if a 2nd, 3rd or 4th attempt was needed. It always went to max a second attempt !

@ChrisHomeAssistant
Copy link

Great, thanks a lot, I'll give it a try!

@Stoffl17
Copy link

Maybe some good news guys!
I already had a similar script like described by @oliskippy, but my execution rate was a desaster.
Today I tried now following steps:

  • Remove the Garden Integration
  • Remove the Application completely from the developer portal
  • Setup everything again (New Application, then Installation of Gardena Integraton with new APP-ID and Secret)
  • All entities and the script can remain like they are (@oliskippy: In your case the device IDs might change, I propose for such a case to always go via the entity_id (entity_name) itself)

Result: It works smooth. No Loops in my scripts after a few tries.

I hope this helps fro you, too.

@ChrisHomeAssistant
Copy link

Maybe I’m too pessimistic, but I don’t know if it might solve it completely. I started my setup 5 days ago. And there are still these time out errors.

@martinwild1987
Copy link

I have the same issue: Command to valve - open - error after a few seconds, so the first valve is opened for 30 minutes (standard in the irrigation control), while the other 5 won't get a single drop of water....

Problem obtains not every time the automation is running....

Already installed version 1.1.0 (this number is NOT shown in the Integration overview though having it uninstalled before in HACS and reinstalled it with restarts. It shows version 1.0.0)

This error occurs since 2023.... please help

@Stoffl17
Copy link

Maybe I’m too pessimistic, but I don’t know if it might solve it completely. I started my setup 5 days ago. And there are still these time out errors.

Yes you are right. The fails are less, but not gone.

@Developers team: It would be nice to get a short info if you are plannning to look on this and also other topics or if you decided to stop the development.

@grm
Copy link
Contributor

grm commented Aug 11, 2024 via email

@mike4001
Copy link

We know of course that you developers do this in your free time and without pay.

So thank you in advance for your help.

If you need any logs or more information people here are willing to help for sure.

@Stoffl17
Copy link

Stoffl17 commented Aug 13, 2024

Hello everyone ! There is no real team behind the library/integration ;) I try to maintain it ads much as I can, but I have been quite busy in the past few months with my work. I am currently on holidays abroad and I will try to solve as many issues as possible when I come back to france. I am sorry for the lag in solving this issues and I ll do my best to update everything to make it work again Enjoy the summer, Jérémie Le dim. 11 août 2024, 08:19, Stoffl17 @.***>

Dear @grm,

thanks for your positive feedback. I really appreciate.
Please don't feel under pressure, I was just curious to know if the maintenance will proceed.
If I can support with logs or anything else, just let me know. I'm alos open to do beta-testing, if it is required.

Best regards!

@malkie-hass
Copy link

Hello,
I actually have the same issue with my lawnmower. Sometimes it seems to work not sure what is going on.

malkie

@grm
Copy link
Contributor

grm commented Sep 2, 2024

Unfortunately, httpx.ReadTimeouterrors comes from network error with the gardena API.
There is a retry mechanism that should handle these kind of issues, but it may not. be implemented or there is a hole in the implementation.
Maybe we could try with a loop too retry, but. that seems like a little overkill and rough.

I guess that recreating the application in the gardena API solvee a kind if issue like this.

I'll think about something about it.

Please tell me how do often it happens and if doing nothing also solvees sometimes the issue ?

@ChrisHomeAssistant
Copy link

Thanks for looking into this!
In my case it happens 2 out of 3 times. Sometimes the valve does not open, sometimes it does. But as I have an automation trying to orchestrate several valves, the remaining calls are not executed any more.

Following oliskippy's advice I set up scripts and called them in a loop until the valve is open. Nevertheless, in my case this also fails as it seems that HA's continue_on_error doesn't work properly at the moment or expects a certain error message format to continue. (home-assistant/core#115401)

@Uwe1960
Copy link

Uwe1960 commented Sep 3, 2024 via email

@ChrisHomeAssistant
Copy link

I also tried the integration "retry" but, unfortunately, in my case it did not work reliably

@ChrisHomeAssistant
Copy link

Hi all,

are there any updates on this topic? Or any ideas how to avoid these issues?

Thanks

@ChrisHomeAssistant
Copy link

Although the watering season slowly comes to an end, I'm still curious if there are any new ideas to solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

12 participants