to4ko

Untitled

Apr 5th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.87 KB | None | 0 0
  1. substitutions:
  2.   board_name: shp2_socket_1
  3.   ip_address: 192.168.1.124
  4.   current_res: "0.00221"
  5.   voltage_div: "945"
  6.  
  7. esphome:
  8.   name: ${board_name}
  9.   platform: ESP8266
  10.   board: esp8285
  11. #  on_boot:
  12. #    if:
  13. #      condition:
  14. #        wifi.connected:
  15. #      then:
  16. #        - light.turn_on: blue_led
  17.  
  18. wifi:
  19.   ssid: !secret wifi_ssid
  20.   password: !secret wifi_pass
  21.   domain: .localdomain
  22.   reboot_timeout: 0s
  23.   manual_ip:
  24.     static_ip: ${ip_address}
  25.     gateway: 192.168.1.1
  26.     subnet: 255.255.255.0
  27.  
  28. logger:
  29. api:
  30.   reboot_timeout: 0s
  31.  
  32. ota:
  33. web_server:
  34.   port: 80
  35.  
  36. binary_sensor:
  37.   - platform: gpio
  38.     name: ${board_name}_Button
  39.     pin:
  40.       number: GPIO3
  41.       mode: INPUT_PULLUP
  42.       inverted: True
  43.     on_press:
  44.       - switch.toggle: relay
  45.  
  46. switch:
  47.   - platform: gpio
  48.     name: ${board_name}_Relay
  49.     pin: GPIO14
  50.     id: relay
  51.     restore_mode: ALWAYS_ON
  52.     on_turn_on:
  53.       - switch.turn_on: blue_led
  54.       - switch.turn_off: red_led
  55.     on_turn_off:
  56.       - switch.turn_off: blue_led
  57.       - switch.turn_on: red_led
  58.  
  59.   - platform: gpio
  60.     id: blue_led
  61.     name: ${board_name}_LED_Blue
  62.     icon: mdi:led-on
  63.     restore_mode: ALWAYS_ON
  64.     pin:
  65.       number: GPIO1
  66.       inverted: True
  67.  
  68.   - platform: gpio
  69.     id: red_led
  70.     name: ${board_name}_LED_Red
  71.     icon: mdi:led-on
  72.     restore_mode: ALWAYS_OFF
  73.     pin:
  74.       number: GPIO13
  75.       inverted: True
  76.  
  77. sensor:
  78.   - platform: hlw8012
  79.     sel_pin:
  80.       number: GPIO12
  81.       inverted: True
  82.     cf_pin: GPIO04
  83.     cf1_pin: GPIO05
  84.     current_resistor: ${current_res}
  85.     voltage_divider: ${voltage_div}
  86.     current:
  87.       name: ${board_name}_Current
  88.       icon: mdi:current-ac
  89.       unit_of_measurement: A
  90.     voltage:
  91.       name: ${board_name}_Voltage
  92.       icon: mdi:flash-circle
  93.       unit_of_measurement: V
  94.     power:
  95.       name: ${board_name}_Power
  96.       icon: mdi:flash-outline
  97.       unit_of_measurement: W
  98.     change_mode_every: 8
  99.     update_interval: 10s
  100.  
  101.   - platform: uptime
  102.     name: ${board_name}_Uptime_s
  103.     id: uptime_sensor
  104.  
  105.   - platform: wifi_signal
  106.     name: ${board_name}_WiFi_RSSI
  107.     update_interval: 60s
  108.  
  109. text_sensor:
  110.   - platform: template
  111.     name: ${board_name}_Uptime
  112.     lambda: |-
  113.       uint32_t dur = id(uptime_sensor).state;
  114.       int dys = 0;
  115.       int hrs = 0;
  116.       int mnts = 0;
  117.       if (dur > 86399) {
  118.         dys = trunc(dur / 86400);
  119.         dur = dur - (dys * 86400);
  120.       }
  121.       if (dur > 3599) {
  122.         hrs = trunc(dur / 3600);
  123.         dur = dur - (hrs * 3600);
  124.       }
  125.       if (dur > 59) {
  126.         mnts = trunc(dur / 60);
  127.         dur = dur - (mnts * 60);
  128.       }
  129.       char buffer[17];
  130.       sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
  131.       return {buffer};
  132.     icon: mdi:clock-start
  133.     update_interval: 15s
  134.  
  135. time:
  136.   - platform: homeassistant
  137.     id: homeassistant_time
Add Comment
Please, Sign In to add comment