sanjoyg / dirigera_platform

HomeAssistant Integration for Dirigera Platform
MIT License
123 stars 16 forks source link

Sometimes getting MaxRetryError in a long running light automation #18

Closed snrnats closed 7 months ago

snrnats commented 8 months ago

I have a HA automation to simulate sunrise effect using a light bulb which is connected via Dirigera. This automation turns on the light and adjust the brightness twice per minute over 40 mins period. Most of the time the automation fails at a random time while adjusting the brightness.

This error originated from a custom integration.

Logger: custom_components.dirigera_platform
Source: custom_components/dirigera_platform/light.py:177
integration: IKEA Dirigera Hub Integration (documentation, issues)
First occurred: 8:33:05 AM (1 occurrences)
Last logged: 8:33:05 AM

error encountered turning on : Bed light
This error originated from a custom integration.

Logger: custom_components.dirigera_platform
Source: custom_components/dirigera_platform/light.py:178
integration: IKEA Dirigera Hub Integration (documentation, issues)
First occurred: 8:33:05 AM (1 occurrences)
Last logged: 8:33:05 AM

HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))
Logger: homeassistant.components.script.1709568633936
Source: helpers/script.py:1805
integration: Script (documentation, issues)
First occurred: 8:33:05 AM (3 occurrences)
Last logged: 8:33:05 AM

Lamp Wake Up: Repeat at step 2: If at step 3: Error executing script. Error for call_service at pos 1: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))")), 'dirigera_platform', 'hub_exception')
Lamp Wake Up: Repeat at step 2: Error executing script. Error for if at pos 3: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))")), 'dirigera_platform', 'hub_exception')
Lamp Wake Up: Error executing script. Error for repeat at pos 2: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))")), 'dirigera_platform', 'hub_exception')
Logger: homeassistant.components.automation.light_alarm
Source: helpers/script.py:1805
integration: Automation (documentation, issues)
First occurred: 8:33:05 AM (1 occurrences)
Last logged: 8:33:05 AM

Light Alarm: Error executing script. Error for call_service at pos 1: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))")), 'dirigera_platform', 'hub_exception')
Logger: homeassistant.components.automation.light_alarm
Source: components/automation/__init__.py:687
integration: Automation (documentation, issues)
First occurred: 8:33:05 AM (1 occurrences)
Last logged: 8:33:05 AM

Error while executing automation automation.light_alarm: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='192.168.0.14', port=8443): Max retries exceeded with url: /v1/devices/aa9eb7ac-ecc1-4914-b8a9-26c5d2302298_1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff803f25a0>: Failed to establish a new connection: [Errno 101] Network unreachable'))")), 'dirigera_platform', 'hub_exception')
helpers/script.py ``` alias: Lamp Wake Up sequence: - service: light.turn_on data: brightness: "{{ min_brightness }}" color_temp: "{{ max_mireds }}" target: entity_id: "{{ target_light }}" - repeat: until: - condition: or conditions: - condition: template value_template: "{{ is_state(target_light, 'off') }}" - condition: template value_template: "{{ state_attr(target_light, 'brightness') >= max_brightness }}" - condition: template value_template: >- {{ (((as_timestamp(now()) - start_time) / individual_step) | round(0, "ceil")) > steps }} sequence: - variables: steps_to_now: |- {{ ((as_timestamp(now()) - start_time) / individual_step) | round(0, "ceil") }} brightness: >- {{ min_brightness + (bright_step * steps_to_now) | round(0, 'ceil') }} mireds: "{{ max_mireds - (mireds_step * steps_to_now) }}" - delay: seconds: "{{ individual_step }}" - if: - condition: template value_template: "{{ is_state(target_light, 'on') }}" then: - service: light.turn_on data: brightness: "{{ brightness }}" target: entity_id: "{{ target_light }}" - if: - condition: and conditions: - condition: template value_template: "{{ light_timeout != 0 }}" - condition: template value_template: "{{ is_state(target_light, 'on') }}" then: - delay: minutes: "{{ light_timeout }}" - service: light.turn_on data: brightness: "{{ min_brightness }}" target: entity_id: "{{ target_light }}" - service: light.turn_off data: {} target: entity_id: "{{ target_light }}" description: Turn on lamps brighter based on wake time fields: min_mireds: description: Minimum mireds value. This is the end value - most white selector: color_temp: null required: true default: 200 name: Min Mireds example: 200 max_mireds_selector: description: >- Maximum mireds value. This is the start value. If the light is on the current value from the state of the light will be used and this will be ignored. example: 400 selector: color_temp: null default: 400 required: true name: Max Mireds max_brightness_pct: description: Maximum brightness in percent. example: 80 selector: number: min: 1 max: 100 default: 80 required: true name: Max brightness alarm_length: description: >- This is the start to finish time. Take this into account when setting up the automation this script is called by. example: 10 selector: number: min: 1 max: 60 default: 10 required: true name: Alarm Length steps_per_minute: description: How many steps per minute example: 4 selector: number: min: 1 max: 12 default: 12 name: Steps Per minute required: true target_light: description: A single light or group example: light.master_lamp selector: entity: filter: domain: light name: Target Light required: true light_timeout: description: >- Minutes to delay after Max Brightness has been reached to turn the light back off. Value of 0 disables the timeout example: 5 selector: number: min: 0 max: 60 default: 5 name: Light Timeout required: true variables: steps: "{{ alarm_length * steps_per_minute }}" min_brightness: |- {% if state_attr(target_light, 'brightness') == None %} 3 {% else %} {{ state_attr(target_light, 'brightness') }} {% endif %} max_brightness: "{{ max_brightness_pct * 2.55 }}" max_mireds: |- {% if state_attr(target_light, 'color_temp') == None %} {{ max_mireds_selector }} {% else %} {{ state_attr(target_light, 'color_temp') }} {% endif %} mireds_step: "{{ (max_mireds - min_mireds) / steps }}" bright_step: "{{ (max_brightness - min_brightness) / steps }}" start_time: "{{ as_timestamp(now()) }}" individual_step: "{{ 60 / steps_per_minute }}" mode: parallel ```
bulb info ``` Firmware: 1.0.021 Up-to-date Model: TRADFRI bulb E27 CWS 806lm Product ID: LED1924G9 Serial number: F082C0FFFE3DE067 Manufacturer: IKEA of Sweden ```
sanjoyg commented 8 months ago

It took some time to get to this. When I look at the log it seems its unable to establish connection with the hub

snrnats commented 8 months ago

Does dirigera throttle requests or could it be issue with my local network?

sanjoyg commented 8 months ago

There is no throttle in this code or the downstream library. Definitely looks like local network issue