Advertisement
TuXaMaT

Удлинитель EKF Connect PRO с USB (ESPHome)

Jul 6th, 2023 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.08 KB | None | 0 0
  1. esphome:
  2.   name: ekf_udlinitel
  3.   friendly_name: EKF_udlinitel
  4.  
  5. esp8266:
  6.   board: esp01_1m
  7.  
  8. # Enable logging
  9. logger:
  10. # Enable Home Assistant API
  11. api:
  12.   encryption:
  13.     key: "ваш ключ"
  14.   reboot_timeout: 15min
  15.  
  16. ota:
  17.   password: "ваш пароль"
  18.  
  19. wifi:
  20.   ssid: !secret wifi_ssid
  21.   password: !secret wifi_password
  22.  
  23.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  24.   ap:
  25.     ssid: "Ekf-Udlinitel Fallback Hotspot"
  26.     password: "ваш пароль"
  27.  
  28. captive_portal:
  29. substitutions:
  30.   device_name: ekf_udlinitel
  31.   plug_icon: mdi:power-socket-eu
  32.   plug1_restore: ALWAYS_ON # состояние розетки при подаче питания
  33.   plug2_restore: ALWAYS_ON
  34.   plug3_restore: ALWAYS_ON
  35.   plug4_restore: ALWAYS_ON
  36.  
  37.   # Higher value gives lower watt readout. Нужно подбирать коэффициент для правильного подсчета потребления
  38.   current_res: "0.0010035"
  39.   # Lower value gives lower voltage readout. Нужно подбирать для правильного отображения вольтажа, по эталону.
  40.   voltage_div: "1713"
  41.  
  42. web_server:
  43.   port: 80
  44.  
  45. binary_sensor:
  46.   - platform: gpio
  47.     pin:
  48.       number: GPIO16
  49.       inverted: true
  50.     name: "${device_name}_button"
  51.     on_press:
  52.       - switch.toggle: relay4 # кнопка на корпусе будет включать/выключать только 4ю розетку
  53.  
  54.   - platform: status
  55.     name: "${device_name}_status"
  56.  
  57. switch:
  58.   - platform: gpio
  59.     id: green_led
  60.     pin:
  61.       number: GPIO1
  62.       inverted: true
  63.     restore_mode: ALWAYS_OFF
  64.  
  65.   - platform: gpio
  66.     name: "${device_name}_plug1"
  67.     pin: GPIO15
  68.     id: relay1
  69.     icon: ${plug_icon}
  70.     restore_mode: ${plug1_restore}
  71.  
  72.   - platform: gpio
  73.     name: "${device_name}_plug2"
  74.     pin: GPIO13
  75.     id: relay2
  76.     icon: ${plug_icon}
  77.     restore_mode: ${plug1_restore}
  78.  
  79.   - platform: gpio
  80.     name: "${device_name}_plug3"
  81.     pin: GPIO14
  82.     id: relay3
  83.     icon: ${plug_icon}
  84.     restore_mode: ${plug2_restore}
  85.  
  86.   - platform: gpio
  87.     name: "${device_name}_plug4"
  88.     pin: GPIO3
  89.     id: relay4
  90.     icon: ${plug_icon}
  91.     restore_mode: ${plug3_restore}
  92.     on_turn_on: #при управлении с физической кнопки будет зажигаться гаснуть светодиод
  93.       - switch.turn_on: green_led
  94.     on_turn_off:
  95.       - switch.turn_off: green_led
  96.  
  97. sensor:
  98.   - platform: hlw8012
  99.     sel_pin:
  100.       number: GPIO12
  101.       inverted: true
  102.     cf_pin: GPIO04
  103.     cf1_pin: GPIO05
  104.     current:
  105.       name: "${device_name}_current"
  106.       unit_of_measurement: A
  107.     voltage:
  108.       name: "${device_name}_voltage"
  109.       unit_of_measurement: V
  110.     power:
  111.       id: ${device_name}_wattage
  112.       name: "${device_name}_wattage"
  113.       unit_of_measurement: W
  114.     current_resistor: ${current_res}
  115.     voltage_divider: ${voltage_div}
  116.     change_mode_every: 8
  117.     update_interval: 15s
  118.  
  119.   - platform: total_daily_energy
  120.     name: "${device_name}_daily_energy"
  121.     power_id: ${device_name}_wattage
  122.     filters:
  123.       - multiply: 0.001
  124.     unit_of_measurement: kWh
  125.  
  126.   - platform: wifi_signal
  127.     name: "${device_name}_rssi"
  128.     update_interval: 5min
  129.  
  130.   - platform: uptime
  131.     id: uptime_sec
  132.     name: "${device_name}_uptime"
  133.     update_interval: 5min
  134.  
  135. text_sensor:
  136.   - platform: template
  137.     name: "${device_name}_upformat"
  138.     lambda: |-
  139.       uint32_t dur = id(uptime_sec).state;
  140.       int dys = 0;
  141.       int hrs = 0;
  142.       int mnts = 0;
  143.       if (dur > 86399) {
  144.         dys = trunc(dur / 86400);
  145.         dur = dur - (dys * 86400);
  146.       }
  147.       if (dur > 3599) {
  148.         hrs = trunc(dur / 3600);
  149.         dur = dur - (hrs * 3600);
  150.       }
  151.       if (dur > 59) {
  152.         mnts = trunc(dur / 60);
  153.         dur = dur - (mnts * 60);
  154.       }
  155.       char buffer[17];
  156.       sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
  157.       return {buffer};
  158.     icon: mdi:clock-start
  159.     update_interval: 5min
  160.  
  161. time:
  162.   - platform: homeassistant
  163.     id: homeassistant_time
Tags: ESPhome tuya skf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement