substitutions: 
  device_name: nmcuvoletcuisine2
  friendly_name: volet_cuisine_2
  project_name: "volet.cuisine_2"
  project_version: "1.0"
  shortname: V_C_02
  adresse_ip: 10.0.2.79
  op_duration: 22s
  cl_duration: 22s

packages:
  ## include wifi networks, manual_ip, ap
  wifi: !include common/wifi.yaml
  #include logger with syslog, api, ota, webserver, captive portal
  device_base: !include common/device_base.yaml

esphome:
  name: "${device_name}"
  friendly_name: ${friendly_name}
  project:
    name: "${project_name}"
    version: "${project_version}"
  includes:
    - my_remote_fonction.h

esp8266:
  board: nodemcuv2

 
#aller dans le dossier config et modifier le fichier .h en consequence


 
status_led:
  pin: GPIO2
 
binary_sensor:
#include status
  - <<: !include common/generic_binarysensor.yaml

text_sensor:
#include wifi info : ipaddress ssid
  - <<: !include common/generic_textsensor.yaml
  - platform: template
    name: "Pin"
    icon: "mdi:account-question"
    lambda: |-
      return {"D1:up D2:down D5:stop"};
    update_interval: 60000s
    disabled_by_default: true

sensor:
#include uptime et wifisignal
  - <<: !include common/generic_sensor.yaml
 
    
output:

# D1 :up
# D2 : down
# D5 : stop
  - platform: gpio
    pin: D1
    id: button_UP
    inverted: true
  - platform: gpio
    pin: D2
    id: button_DOWN
    inverted: true
  - platform: gpio
    pin: D5
    id: button_STOP
    inverted: true
    
  - platform: custom
    type: binary
    lambda: |-
      auto associer_binary_output = new AssocierBinaryOutput();
      App.register_component(associer_binary_output);
      return {associer_binary_output};

    outputs:
      id: associer_binary
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto dissocier_binary_output = new DissocierBinaryOutput();
  #     App.register_component(dissocier_binary_output);
  #     return {dissocier_binary_output};

  #   outputs:
  #     id: dissocier_binary
 
 
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto set_bottom_limit_binary_output = new Set_bottom_limitBinaryOutput();
  #     App.register_component(set_bottom_limit_binary_output);
  #     return {set_bottom_limit_binary_output};

  #   outputs:
  #     id: set_bottom_limit_binary
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto set_top_limit_binary_output = new Set_top_limitBinaryOutput();
  #     App.register_component(set_top_limit_binary_output);
  #     return {set_top_limit_binary_output};

  #   outputs:
  #     id: set_top_limit_binary
 
 
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto delete_bottom_limit_binary_output = new Delete_bottom_limitBinaryOutput();
  #     App.register_component(delete_bottom_limit_binary_output);
  #     return {delete_bottom_limit_binary_output};

  #   outputs:
  #     id: delete_bottom_limit_binary
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto delete_top_limit_binary_output = new Delete_top_limitBinaryOutput();
  #     App.register_component(delete_top_limit_binary_output);
  #     return {delete_top_limit_binary_output};

  #   outputs:
  #     id: delete_top_limit_binary
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto set_third_limit_binary_output = new Set_third_limitBinaryOutput();
  #     App.register_component(set_third_limit_binary_output);
  #     return {set_third_limit_binary_output};

  #   outputs:
  #     id: set_third_limit_binary
 
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto goto_third_limit_binary_output = new Goto_third_limitBinaryOutput();
  #     App.register_component(goto_third_limit_binary_output);
  #     return {goto_third_limit_binary_output};

  #   outputs:
  #     id: goto_third_limit_binary
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto mode_step_on_binary_output = new Mode_step_onBinaryOutput();
  #     App.register_component(mode_step_on_binary_output);
  #     return {mode_step_on_binary_output};

  #   outputs:
  #     id: mode_step_on_binary_output
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto mode_step_off_binary_output = new Mode_step_offBinaryOutput();
  #     App.register_component(mode_step_off_binary_output);
  #     return {mode_step_off_binary_output};

  #   outputs:
  #     id: mode_step_off_binary_output
 
      
  # - platform: custom
  #   type: binary
  #   lambda: |-
  #     auto change_dir_motor_binary_output = new Change_dir_motorBinaryOutput();
  #     App.register_component(change_dir_motor_binary_output);
  #     return {change_dir_motor_binary_output};

  #   outputs:
  #     id: change_dir_motor_binary_output
  
