How often are triggers checked, and can the frequency be changed?

Hi all,

I have several automations, the trigger for each is whether my PV/solar output has been at least x kW for 10 minutes, with some conditions, and an action to turn my heat pump on to produce hot water.

The problem I have is that the trigger value seems to be checked very infrequently, approximately once per hour, sometimes once in 2 hours, though I can see that the PV output has been well above the trigger level for much longer than 10 minutes.

My question is, how often will a trigger be checked? It doesn’t seem to happen on PV output value change, as that happens all the time. What’s the default period, and can it be changed? I’ve checked everywhere but can’t seem to find an answer.

Thanks for your help.

Numeric triggers only trigger when it was previously below x and then above x for 10 minutes. So if you’re above x and move further above x, that’s not going to trigger because you never went below x to begin with.

Caveat: I am not a developer or CS professional…

My understanding is that triggers are never checked, per se. Triggers create a listener on the event bus so that whenever events that meet the criteria are posted to the bus, the trigger it is fired. There is no repetitive polling of entities’ states.

@petro
Thank you for your reply. In this case, in the mornings, the PV output starts at 0 and climbs to above the trigger value (for 10 minutes), but the trigger is not ‘pulled’ until some later time. That’s the part I don’t understand. Though your information was useful, thank you.

are you using a numeric state trigger?

Can you please post the automation trace for the last time it was triggered?

Use the download trace option and paste it here correctly formatted for the forum.

You might want to show the history of the sensor from the PV. Maybe this sensor is sending some “off” or “below x KW” values, just for a few milliseconds, so the “condition” to be above x KW for ten minutes is reset in between. :slight_smile:

Yes, here it is:

alias: Heat water while the sun shines, level 4
description: >-
  When solar is producing between 1.5 kW and 5.5 kW for at least 10 mins and
  water tank temp is < 58 °C and battery SoC is > 90%, set DHW target temp to 64
  °C and force DHW and set quiet mode to off
trigger:
  - platform: numeric_state
    entity_id: sensor.inverter_input_power
    for:
      hours: 0
      minutes: 10
      seconds: 0
    above: 1500
    below: 5500
condition:
  - type: is_temperature
    condition: device
    device_id: 5146f5c31651abb30cdec21b28d85838
    entity_id: 61d9b2152c9c77348139394701a4a822
    domain: sensor
    below: 58
  - condition: numeric_state
    entity_id: sensor.battery_state_of_capacity
    above: 90
action:
  - type: turn_on
    device_id: 5146f5c31651abb30cdec21b28d85838
    entity_id: a5cf0afd27214ecf8de5a48fbc255f4d
    domain: switch
  - type: turn_on
    device_id: 5146f5c31651abb30cdec21b28d85838
    entity_id: 9a3b39024483d0512994ba6ae4243083
    domain: switch
  - device_id: 5146f5c31651abb30cdec21b28d85838
    domain: number
    entity_id: 8c5b97bd43e6e7688e1c4a0ff676c388
    type: set_value
    value: 64
  - device_id: 5146f5c31651abb30cdec21b28d85838
    domain: select
    entity_id: d9016c9419c55e0ee4a4b1e07595aac0
    type: select_option
    option: "Off"
  - service: notify.pushover
    data:
      message: >-
        When solar is producing between 1.5 kW and 5.5 kW for at least 10 mins
        and water tank temp is < 58 °C and battery SoC is > 90%, set DHW target
        temp to 64 °C and force DHW and set quiet mode to off


        Input power from PV {{states("sensor.inverter_input_power") }} W

        Tank temp {{states("sensor.panasonic_heat_pump_main_dhw_temp") }} °C

        Battery SoC {{states("sensor.battery_state_of_capacity") }}%
      title: "Automation triggered: Heat water while the sun shines, level 4"
mode: single

Sure, here’s the last trace:

