Automatisation not working

Hello,

I would like this automation to make running the heater every three hours for 2 hours.
It doesn’t seems to take into consideration the two hors work.
When ON and Off it has to send a notification.
Is there any mistake ??

Thx

alias: Car Heater
description: chauffage moteur Land
triggers:
  - trigger: time_pattern
    hours: /3
    minutes: "00"
    seconds: "00"
conditions: []
actions:
  - action: switch.turn_on
    target:
      entity_id: switch.innr_sp240_recharge_switch_2
    data: {}
  - action: notify.mobile_app_sm_f721b
    metadata: {}
    data:
      title: Recharge On
      message: Chauffage Land On
  - delay:
      hours: "02"
      minutes: "00"
      seconds: "00"
      milliseconds: "00"
  - action: switch.turn_off
    target:
      entity_id: switch.innr_sp240_recharge_switch_2
    data: {}
  - action: notify.mobile_app_sm_f721b
    metadata: {}
    data:
      title: Recharge off
      message: Chauffage Land Off
mode: single

Waiting in automations for that long is not advisable. Try this instead:

alias: Car Heater On
description: chauffage moteur Land
triggers:
  - trigger: time_pattern
    hours: '/3'
    minutes: 0
    seconds: 0
conditions: []
actions:
  - action: switch.turn_on
    target:
      entity_id: switch.innr_sp240_recharge_switch_2
    data: {}
  - action: notify.mobile_app_sm_f721b
    metadata: {}
    data:
      title: Recharge On
      message: Chauffage Land On
alias: Car Heater Off
description: chauffage moteur Land
triggers:
  - trigger: state
    entity_id: switch.innr_sp240_recharge_switch_2
    to: 'on'
    for:
      hours: 2
conditions: []
actions:
  - action: switch.turn_off
    target:
      entity_id: switch.innr_sp240_recharge_switch_2
    data: {}
  - action: notify.mobile_app_sm_f721b
    metadata: {}
    data:
      title: Recharge Off
      message: Chauffage Land Off

Did I understood well ?? These are two different automation, the first one “Recharge on” and the second one “Recharge off” … They are both independently working but I need the recharge to be off when > 2h …

First automation turns the switch on every 3 hours.

Second automation turns the switch off when it has been on for 2 hours.

Result: every three hours switch turns on for two hours.

Is that not what you wanted?

I thought OP meant they wanted a 5 hour cycle… 3 off, 2 on.

If so, that’s an easy fix:

triggers:
  - trigger: time_pattern
    hours: '/5'
    minutes: 0
    seconds: 0