switch:
#include restart
  - <<: !include common/generic_switch.yaml

  - platform: template
    name: UP ${shortname} 
    icon: "mdi:arrow-up-circle"
    turn_on_action:
    - output.turn_on: button_UP
    - delay: 300ms
    - output.turn_off: button_UP
  - platform: template
    name: DOWN ${shortname}  
    icon: "mdi:arrow-down-circle"
    turn_on_action:
    - output.turn_on: button_DOWN
    - delay: 300ms
    - output.turn_off: button_DOWN
  - platform: template
    name: STOP ${shortname}  
    icon: "mdi:stop-circle"
    turn_on_action:
    - output.turn_on: button_STOP
    - delay: 300ms
    - output.turn_off: button_STOP

  - platform: template
    name: Associer ${device_name} 
    icon: "mdi:gesture-tap-button"
    turn_on_action:
    - output.turn_on: associer_binary
    turn_off_action:
    - output.turn_off: associer_binary
    disabled_by_default: true
    
  # - platform: template
  #   name: Dissocier  ${device_name} 
  #   icon: "mdi:delete"
  #   turn_on_action:
  #   - output.turn_on: dissocier_binary
  #   turn_off_action:
  #   - output.turn_off: dissocier_binary
  #   disabled_by_default: true
 
  # - platform: template
  #   name: Set top limit ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: set_top_limit_binary
  #   turn_off_action:
  #   - output.turn_off: set_top_limit_binary
  #   disabled_by_default: true

  # - platform: template
  #   name: Set bottom limit  ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: set_bottom_limit_binary
  #   turn_off_action:
  #   - output.turn_off: set_bottom_limit_binary
  #   disabled_by_default: true
 
    
  # - platform: template
  #   name: Delete top limit ${device_name} 
  #   icon: "mdi:delete"
  #   turn_on_action:
  #   - output.turn_on: delete_top_limit_binary
  #   turn_off_action:
  #   - output.turn_off: delete_top_limit_binary
  #   disabled_by_default: true

  # - platform: template
  #   name: Delete bottom limit  ${device_name} 
  #   icon: "mdi:delete"
  #   turn_on_action:
  #   - output.turn_on: delete_bottom_limit_binary
  #   turn_off_action:
  #   - output.turn_off: delete_bottom_limit_binary
  #   disabled_by_default: true
 

  # - platform: template
  #   name: set third limit  ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: set_third_limit_binary
  #   turn_off_action:
  #   - output.turn_off: set_third_limit_binary
  #   disabled_by_default: true
 
    
  # - platform: template
  #   name: Goto third limit ${device_name} 
  #   icon: "mdi:blinds"
  #   turn_on_action:
  #   - output.turn_on: goto_third_limit_binary
  #   turn_off_action:
  #   - output.turn_off: goto_third_limit_binary
  #   disabled_by_default: true

  # - platform: template
  #   name: Mode step on  ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: mode_step_on_binary_output
  #   turn_off_action:
  #   - output.turn_off: mode_step_on_binary_output
  #   disabled_by_default: true
    
  # - platform: template
  #   name: Mmode step off  ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: mode_step_off_binary_output
  #   turn_off_action:
  #   - output.turn_off: mode_step_off_binary_output
  #   disabled_by_default: true

  # - platform: template
  #   name: Change dir motor ${device_name} 
  #   icon: "mdi:gesture-tap-button"
  #   turn_on_action:
  #   - output.turn_on: change_dir_motor_binary_output
  #   turn_off_action:
  #   - output.turn_off: change_dir_motor_binary_output
  #   disabled_by_default: true
 
    
cover:
  - platform: time_based
    name:  ${friendly_name} 
    open_action:
      - output.turn_on: button_UP
      - delay: 300ms
      - output.turn_off: button_UP
    open_duration: ${op_duration}
    close_action:
      - output.turn_on: button_DOWN
      - delay: 300ms
      - output.turn_off: button_DOWN
    close_duration: ${cl_duration}
    stop_action:
      - output.turn_on: button_STOP
      - delay: 300ms
      - output.turn_off: button_STOP
 
 
 
 
 
 
 