{
  "trace": {
    "last_step": "condition/0/entity_id/0",
    "run_id": "4b67a45a56947a4f29eddbd0a1dc0ff1",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2023-08-16T14:03:40.746542+00:00",
      "finish": "2023-08-16T14:03:40.747226+00:00"
    },
    "domain": "automation",
    "item_id": "1691882354648",
    "trigger": "numeric state of sensor.inverter_input_power",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-08-16T14:03:40.746770+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.heat_water_while_the_sun_shines_level_4",
              "state": "on",
              "attributes": {
                "id": "1691882354648",
                "last_triggered": "2023-08-16T11:24:36.802088+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Heat water while the sun shines, level 4"
              },
              "last_changed": "2023-08-15T16:21:24.625933+00:00",
              "last_updated": "2023-08-16T11:24:37.639967+00:00",
              "context": {
                "id": "01H7Z1E9200RXG6E576HEC2DYN",
                "parent_id": "01H7Z0VZ3KJJ01AAHRCM084F86",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "numeric_state",
              "entity_id": "sensor.inverter_input_power",
              "below": 5500,
              "above": 1500,
              "from_state": {
                "entity_id": "sensor.inverter_input_power",
                "state": "1457",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "W",
                  "device_class": "power",
                  "friendly_name": "Input power (from PV)"
                },
                "last_changed": "2023-08-16T13:53:06.161582+00:00",
                "last_updated": "2023-08-16T13:53:06.161582+00:00",
                "context": {
                  "id": "01H7Z9Y5KH79F612C8N0T9RPZ7",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.inverter_input_power",
                "state": "1569",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "W",
                  "device_class": "power",
                  "friendly_name": "Input power (from PV)"
                },
                "last_changed": "2023-08-16T13:53:40.740636+00:00",
                "last_updated": "2023-08-16T13:53:40.740636+00:00",
                "context": {
                  "id": "01H7Z9Z7C45YEXWAXR1XZRTR2V",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": {
                "__type": "<class 'datetime.timedelta'>",
                "total_seconds": 600
              },
              "description": "numeric state of sensor.inverter_input_power"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2023-08-16T14:03:40.746895+00:00",
          "result": {
            "result": false
          }
        },
        {
          "path": "condition/0",
          "timestamp": "2023-08-16T14:03:40.746967+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/entity_id/0": [
        {
          "path": "condition/0/entity_id/0",
          "timestamp": "2023-08-16T14:03:40.747039+00:00",
          "result": {
            "result": false,
            "state": 60,
            "wanted_state_below": 58
          }
        }
      ]
    },
    "config": {
      "id": "1691882354648",
      "alias": "Heat water while the sun shines, level 4",
      "description": "When solar is producing between 1.5 kW and 5.5 kW for at least 10 mins and water tank temp is < 58 °C and battery SoC is > 90%, set DHW target temp to 64 °C and force DHW and set quiet mode to off",
      "trigger": [
        {
          "platform": "numeric_state",
          "entity_id": "sensor.inverter_input_power",
          "for": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0
          },
          "above": 1500,
          "below": 5500
        }
      ],
      "condition": [
        {
          "type": "is_temperature",
          "condition": "device",
          "device_id": "5146f5c31651abb30cdec21b28d85838",
          "entity_id": "61d9b2152c9c77348139394701a4a822",
          "domain": "sensor",
          "below": 58
        },
        {
          "condition": "numeric_state",
          "entity_id": "sensor.battery_state_of_capacity",
          "above": 90
        }
      ],
      "action": [
        {
          "type": "turn_on",
          "device_id": "5146f5c31651abb30cdec21b28d85838",
          "entity_id": "a5cf0afd27214ecf8de5a48fbc255f4d",
          "domain": "switch"
        },
        {
          "type": "turn_on",
          "device_id": "5146f5c31651abb30cdec21b28d85838",
          "entity_id": "9a3b39024483d0512994ba6ae4243083",
          "domain": "switch"
        },
        {
          "device_id": "5146f5c31651abb30cdec21b28d85838",
          "domain": "number",
          "entity_id": "8c5b97bd43e6e7688e1c4a0ff676c388",
          "type": "set_value",
          "value": 64
        },
        {
          "device_id": "5146f5c31651abb30cdec21b28d85838",
          "domain": "select",
          "entity_id": "d9016c9419c55e0ee4a4b1e07595aac0",
          "type": "select_option",
          "option": "Off"
        },
        {
          "service": "notify.pushover",
          "data": {
            "message": "When solar is producing between 1.5 kW and 5.5 kW for at least 10 mins and water tank temp is < 58 °C and battery SoC is > 90%, set DHW target temp to 64 °C and force DHW and set quiet mode to off\n\nInput power from PV {{states(\"sensor.inverter_input_power\") }} W\nTank temp {{states(\"sensor.panasonic_heat_pump_main_dhw_temp\") }} °C\nBattery SoC {{states(\"sensor.battery_state_of_capacity\") }}%",
            "title": "Automation triggered: Heat water while the sun shines, level 4"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01H7ZAHHAAAJGZH1QQZ9Y0C6TH",
      "parent_id": "01H7Z9Z7C45YEXWAXR1XZRTR2V",
      "user_id": null
    }
  },
  "logbookEntries": []
}
1 Like

Thanks, I downloaded a CSV of all of the sensor values but they were all in the right range. Thanks for the suggestion

Well in that case it stopped at this condition:

  - type: is_temperature
    condition: device
    device_id: 5146f5c31651abb30cdec21b28d85838
    entity_id: 61d9b2152c9c77348139394701a4a822
    domain: sensor
    below: 58

That was my assumption, but then I thought I must be wrong because the automations didn’t work as I expected… Thanks for your reply

It’s most likely that your conditions are delaying the actions. Check their states around the time you expected it to trigger too.

Thanks to everyone who replied, and sorry for my late response. I’m not quite sure why, but things seems to be working again now. I guess it was an error somewhere on my part, just not sure where. Thanks again

If the automation is unchanged it will still not always do as you wish. There are three things that can happen to make all conditions true:

  1. When solar is producing between 1.5 kW and 5.5 kW for 10 mins without interruption (and 2 and 3 are already true)
  2. when water tank temp reaches below 58 °C (and 1 and 3 are already true)
  3. When the battery SoC reaches 90% (and 1 and 2 are already true).

That means you need a trigger for each of these 3 events, and also conditions for all three things you need to be true.

In its current form, only the first situation, 10 mins after solar production is in range, while the other conditions are already true, will perform the actions. The other situations (when the two conditions are not yet met) will not result in an action.