Guest User

Somfy ESPhome YAML

a guest
Mar 20th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 11.05 KB | None | 0 0
  1. ################## DEFAULT_CONFIG ##################
  2.           Used to shorten code per device          #
  3.                  _device_base.yaml                 #
  4. ################## DEFAULT_CONFIG ##################
  5. esphome:
  6. mqtt:
  7.   broker: !secret mqtt_broker
  8.   username: !secret mqtt_usr
  9.   password: !secret mqtt_pwd
  10.   discovery: false
  11.   discovery_retain: false
  12.   reboot_timeout: 0s
  13.   topic_prefix: ${device_name}
  14.  
  15. logger:
  16. api:
  17.   port: 6053
  18.   reboot_timeout: 5min
  19.   encryption:
  20.     key: !secret api_key
  21.  
  22. wifi:
  23.   ssid: !secret wifi_ssid
  24.   password: !secret wifi_pwd
  25.   reboot_timeout: 5min
  26.   fast_connect: true
  27.   power_save_mode: none
  28.   ap:
  29.     ssid: "${device_name} AP"
  30.     password: !secret fallback_pwd
  31.  
  32. captive_portal:
  33. ota:
  34.   safe_mode: true
  35.   password: !secret ota_pwd
  36.   port: 8266
  37.   id: otap
  38.  
  39. web_server:
  40.   port: 80
  41.   auth:
  42.     username: !secret web_usr
  43.     password: !secret web_pwd
  44.  
  45. button:
  46.   - platform: restart
  47.     name: "${device_name}_restart"
  48. ####################################################
  49.  
  50.  
  51. ################## DEFAULT_CONFIG ##################
  52. packages:                                         #
  53.   device_base: !include _device_base.yaml          #
  54. ################## DEFAULT_CONFIG ##################
  55.  
  56. substitutions:
  57.   device_name: somfy-remotes
  58.   rmte1: 5ch
  59.   rmte2: 1ch
  60.  
  61. esphome:
  62.   name: ${device_name}
  63.   platform: ESP32
  64.   board: nodemcu-32s
  65.  
  66. text_sensor:
  67.   - platform: template
  68.     id: slct_chnl
  69.     name: "Selected Channel"
  70.     update_interval: never
  71.  
  72. script:
  73.   - id: ch_1
  74.     then:
  75.       - while:
  76.           condition:
  77.             or:
  78.               - binary_sensor.is_off: led1
  79.               - binary_sensor.is_on: led2
  80.               - binary_sensor.is_on: led3
  81.               - binary_sensor.is_on: led4
  82.           then:
  83.             - switch.turn_on: slct
  84.             - delay: 250ms
  85.       - text_sensor.template.publish:
  86.           id: slct_chnl
  87.           state: "Channel 1"
  88.  
  89.   - id: ch_2
  90.     then:
  91.       - while:
  92.           condition:
  93.             or:
  94.               - binary_sensor.is_on: led1
  95.               - binary_sensor.is_off: led2
  96.               - binary_sensor.is_on: led3
  97.               - binary_sensor.is_on: led4
  98.           then:
  99.             - switch.turn_on: slct
  100.             - delay: 250ms
  101.       - text_sensor.template.publish:
  102.           id: slct_chnl
  103.           state: "Channel 2"
  104.  
  105.   - id: ch_3
  106.     then:
  107.       - while:
  108.           condition:
  109.             or:
  110.               - binary_sensor.is_on: led1
  111.               - binary_sensor.is_on: led2
  112.               - binary_sensor.is_off: led3
  113.               - binary_sensor.is_on: led4
  114.           then:
  115.             - switch.turn_on: slct
  116.             - delay: 250ms
  117.       - text_sensor.template.publish:
  118.           id: slct_chnl
  119.           state: "Channel 3"
  120.  
  121.   - id: ch_4
  122.     then:
  123.       - while:
  124.           condition:
  125.             or:
  126.               - binary_sensor.is_on: led1
  127.               - binary_sensor.is_on: led2
  128.               - binary_sensor.is_on: led3
  129.               - binary_sensor.is_off: led4
  130.           then:
  131.             - switch.turn_on: slct
  132.             - delay: 250ms
  133.       - text_sensor.template.publish:
  134.           id: slct_chnl
  135.           state: "Channel 4"
  136.  
  137.   - id: ch_5
  138.     then:
  139.       - while:
  140.           condition:
  141.             or:
  142.               - binary_sensor.is_off: led1
  143.               - binary_sensor.is_off: led2
  144.               - binary_sensor.is_off: led3
  145.               - binary_sensor.is_off: led4
  146.           then:
  147.             - switch.turn_on: slct
  148.             - delay: 250ms
  149.       - text_sensor.template.publish:
  150.           id: slct_chnl
  151.           state: "Channel 5"
  152.  
  153. switch:
  154.   - platform: gpio
  155.     name: "${rmte1} Program"
  156.     id: program_${rmte1}
  157.     pin:
  158.       number: GPIO33
  159.       mode: OUTPUT
  160.       inverted: yes
  161.     on_turn_on:
  162.       - delay: 500ms
  163.       - switch.turn_off: program_${rmte1}
  164.  
  165.   - platform: gpio
  166.     id: up_${rmte1}
  167.     pin:
  168.       number: GPIO25
  169.       mode: OUTPUT
  170.       inverted: yes
  171.     on_turn_on:
  172.       - delay: 400ms
  173.       - switch.turn_off: up_${rmte1}
  174.      
  175.   - platform: gpio
  176.     id: stop_${rmte1}
  177.     pin:
  178.       number: GPIO27
  179.       mode: OUTPUT
  180.       inverted: yes
  181.     on_turn_on:
  182.       - delay: 400ms
  183.       - switch.turn_off: stop_${rmte1}
  184.      
  185.   - platform: gpio
  186.     id: down_${rmte1}
  187.     pin:
  188.       number: GPIO26
  189.       mode: OUTPUT
  190.       inverted: yes
  191.     on_turn_on:
  192.       - delay: 400ms
  193.       - switch.turn_off: down_${rmte1}
  194.      
  195.   - platform: gpio
  196.     name: "${rmte1} Select"
  197.     id: slct
  198.     pin:
  199.       number: GPIO32
  200.       inverted: yes
  201.     on_turn_on:
  202.       - delay: 100ms
  203.       - switch.turn_off: slct
  204.  
  205.   - platform: gpio
  206.     name: "${rmte2} Program"
  207.     id: program_${rmte2}
  208.     pin:
  209.       number: GPIO14
  210.       mode: OUTPUT
  211.       inverted: yes
  212.     on_turn_on:
  213.       - delay: 500ms
  214.       - switch.turn_off: program_${rmte2}
  215.      
  216.   - platform: gpio
  217.     id: up_${rmte2}
  218.     pin:
  219.       number: GPIO19
  220.       mode: OUTPUT
  221.       inverted: yes
  222.     on_turn_on:
  223.       - delay: 400ms
  224.       - switch.turn_off: up_${rmte2}
  225.      
  226.   - platform: gpio
  227.     id: stop_${rmte2}
  228.     pin:
  229.       number: GPIO18
  230.       mode: OUTPUT
  231.       inverted: yes
  232.     on_turn_on:
  233.       - delay: 400ms
  234.       - switch.turn_off: stop_${rmte2}
  235.      
  236.   - platform: gpio
  237.     id: down_${rmte2}
  238.     pin:
  239.       number: GPIO21
  240.       mode: OUTPUT
  241.       inverted: yes
  242.     on_turn_on:
  243.       - delay: 400ms
  244.       - switch.turn_off: down_${rmte2}
  245.  
  246. binary_sensor:
  247.   - platform: gpio
  248.     id: led1
  249.     pin:
  250.       number: GPIO35
  251.       inverted: yes
  252.     filters:
  253.       - delayed_off: 90ms
  254.  
  255.   - platform: gpio
  256.     id: led2
  257.     pin:
  258.       number: GPIO34
  259.       inverted: yes
  260.     filters:
  261.       - delayed_off: 90ms
  262.  
  263.   - platform: gpio
  264.     id: led3
  265.     pin:
  266.       number: GPIO39
  267.       inverted: yes
  268.     filters:
  269.       - delayed_off: 90ms
  270.  
  271.   - platform: gpio
  272.     id: led4
  273.     pin:
  274.       number: GPIO36
  275.       inverted: yes
  276.     filters:
  277.       - delayed_off: 90ms
  278.  
  279.   - platform: gpio
  280.     pin:
  281.       number: GPIO5
  282.       mode: INPUT_PULLUP
  283.       inverted: true
  284.     id: pwrlss
  285.     name: "Stroom aanwezig"
  286.     device_class: power
  287.     on_release:
  288.       then:
  289.         - logger.log: "!Stroomuitval!"
  290.         - if:
  291.             condition:
  292.               lambda: 'return id(slct_chnl).state != "Channel 3";'
  293.             then:
  294.               - script.execute: ch_3
  295.               - script.wait: ch_3
  296.         - switch.turn_on: up_${rmte1}
  297.  
  298. cover:
  299.   - platform: template
  300.     device_class: shutter
  301.     name: "Slaapkamer"
  302.     assumed_state: true
  303.     optimistic: true
  304.     open_action:
  305.       - if:
  306.           condition:
  307.             lambda: 'return id(slct_chnl).state != "Channel 1";'
  308.           then:
  309.             - script.execute: ch_1
  310.             - script.wait: ch_1
  311.       - switch.turn_on: up_${rmte1}
  312.     stop_action:
  313.       - if:
  314.           condition:
  315.             lambda: 'return id(slct_chnl).state != "Channel 1";'
  316.           then:
  317.             - script.execute: ch_1
  318.             - script.wait: ch_1
  319.       - switch.turn_on: stop_${rmte1}
  320.     close_action:
  321.       - if:
  322.           condition:
  323.             lambda: 'return id(slct_chnl).state != "Channel 1";'
  324.           then:
  325.             - script.execute: ch_1
  326.             - script.wait: ch_1
  327.       - switch.turn_on: down_${rmte1}
  328.  
  329.   - platform: template
  330.     device_class: shutter
  331.     name: "Babykamer"
  332.     id: studeerkamer
  333.     assumed_state: true
  334.     optimistic: true
  335.     open_action:
  336.       - if:
  337.           condition:
  338.             lambda: 'return id(slct_chnl).state != "Channel 2";'
  339.           then:
  340.             - script.execute: ch_2
  341.             - script.wait: ch_2
  342.       - switch.turn_on: up_${rmte1}
  343.     stop_action:
  344.       - if:
  345.           condition:
  346.             lambda: 'return id(slct_chnl).state != "Channel 2";'
  347.           then:
  348.             - script.execute: ch_2
  349.             - script.wait: ch_2
  350.       - switch.turn_on: stop_${rmte1}
  351.     close_action:
  352.       - if:
  353.           condition:
  354.             lambda: 'return id(slct_chnl).state != "Channel 2";'
  355.           then:
  356.             - script.execute: ch_2
  357.             - script.wait: ch_2
  358.       - switch.turn_on: down_${rmte1}
  359.  
  360.   - platform: template
  361.     device_class: shutter
  362.     name: "Nina kamer"
  363.     id: cvr_nina_kamer
  364.     assumed_state: true
  365.     optimistic: true
  366.     open_action:
  367.       - if:
  368.           condition:
  369.             lambda: 'return id(slct_chnl).state != "Channel 3";'
  370.           then:
  371.             - script.execute: ch_3
  372.             - script.wait: ch_3
  373.       - switch.turn_on: up_${rmte1}
  374.     stop_action:
  375.       - if:
  376.           condition:
  377.             lambda: 'return id(slct_chnl).state != "Channel 3";'
  378.           then:
  379.             - script.execute: ch_3
  380.             - script.wait: ch_3
  381.       - switch.turn_on: stop_${rmte1}
  382.     close_action:
  383.       - if:
  384.           condition:
  385.             lambda: 'return id(slct_chnl).state != "Channel 3";'
  386.           then:
  387.             - script.execute: ch_3
  388.             - script.wait: ch_3
  389.       - switch.turn_on: down_${rmte1}
  390.  
  391.   - platform: template
  392.     device_class: shutter
  393.     name: "Slaapkamer/Babykamer"
  394.     assumed_state: true
  395.     optimistic: true
  396.     open_action:
  397.       - if:
  398.           condition:
  399.             lambda: 'return id(slct_chnl).state != "Channel 4";'
  400.           then:
  401.             - script.execute: ch_4
  402.             - script.wait: ch_4
  403.       - switch.turn_on: up_${rmte1}
  404.     stop_action:
  405.       - if:
  406.           condition:
  407.             lambda: 'return id(slct_chnl).state != "Channel 4";'
  408.           then:
  409.             - script.execute: ch_4
  410.             - script.wait: ch_4
  411.       - switch.turn_on: stop_${rmte1}
  412.     close_action:
  413.       - if:
  414.           condition:
  415.             lambda: 'return id(slct_chnl).state != "Channel 4";'
  416.           then:
  417.             - script.execute: ch_4
  418.             - script.wait: ch_4
  419.       - switch.turn_on: down_${rmte1}
  420.  
  421.   - platform: template
  422.     device_class: shutter
  423.     name: "Alles"
  424.     assumed_state: true
  425.     optimistic: true
  426.     open_action:
  427.       - if:
  428.           condition:
  429.             lambda: 'return id(slct_chnl).state != "Channel 5";'
  430.           then:
  431.             - script.execute: ch_5
  432.             - script.wait: ch_5
  433.       - switch.turn_on: up_${rmte1}
  434.     stop_action:
  435.       - if:
  436.           condition:
  437.             lambda: 'return id(slct_chnl).state != "Channel 5";'
  438.           then:
  439.             - script.execute: ch_5
  440.             - script.wait: ch_5
  441.       - switch.turn_on: stop_${rmte1}
  442.     close_action:
  443.       - if:
  444.           condition:
  445.             lambda: 'return id(slct_chnl).state != "Channel 5";'
  446.           then:
  447.             - script.execute: ch_5
  448.             - script.wait: ch_5
  449.       - switch.turn_on: down_${rmte1}
  450.  
  451.   - platform: template
  452.     device_class: shutter
  453.     name: "Zolder"
  454.     id: zolder
  455.     assumed_state: true
  456.     optimistic: true
  457.     open_action:
  458.       - switch.turn_on: up_${rmte2}
  459.     stop_action:
  460.       - switch.turn_on: stop_${rmte2}
  461.     close_action:
  462.       - switch.turn_on: down_${rmte2}
  463.  
  464. time:
  465.   - platform: homeassistant
  466.     id: homeassistant_time
Advertisement
Add Comment
Please, Sign In to add comment