Strange Behaviour in Automation

Hi, Anybody know what could be causing my automation to turn on then immediately after turn off my switch?

I have an automation that turns on a van charger (working ok) and should turn off a blocking relay for a hot tub when the electricity tariff switches to off peak and vice versa for on peak.

Screenshot of the traces below as well as the automation config (note I actually setup automation via the GUI but easier to share code).

Thanks in advanvce.

id: '1735942837569'
alias: Octopus Low Tariff Action
description: Activate Hot Tub Blocking Relay when not on low Tarif rate
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.octopus_energy_electricity_24e8051697_1411979871000_current_rate
    above: 0.08
    id: Peak Rate
  - trigger: numeric_state
    entity_id:
      - sensor.octopus_energy_electricity_24e8051697_1411979871000_current_rate
    below: 0.08
    id: Off Peak
conditions: []
actions:
  - if:
      - condition: trigger
        id:
          - Off Peak
    then:
      - type: turn_off
        device_id: 820302ec2f4c7b3b9c04e21d2db3dc69
        entity_id: 4c19f717f3655b0cc50ac1e64b35601e
        domain: switch
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.switch_16amcb_vancharger
    else:
      - if:
          - condition: trigger
            id:
              - Peak Rate
        then:
          - type: turn_on
            device_id: 820302ec2f4c7b3b9c04e21d2db3dc69
            entity_id: 4c19f717f3655b0cc50ac1e64b35601e
            domain: switch
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - switch.switch_16amcb_vancharger
mode: single

Maybe because that is what your asking it to do. I assume the first action

device_id: 820302ec2f4c7b3b9c04e21d2db3dc69

Is the van charger? If so it is turned off and then on.

Try to always use entities rather than devices in automation’s as not only does it make it easier to debug but generally works better.

Thankyou for your reply. Below is a screenshot of the automation in the GUI where all seems ok!!?? I will change it from the device to the entity though to see if it helps at all.

my understanding with the

below: 0.08

must be below the number

above: 0.08

must be above it

there fore if it is 0.08 it going to do nothing

the actual value comes in at 0.07; I could change the threshold to 0.1 to give some extra margin for rounding but I don’t think this is the problem as the traces indicate that “Peak Rate” and “Off Peak” triggers are firing off ok…