Advertisement
Guest User

Untitled

a guest
Feb 28th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.70 KB | None | 0 0
  1. substitutions:
  2.  ###### Board specifics
  3.   core: dev
  4.   arduino: recommended
  5.   platform: ESP32
  6.   board: nodemcu-32s # https://esphome.io/devices/nodemcu_esp32.html ESP32-DevkitC
  7.   ###### web portal
  8.   web_port: "80"
  9.   web_version: "2"
  10.   ###### Identity
  11.   devicename: atticlight
  12.   friendlyname: Attic Light Controller
  13.   upper_devicename: AtticLight
  14.   logger_level: DEBUG # default DEBUG, options = NONE,ERROR,WARN,INFO,VERBOSE,VERY_VERBOSE
  15.   # https://esphome.io/components/logger.html?highlight=logger
  16.   ###### Pins
  17.   light_pin1: GPIO21 # light1 (0-10v light1)
  18.   light_pin2: GPIO33 # light2 (0-10v light2)
  19.   light_pin3: GPIO19 # light3 (ledstrip 1)
  20.   light_pin4: GPIO18 # light4 (ledstrip 2)
  21.   relay_pin1: GPIO17 # Relay1,comm = vcc,NO = light1
  22.   relay_pin2: GPIO16 # Relay2,comm = vcc,NO = light2
  23.   relay_pin3: GPIO04 # Relay3,comm = vcc,NO = light3
  24.   relay_pin4: GPIO26 # Relay4,comm = vcc,NO = light4
  25.   touch_pin1: GPIO32 # Touch sensor
  26.   ###### Variables:
  27.   DefaultLightSetting: "60"
  28.  
  29. esphome:
  30.   name: $devicename
  31.   friendly_name: $friendlyname
  32.   name_add_mac_suffix: true # this sucks
  33.   project:
  34.     name: "vso.pwm_attic_project"
  35.     version: "1.1.0"
  36. # to be researched
  37. # psram:
  38. #  mode: octal
  39. #  speed: 80mhz \
  40.  
  41. esp32:
  42.   board: $board
  43.   framework:
  44.     type: arduino
  45.  
  46. # Enable logging
  47. logger:
  48.   level: $logger_level
  49. #  logs:
  50. #    mqtt.component: DEBUG
  51. #    mqtt.client: ERROR
  52.  
  53.  
  54. # Enable Home Assistant API
  55. api:
  56.  #port: 6053 # set port defaults to 6053
  57.   encryption:
  58.     key: !secret api_key
  59.   reboot_timeout: 0s # default 15min
  60.   on_client_disconnected:
  61.     - logger.log: "API client disconnected!"
  62.  
  63. time:
  64.   - platform: homeassistant
  65.     id: homeassistant_time
  66.  
  67. ota:
  68.   password: !secret ota_password
  69.   # send log updates
  70.          
  71. network:
  72.     enable_ipv6: False
  73.  
  74. wifi:
  75. # use_address: !secret IP_adrress116
  76.   networks:
  77.   - ssid: !secret wifi_ssid
  78.     password: !secret wifi_password
  79.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  80.   ap:
  81.     ssid: $devicename " Hotspot"
  82.     password: !secret wifi_password
  83.  
  84. captive_portal:
  85. wled:
  86.  
  87. web_server:
  88.   port: $web_port
  89.   version: 2
  90.   local: True
  91.  
  92. text_sensor:
  93.   - platform: wifi_info
  94.     ip_address:
  95.       name: IP Address
  96.     ssid:
  97.       name: Connected SSID
  98.     bssid:
  99.       name: Connected BSSID
  100.     mac_address:
  101.       name: Mac Wifi Address
  102.     # scan_results:
  103.     #  name: ${devicename} Latest Scan Results
  104.  
  105. # control external relay switch (powersupplies)
  106. power_supply:
  107.    # name: "power supply light 1"
  108.   - id: 'power_supply1'  
  109.     pin: $relay_pin1
  110.     enable_time: 2ms
  111.     # name: "power supply light 2"
  112.   - id: power_supply2
  113.     pin: $relay_pin2
  114.     enable_time: 2ms
  115.     # name: "power supply light 3"
  116.   - id: power_supply3  
  117.     pin: $relay_pin3
  118.     enable_time: 2ms
  119.     # name: "power supply light 4"
  120.   - id: power_supply4  
  121.     pin: $relay_pin4
  122.     enable_time: 2ms
  123.  
  124.  
  125. switch:
  126.  # (HA and webportal) restart ESP device button
  127.   - platform: restart  
  128.     name: ${devicename}" Restart"
  129.     icon: "mdi:pulse"
  130.   # define 1st light (ha and esphome)
  131.  
  132. output:
  133.    # name: "light1 state"
  134.   - platform: ledc  # for PWM control 0-10v
  135.     pin: $light_pin1 #  PWM Pin 0-10v
  136.     frequency: 1000 Hz #  PWM Pin 0-10v between 1000 and 3000 hz
  137.     id: light_output1
  138.     power_supply: power_supply1
  139.   - platform: ledc # for PWM control 0-10v
  140.     pin: $light_pin2 #  PWM Pin 0-10v
  141.     frequency: 1000 Hz #  PWM Pin 0-10v between 1000 and 3000 hz
  142.     id: light_output2
  143.     power_supply: power_supply2
  144.  
  145.  
  146. light:
  147.   - platform: monochromatic
  148.     id: light1
  149.     name: "Light 1"
  150.     output: light_output1
  151.     on_turn_on:
  152.       - light.turn_off: light3
  153.   - platform: monochromatic
  154.     id: light2
  155.     name: "Light 2"
  156.     output: light_output2
  157.     on_turn_on:
  158.       - light.turn_off: light3
  159.   - platform: neopixelbus
  160.     id: light3
  161.     name: "Hidden lights 3"
  162.     power_supply: power_supply3
  163.     restore_mode: ALWAYS_OFF
  164.     variant: WS2812
  165.     pin: $light_pin3
  166.     num_leds: 8
  167.     type: GRB
  168.     method: # added to avoid issues on multiple strips control
  169.       type: esp32_rmt
  170.       channel: 0
  171.   - platform: neopixelbus
  172.     id: light4
  173.     name: "Hidden lights 4"
  174.     power_supply: power_supply4
  175.     restore_mode: ALWAYS_OFF
  176.     variant: WS2812
  177.     pin: $light_pin4
  178.     num_leds: 16
  179.     type: GRB
  180.     method: # added to avoid issues on multiple strips control
  181.       type: esp32_rmt
  182.       channel: 1
  183.   - platform: partition
  184.     name: "Hidden lights 5 (3+4)"
  185.     id: light5
  186.     segments:
  187.       - id: light3
  188.         from: 0 # number 1
  189.         to : 7 # if 16 leds -1 = 15
  190.       - id: light4
  191.         from: 0 # number 1
  192.         to : 15 # if 16 leds -1 = 15
  193.       #- single_light_id: light6
  194.  
  195. binary_sensor:
  196.   - platform: gpio
  197.     name: "Touch Pad" # physical touch-sensor (ts223)
  198.     id: touch_input
  199.     pin: $touch_pin1
  200.     icon: "mdi:GestureTapButton"
  201.     on_click:
  202.       - min_length: 50ms
  203.         max_length: 350ms
  204.         then:
  205.           - script.execute: touch_single
  206.       - min_length: 350ms
  207.         then:
  208.             - light.turn_off: light1
  209.             - light.turn_off: light2
  210.  
  211. script:
  212.   - id: touch_single
  213.     then:
  214.       - if:
  215.           condition:
  216.             and:
  217.               - light.is_off: light1
  218.               - light.is_off: light2
  219.           then:
  220.             - light.turn_on:
  221.                 id: light1
  222.                 brightness: 60%
  223.             - light.turn_on:
  224.                 id: light2
  225.                 brightness: 60%
  226.           else:
  227.             - if:
  228.                 condition:
  229.                   light.is_on: light1
  230.                 then:
  231.                   if:
  232.                     condition:
  233.                       lambda: |-
  234.                         return int(id(light1).remote_values.get_brightness() * 100) == 100;
  235.                     then:
  236.                       - light.turn_on:
  237.                           id: light1
  238.                           brightness: 10%
  239.                     else:
  240.                       - light.dim_relative:
  241.                           id: light1
  242.                           relative_brightness: 10%
  243.             - if:
  244.                 condition:
  245.                   light.is_on: light2
  246.                 then:
  247.                   if:
  248.                     condition:
  249.                       lambda: |-
  250.                         return int(id(light2).remote_values.get_brightness() * 100) == 100;
  251.                     then:
  252.                       - light.turn_on:
  253.                           id: light2
  254.                           brightness: 10%
  255.                     else:
  256.                       - light.dim_relative:
  257.                           id: light2
  258.                           relative_brightness: 10%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement