Timer sous forme de script

Salut :wave:,

Merci de participer sur le forum :+1:

:information_source: Lorsque tu postes du code (flow, yaml, js, etc.), utilise les blocs codes :computer:

Pour cela, il te suffit de cliquer sur l’outil dédié et de coller ton code à l’endroit indiqué :

L’équipe HACF.

:hacf:

AUTOMATION
  alias: Synchroniser les timers
  description: Permet de synchroniser tous les timers arrossage suivant le timer global
  trigger:
  - platform: state
    entity_id: input_number.timer_arrosage_global_serre
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id:
      - input_number.timer_arrosage_serre_g
      - input_number.timer_arrosage_serre_d
      - input_number.timer_arrosage_serre_m
      - input_number.timer_arrosage_serre_deux
    data:
      value: '{{states(''input_number.timer_arrosage_global_serre'')|int}}'
  mode: single
- id: '1623853345540'
  alias: Démarrage de Timer Serre G - D - M - Deux
  description: Permet de démarrer les timers Serre G - D - M - Deux sur le passage
    à vrai du booléen correspondant
  trigger:
  - platform: state
    entity_id: input_boolean.arrosage_global_serre
    to: 'on'
  condition: []
  action:
  - service: switch.turn_on
    target:
      entity_id: 
      - switch.knx_arrosage_serre_g
      - switch.knx_arrosage_serre_d
      - switch.knx_arrosage_serre_milieu
      - switch.knx_arrosage_serre_deux
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.arrosage_global_serre
  - service: input_number.set_value
    target:
      entity_id:
      - input_number.timer_arrosage_serre_g
      - input_number.timer_arrosage_serre_d
      - input_number.timer_arrosage_serre_m
      - input_number.timer_arrosage_serre_deux
      - timer.arrosage_global_serre
    data:
      value: '{{states(''input_number.timer_arrosage_global_serre'')|int}}'
  - service: timer.start
    data:
      duration: '{{states(''input_number.timer_arrosage_global_serre'')|int * 60}}'
    target:
      entity_id:
      - timer.arrosage_serre_gauche
      - timer.arrosage_serre_droite
      - timer.arrosage_serre_milieu
      - timer.arrosage_serre_deux
      - timer.arrosage_global_serre
  mode: single
- id: '1623942645906'
  alias: Démarrage de Timer Serre G
  description: Permet de démarrer le timer serre milieu sur le passage à vrai du switch
    KNX correspondant
  trigger:
  - platform: state
    entity_id: input_boolean.arrosage_serre_g
    to: 'on'
  condition: []
  action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.arrosage_serre_g
  - service: timer.start
    data:
      duration: '{{ states(''input_number.timer_arrosage_serre_g'') | int * 60 }}'
    target:
      entity_id: timer.arrosage_serre_gauche
  - service: switch.turn_on
    target:
      entity_id: switch.knx_arrosage_serre_g
  mode: single
- id: stop arrosage serre gauche
  alias: Stop arrosage serre gauche
  trigger:
  - event_data:
      entity_id: timer.arrosage_serre_gauche
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: switch.knx_arrosage_serre_g
    service: switch.turn_off
  mode: single
- id: '1623942744415'
  alias: Démarrage de Timer Serre D
  description: Permet de démarrer le timer serre milieu sur le passage à vrai du switch
    KNX correspondant
  trigger:
  - platform: state
    entity_id: input_boolean.arrosage_serre_d
    to: 'on'
  condition: []
  action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.arrosage_serre_d
  - service: timer.start
    data:
      duration: '{{ states(''input_number.timer_arrosage_serre_d'') | int * 60 }}'
    target:
      entity_id: timer.arrosage_serre_droite
  - service: switch.turn_on
    target:
      entity_id: switch.knx_arrosage_serre_d
  mode: single
- id: stop arrosage serre droite
  alias: Stop arrosage serre droite
  trigger:
  - event_data:
      entity_id: timer.arrosage_serre_droite
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: switch.knx_arrosage_serre_d
    service: switch.turn_off
  mode: single
- id: '1623943003398'
  alias: Démarrage de Timer Serre Milieu
  description: Permet de démarrer le timer serre milieu sur le passage à vrai du switch
    KNX correspondant
  trigger:
  - platform: state
    entity_id: input_boolean.arrosage_serre_m
    to: 'on'
  condition: []
  action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.arrosage_serre_m
  - service: timer.start
    data:
      duration: '{{ states(''input_number.timer_arrosage_serre_m'') | int * 60 }}'
    target:
      entity_id: timer.arrosage_serre_milieu
  - service: switch.turn_on
    target:
      entity_id: switch.knx_arrosage_serre_milieu
  mode: single
- id: stop arrosage serre milieu
  alias: Stop arrosage serre milieu
  trigger:
  - event_data:
      entity_id: timer.arrosage_serre_milieu
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: switch.knx_arrosage_serre_milieu
    service: switch.turn_off
  mode: single
- id: '1623943036295'
  alias: Démarrage de Timer Serre Deux
  description: Permet de démarrer le timer serre milieu sur le passage à vrai du switch
    KNX correspondant
  trigger:
  - platform: state
    entity_id: input_boolean.arrosage_serre_deux
    to: 'on'
  condition: []
  action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.arrosage_serre_deux
  - service: timer.start
    data:
      duration: '{{ states(''input_number.timer_arrosage_serre_deux'') | int * 60
        }}'
    target:
      entity_id: timer.arrosage_serre_deux
  - service: switch.turn_on
    target:
      entity_id: switch.knx_arrosage_serre_deux
  mode: single
- id: stop arrosage serre deux
  alias: Stop arrosage serre deux
  trigger:
  - event_data:
      entity_id: timer.arrosage_serre_deux
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: switch.knx_arrosage_serre_deux
    service: switch.turn_off
  mode: single

Merci @foxbru
peux-tu ajouter ta card lovelace elle était fort sympathique et intuitif
merci d’avance :slight_smile:

Voici
Peux-tu me faire un retour si ok ? Merci

type: entities
entities:
  - entity: switch.knx_arrosage_serre_g
  - entity: switch.knx_arrosage_serre_d
  - entity: switch.knx_arrosage_serre_milieu
  - entity: switch.knx_arrosage_serre_deux
  - type: section
  - entity: input_number.timer_arrosage_global_serre
    name: Reglage durée
    icon: mdi:timer-sand
  - entity: timer.arrosage_global_serre
    name: Durée restante
  - entity: group.arrosage_serres
header:
  type: picture
  image: http://192.xxx.xxx.xxx:xxxx/local/arrosage.jpg
  tap_action:
    action: none
  hold_action:
    action: none
footer:
  type: buttons
  entities:
    - entity: input_boolean.arrosage_global_serre
      icon: mdi:play
      name: Lancer l'arrosage
state_color: true

1 « J'aime »

Merci encore @foxbru
C’est parfait :slight_smile: