Bonjour,
J’essaie depuis plusieurs jours de mettre en place un script et des automatisations pour gérer l’ouverture, l’arrêt et la fermeture de mon portail qui est piloté par un relai zigbee.
Je dois m’y prendre comme une truffe car rien ne fonctionne comme souhaité.
J’ai créé deux entrées (input_number), une entrée avec 4 valeurs possibles : 0, 1, 2 ou 3. La valeur 0 correspondant au portail fermé, la valeur 1 au portail ouvert, la valeur 3 au portail en mouvement et la valeur 4 au portail partiellement ouvert. La deuxième entrée a deux valeurs possibles : 0 ou 1, la première valeur correspondant à l’ouverture (sens) et la deuxième à la fermeture. J’ai créé un timer de 25 secondes correspondant grosso modo au temps que met le portail à s’ouvrir ou se fermer.
J’ai sur le portail trois capteurs d’ouverture (un indiquant quand le portail est fermé, un indiquant quand le battant droit du portail est ouvert en grand et un indiquant quand le battant gauche est ouvert en grand.
J’ai 4 automatisations qui définissent la position du portail (et de de l’input_number nommé input_number.portail_position) :
- Portail - Position portail fermé :
alias: Portail - Position portail fermé
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.allee_du_garage_detecteur_de_fermeture_portail_contact
from: "on"
to: "off"
- platform: state
entity_id:
- timer.portail_timer
from: active
to: idle
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value: 0
target:
entity_id: input_number.portail_position
- service: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: timer.cancel
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
mode: single
- Portail - Position portail ouvert :
alias: Portail - Position portail ouvert
description: ""
trigger:
- platform: state
entity_id:
- >-
binary_sensor.allee_du_garage_detecteur_d_ouverture_battant_droit_portail_contact
from: "on"
to: "off"
- platform: state
entity_id:
- timer.portail_timer
from: active
to: idle
condition:
- condition: state
entity_id: >-
binary_sensor.allee_du_garage_detecteur_d_ouverture_battant_gauche_portail_contact
state: "off"
action:
- service: input_number.set_value
metadata: {}
data:
value: 1
target:
entity_id: input_number.portail_position
- service: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: timer.cancel
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
mode: single
- Portail - Position portail en mouvement :
alias: Portail - Position portail en mouvement
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.allee_du_garage_detecteur_de_fermeture_portail_contact
from: "off"
to: "on"
- platform: state
entity_id:
- >-
binary_sensor.allee_du_garage_detecteur_d_ouverture_battant_droit_portail_contact
from: "off"
to: "on"
condition:
- condition: state
entity_id: timer.portail_timer
state: active
action:
- service: input_number.set_value
metadata: {}
data:
value: 2
target:
entity_id: input_number.portail_position
mode: single
- Portail - Position portail partiellement ouvert :
alias: Portail - Position portail partiellement ouvert
description: ""
trigger:
- platform: state
entity_id:
- timer.portail_timer
from: active
to: paused
condition:
- condition: state
entity_id: >-
binary_sensor.allee_du_garage_detecteur_d_ouverture_battant_droit_portail_contact
state: "on"
- condition: state
entity_id: >-
binary_sensor.allee_du_garage_detecteur_d_ouverture_battant_gauche_portail_contact
state: "on"
- condition: state
entity_id: binary_sensor.allee_du_garage_detecteur_de_fermeture_portail_contact
state: "on"
action:
- service: input_number.set_value
metadata: {}
data:
value: 3
target:
entity_id: input_number.portail_position
mode: single
Le script utilisé est le suivant :
alias: Allée du garage - Actionner portail
sequence:
- choose:
- conditions:
- condition: numeric_state
entity_id: input_number.portail_position
below: 1
sequence:
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: input_number.set_value
metadata: {}
data:
value: 0
target:
entity_id: input_number.portail_sens
- type: turn_on
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- type: turn_off
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- conditions:
- condition: numeric_state
entity_id: input_number.portail_position
above: 0
below: 2
sequence:
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: input_number.set_value
metadata: {}
data:
value: 1
target:
entity_id: input_number.portail_sens
- type: turn_on
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- type: turn_off
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- conditions:
- condition: numeric_state
entity_id: input_number.portail_position
above: 1
below: 3
sequence:
- service: timer.pause
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- type: turn_on
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- type: turn_off
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- conditions:
- condition: numeric_state
entity_id: input_number.portail_position
above: 2
sequence:
- if:
- condition: numeric_state
entity_id: input_number.portail_sens
below: 1
then:
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: input_number.set_value
metadata: {}
data:
value: 1
target:
entity_id: input_number.portail_sens
- type: turn_on
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- type: turn_off
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
else:
- service: timer.start
metadata: {}
data: {}
target:
entity_id: timer.portail_timer
- service: input_number.set_value
metadata: {}
data:
value: 0
target:
entity_id: input_number.portail_sens
- type: turn_on
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- type: turn_off
device_id: 4bd1068c9b590c3d3b2093b1ddbfd674
entity_id: 8bbe9d33a26c8a37367385e18359c016
domain: switch
mode: single
A des moments, le portail s’arrête en cours d’ouverture ou de fermeture, à d’autres moments, il se ferme complètement puis se rouvre…
Je dois avoir un problème avec les automatisations mais je ne vois pas lequel.
Pour les automatisations Portail - Position portail ouvert et Portail - Position portail fermé, j’ai ajouté en trigger le passage du timer de active à idle car les triggers liés au passage de on à off pour les capteurs d’ouverture ne semblaient pas fonctionner à chaque coup…
Si quelqu’un à une idée de ce qui mer… ça m’aiderait bien. Merci d’avance.