Closed snrnats closed 7 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
Does dirigera throttle requests or could it be issue with my local network?
There is no throttle in this code or the downstream library. Definitely looks like local network issue
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.
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 ```