Trigger: null - Automation

I have created a helper (Binary sensor) to check if the Octopus agile electric rate is cheaper than running the oil boiler. Then created an automation to turn then immersions on when it is.

This automation is duplicated with one difference so it can work in conjunction with another Automation that charges the solar batteries.

It triggers every time the Octopus Agile rate changes and checks some conditions.

The bit I don’t get is there is a condition to check the binary sensor is ‘detected’ that is met, then when the automation turns the immersions on I have placed a ‘wait for trigger’ to look for the binary sensor to be ‘clear’ but this part is shows in logs as ‘null’ and the automation ends immediately.

Does anyone know why?

alias: Immersion - Elec vs Oil per/kwh - TOU On
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.octopus_energy_current_rate
    attribute: applicable_rates
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition:
  - condition: state
    entity_id: binary_sensor.import_vs_oil_cost_per_kwh_live_0_02p
    state: "on"
  - condition: state
    entity_id: binary_sensor.octopus_energy_target_5hr_lowest_import
    state: "on"
  - condition: state
    entity_id: binary_sensor.octopus_energy_target_octopus_twelve_hour_min_target
    state: "on"
action:
  - service: notify.mobile_app_dan_s_phone
    data:
      message: Immersion Trigger - TOU On - Start
  - type: turn_on
    device_id: cd47a113b5f9c4c423beff1afa3b7a54
    entity_id: 2eca3ce8a3fdd572334cf1955ab618cf
    domain: switch
  - type: turn_on
    device_id: d3bbfaa16c0893c7d1bd00f91d301a65
    entity_id: 0dd48a897da98abde869b31cf6116ff4
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.import_vs_oil_cost_per_kwh_live_0_02p
        to: "off"
        from: "on"
    continue_on_timeout: false
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: cd47a113b5f9c4c423beff1afa3b7a54
    entity_id: 2eca3ce8a3fdd572334cf1955ab618cf
    domain: switch
  - type: turn_off
    device_id: d3bbfaa16c0893c7d1bd00f91d301a65
    entity_id: 0dd48a897da98abde869b31cf6116ff4
    domain: switch
  - service: notify.mobile_app_dan_s_phone
    data:
      message: Immersion Trigger - TOU On - End
mode: single
trace:
  stored_traces: 48

You specified a timeout of 0ms. So the wait for trigger stops immediately.

Hi Tom,

Thanks for the reply. Honestly I think that I have toggled the ‘Continue on timeout’ toggle on and off when testing. I think it was on when first set it up.

So you are saying the timeout option needs to be on with no timeout in secs specified to basically just make it redundant?

I’m saying you need to specify a time, or not specify any time. Do not specify 0s. Or this happens:

With continue on, the wait will continue after 0s (i.e. immediately).

With continue off the wait will exit the automation after 0s (i.e. immediately).

It’s now working Tom

I had to remove the ‘0’s and save everything again as you said and toggle off’ ‘continue on timeout’

The odd part is when you create the wait for trigger action from fresh it fills the '0’s in by default. So I thought just not touching them and leaving them as 0’s would suffice.

I realise this is not the case now.

Dam, I forgot I set a timeout also of 28mins

The automation ended on the timeout not the trigger

Executed: 29 October 2023 at 07:01:37
Result:
wait:
remaining: 0
trigger: null
timeout: true

The trigger is the binary sensor in the conditions

condition:
  - condition: state
    entity_id: binary_sensor.import_vs_oil_cost_per_kwh_live_0_02p
    state: "on"
  - condition: state
    entity_id: binary_sensor.octopus_energy_target_5hr_lowest_import
    state: "on"
  - condition: state
    entity_id: binary_sensor.octopus_energy_target_octopus_twelve_hour_min_target
    state: "on"

Ok its now working.

I finally paid more attention to what I had done and it tested out as working.

Many thanks.