hvorragend / ha-blueprints

Other
32 stars 9 forks source link

How often does the blueprint trigger / what are the actual trigger events? #91

Closed promufa closed 2 months ago

promufa commented 2 months ago

Hi, thanks again for the tons of work you have put in this blueprint and for your helkp with an issue I had previously.

I am having an issue with opening the blinds in the morning. I have set time up early at 5:30 and time up late at 8:30. I have not set brightnes control for the open/close function (only for shading). The open/close is controlled only by the set times (in the blueprint) and sun elevation.

I am not using the blueprint default actions as they were not working reliably for shading with my Shelly relays. Instead I am using the additional actions to set position to 100% or 0%, or for shading drive to eg 30%, delay afew seconds to allow the roller to arrive at the set position and then adjust the tilt by driving the oposite way for a few ms.

For opening in the morning (for some blinds) I have set a condition in the additional actions: "bed sensor" is clear. Now the good part is that the blinds do not open at 5:30 if someone is in bed. Other blinds where the bed condition is not implemented, open normally at the set time. However, after the bed sensor turns "clear" the blinds that depend on this sensor remain closed (even if the time is still between 5:30 and 8:30).

Basically I am trying to understand how often is the automation triggering and checking the bed sensor to decide if it should open the blinds or not. I know I could use the "resident" funstion for this but I do not like the fact that it will force close the blinds at any time during the day if the bed sensor reports "true / occupied".

Let me know if you need any traces etc. I am attaching the config here:

alias: large blinds automation
description: ""
use_blueprint:
  path: hvorragend/cover_control_automation.yaml
  input:
    blind: cover.large_blinds
    auto_options:
      - auto_up_enabled
      - auto_down_enabled
      - auto_shading_enabled
      - auto_sun_enabled
    cover_status_options: cover_helper_enabled
    cover_status_helper: input_text.large_blind_helper
    drive_time: 90
    time_up_early: "05:30:00"
    time_up_early_non_workday: "06:30:00"
    time_up_late: "08:30:00"
    time_up_late_non_workday: "10:30:00"
    time_down_early: "21:30:00"
    time_down_early_non_workday: "22:30:00"
    time_down_late: "22:30:00"
    time_down_late_non_workday: "23:59:59"
    brightness_time_duration: 120
    brightness_down: 600
    position_tolerance: 5
    workday_sensor: binary_sensor.workday_sensor
    shading_position: 45
    shading_brightness_sensor: sensor.average_illuminance
    sun_time_duration: 60
    sun_elevation_up: 3
    sun_elevation_down: -8
    drive_delay_fix: 2
    shading_sun_brightness_start: 650
    shading_sun_brightness_end: 300
    shading_azimuth_start: 150
    shading_azimuth_end: 300
    shading_elevation_min: 20
    shading_min_temperatur1: 18
    shading_forecast_temp: 18
    shading_weather_conditions: []
    ignore_after_manual_config: []
    individual_config:
      - prevent_default_cover_actions
      - allow_shading_multiple_times
    check_config: false
    check_config_debuglevel: info
    shading_min_temperatur2: 18
    shading_waitingtime_start: 120
    auto_shading_start_condition:
      - condition: or
        conditions:
          - condition: numeric_state
            entity_id: sensor.openweathermap_cloud_coverage
            below: 70
            enabled: true
          - condition: numeric_state
            entity_id: sensor.average_illuminance
            above: 700
        enabled: false
      - condition: template
        value_template: "{{ now().month in [4,5,6,7,8,9] }}"
    shading_waitingtime_end: 600
    auto_down_condition:
      - condition: numeric_state
        entity_id: sun.sun
        attribute: elevation
        below: -5
    auto_shading_start_action:
      - if:
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: cover.large_blinds
                attribute: current_position
                above: 60
        then:
          - service: script.shade_large_living
            data: {}
    auto_up_condition:
      - condition: state
        entity_id: binary_sensor.esphome_web_5a3d64_main_bed_sensor
        state: "off"
    auto_shading_end_condition: []
    auto_up_action:
      - service: cover.open_cover
        metadata: {}
        data: {}
        target:
          entity_id: cover.large_blinds
    auto_down_action:
      - delay:
          hours: 0
          minutes: 0
          seconds: 25
          milliseconds: 0
      - service: cover.close_cover
        metadata: {}
        data: {}
        target:
          entity_id: cover.large_blinds
    auto_shading_end_action:
      - service: cover.open_cover
        metadata: {}
        data: {}
        target:
          entity_id: cover.large_blinds
hvorragend commented 2 months ago

You can follow the triggers in the traces and switch back and forth between them.

It is triggered at "Early" and "Late". And when the numeric threshold values are reached or crossed. See note in HA documentation "Numeric State Trigger"

promufa commented 2 months ago

I see thanks for clarifying.

Would it make sense to change the logic a bit, so that it triggers for example every 5 minutes and open / close if time is between "Early" and "Late", or for every change of sun.sun and time is between"Early" and "Late". This would force more frequent testing of any additional conditions and result in the automation being a lot more dynamic and responsive to changes in the house, instead of relying on the two preset times.

crandler commented 2 months ago

@hvorragend idea: maybe you could add an external entity that triggers CCA on update or change?

promufa commented 2 months ago

How would one go about doing this? should i create a new set of triggers (as described above) to control a boolean and use that boolean in the force immediate open / close?_ Just realise the last comment was address to hvorragend and not me, I was confused as to how I could possibly trigger the automation with an external entity

promufa commented 2 months ago

Just for the sake of completeness in the thread, I have managed to get this to work by adding the following as an additional action (with the default actions disabled in the blueprint):

if:
  - condition: state
    entity_id: binary_sensor.esphome_web_5a3d64_main_bed_sensor
    state: "off"
then:
  - service: cover.open_cover
    metadata: {}
    data: {}
    target:
      entity_id: cover.large_blinds
else:
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.esphome_web_5a3d64_main_bed_sensor
        to: "off"
        for:
          hours: 0
          minutes: 1
          seconds: 30
    timeout:
      hours: 5
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: cover.open_cover
    metadata: {}
    data: {}
    target:
      entity_id: cover.large_blinds

With this the bleuprint will trigger at the Blinds up early time and either open the blinds or fall into "wait for trigger" loop that will open the blinds as soon as the occupancy sensor is clear, regardless of what time it is (or 5 hours after the early up time, when the loop times-out)