Advertisement
to4ko

Untitled

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