Advertisement
Guest User

Untitled

a guest
Sep 26th, 2022
267
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 1 0
  1. esphome:
  2. name: power-strip-1
  3.  
  4. platform: ESP8266
  5. board: esp8285
  6. esp8266_restore_from_flash: true
  7.  
  8. substitutions:
  9. plug_name: p1_01
  10.  
  11. wifi:
  12. ssid: airCube-536
  13. password: wellingtonboot
  14. #domain: !secret domain
  15. #use_address: 192.168.6.6
  16. # Enable fallback hotspot (captive portal) in case wifi connection fails
  17. ap:
  18. ssid: "${plug_name} Fallback Hotspot"
  19. password: !secret Fallback_Hotspot
  20.  
  21. captive_portal:
  22.  
  23. # Enable logging
  24. logger:
  25. #level: VERY_VERBOSE
  26. #baud_rate: 0
  27. #level: DEBUG
  28. baud_rate: 0
  29. logs:
  30. adc: INFO
  31.  
  32. # Enable Home Assistant API
  33. api:
  34.  
  35. ota:
  36.  
  37. time:
  38. - platform: homeassistant
  39. id: homeassistant_time
  40.  
  41. status_led:
  42. pin:
  43. number: GPIO02
  44. inverted: True
  45.  
  46. uart:
  47. rx_pin: GPIO03
  48. #tx_pin: GPIO01
  49. baud_rate: 4800
  50.  
  51. sensor:
  52. - platform: wifi_signal
  53. name: "${plug_name} - WiFi Signal"
  54. update_interval: 60s
  55. - platform: uptime
  56. name: "${plug_name} - Uptime"
  57. icon: mdi:clock-outline
  58. update_interval: 60s
  59. - platform: cse7766
  60. current:
  61. name: "${plug_name} - Ampere"
  62. unit_of_measurement: A
  63. accuracy_decimals: 3
  64. icon: mdi:flash-outline
  65. voltage:
  66. name: "${plug_name} - Volt"
  67. unit_of_measurement: V
  68. accuracy_decimals: 1
  69. icon: mdi:flash-outline
  70. filters:
  71. - lambda: return x * 2.34245;
  72. power:
  73. name: "${plug_name} - Watt"
  74. unit_of_measurement: W
  75. id: "${plug_name}_Wattage"
  76. icon: mdi:flash-outline
  77. filters:
  78. - lambda: return x * 2.34245;
  79. update_interval: 3s
  80. - platform: total_daily_energy
  81. name: "${plug_name} - Dagverbruik"
  82. power_id: "${plug_name}_Wattage"
  83. filters:
  84. # Multiplication factor from W to kW is 0.001
  85. - multiply: 0.001
  86. unit_of_measurement: kWh
  87. icon: mdi:clock-alert
  88. - platform: adc
  89. pin: GPIO17
  90. id: gpio17
  91. internal: true
  92. update_interval: 0.1s
  93. filters:
  94. - lambda: |-
  95. if(x >= 0.60 && x < 0.90){
  96. id(buttonrelay1).publish_state(true);
  97. } else if(x >= 0.30 && x < 0.60){
  98. id(buttonrelay2).publish_state(true);
  99. }
  100. else if(x > 0.10 && x < 0.30){
  101. id(buttonrelay3).publish_state(true);
  102. } else {
  103. id(buttonrelay1).publish_state(false);
  104. id(buttonrelay2).publish_state(false);
  105. id(buttonrelay3).publish_state(false);
  106. }
  107. return{};
  108.  
  109. binary_sensor:
  110. - platform: gpio
  111. id: button
  112. internal: true
  113. pin:
  114. number: GPIO16
  115. mode: INPUT
  116. inverted: true
  117. #on_state:
  118. on_press:
  119. - switch.toggle: relay4
  120. - platform: template
  121. id: buttonrelay1
  122. internal: true
  123. on_press:
  124. - switch.toggle: relay1
  125. filters:
  126. - delayed_off: 100ms
  127. - platform: template
  128. id: buttonrelay2
  129. internal: true
  130. on_press:
  131. - switch.toggle: relay2
  132. filters:
  133. - delayed_off: 100ms
  134. - platform: template
  135. id: buttonrelay3
  136. internal: true
  137. on_press:
  138. - switch.toggle: relay3
  139. filters:
  140. - delayed_off: 100ms
  141.  
  142. text_sensor:
  143. - platform: version
  144. name: "${plug_name} - ESPHome Version"
  145.  
  146. switch:
  147. - platform: gpio
  148. pin: GPIO14
  149. id: relay1
  150. restore_mode: RESTORE_DEFAULT_ON
  151. name: '${plug_name} - Switch1'
  152. icon: mdi:power-socket-eu
  153. - platform: gpio
  154. pin: GPIO12
  155. id: relay2
  156. restore_mode: RESTORE_DEFAULT_ON
  157. name: '${plug_name} - Switch2'
  158. icon: mdi:power-socket-eu
  159. - platform: gpio
  160. pin: GPIO13
  161. id: relay3
  162. restore_mode: RESTORE_DEFAULT_ON
  163. name: '${plug_name} - Switch3'
  164. icon: mdi:power-socket-eu
  165. - platform: gpio
  166. pin: GPIO05
  167. id: relay4
  168. restore_mode: RESTORE_DEFAULT_ON
  169. name: '${plug_name} - Switch USB'
  170. icon: mdi:power-socket-eu
  171. inverted: yes
  172. - platform: restart
  173. name: "${plug_name} - ESP Restart"
  174. - platform: template
  175. name: '${plug_name} - Switch off 60s (reset!)'
  176. turn_on_action:
  177. - switch.turn_off: relay3
  178. - delay: 60s
  179. - switch.turn_on: relay3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement