Advertisement
artpc

EspHome_plug

Jul 11th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. substitutions:
  2. plug_name: lodowka
  3. # Higher value gives lower watt readout
  4. current_res: "0.00221"
  5. # Lower value gives lower voltage readout
  6. voltage_div: "945"
  7.  
  8.  
  9.  
  10. esphome:
  11. name: lodowka
  12. platform: ESP8266
  13. board: esp8285
  14.  
  15. # WiFi connection
  16. wifi:
  17. ssid: 'lan'
  18. password: 'pass'
  19. manual_ip:
  20. static_ip: 192.168.1.94
  21. gateway: 192.168.1.100
  22. subnet: 255.255.255.0
  23. dns1: 192.168.1.100
  24. dns2: 192.168.1.100
  25.  
  26. # Enable logging
  27. logger:
  28.  
  29. # Enable Web server
  30. #web_server:
  31. # port: 80
  32.  
  33. # Enable Home Assistant API
  34. api:
  35. password: 'PASSWORD'
  36.  
  37. ota:
  38. password: 'PASSWORD'
  39.  
  40. time:
  41. - platform: homeassistant
  42. id: homeassistant_time
  43.  
  44.  
  45. binary_sensor:
  46. - platform: gpio
  47. name: "${plug_name}_button"
  48. pin:
  49. number: GPIO3
  50. inverted: True
  51. on_press:
  52. - switch.toggle: relay
  53. - platform: status
  54. name: ${plug_name}_Status
  55.  
  56.  
  57.  
  58. switch:
  59. - platform: gpio
  60. id: relay
  61. name: "${plug_name}_Relay"
  62. pin: GPIO14
  63. icon: mdi:power-socket-eu
  64. restore_mode: ALWAYS_ON
  65. on_turn_on:
  66. - switch.turn_on: blue_led
  67. on_turn_off:
  68. - switch.turn_off: blue_led
  69.  
  70. - platform: gpio
  71. id: blue_led
  72. name: "${plug_name}_LED_Blue"
  73. icon: mdi:led-on
  74. pin: GPIO1
  75. inverted: True
  76. restore_mode: ALWAYS_ON
  77.  
  78. - platform: gpio
  79. id: red_led
  80. name: "${plug_name}_LED_Red"
  81. pin: GPIO13
  82. inverted: True
  83. restore_mode: ALWAYS_OFF
  84.  
  85. sensor:
  86. - platform: hlw8012
  87. sel_pin:
  88. number: GPIO12
  89. inverted: True
  90. cf_pin: GPIO04
  91. cf1_pin: GPIO05
  92. # Higher value gives lower watt readout
  93. current_resistor: 0.00221
  94. # Lower value gives lower voltage readout
  95. voltage_divider: 794
  96. current:
  97. name: "${plug_name}_Amperage"
  98. icon: mdi:current-ac
  99. unit_of_measurement: A
  100. voltage:
  101. name: "${plug_name}_Voltage"
  102. icon: mdi:flash-circle
  103. unit_of_measurement: V
  104. power:
  105. name: "${plug_name}_Wattage"
  106. unit_of_measurement: W
  107. id: "${plug_name}_Wattage"
  108. change_mode_every: 8
  109. update_interval: 10s
  110. - platform: total_daily_energy
  111. name: "${plug_name}_Total Daily Energy"
  112. icon: mdi:circle-slice-3
  113. power_id: "${plug_name}_Wattage"
  114. filters:
  115. # Multiplication factor from W to kW is 0.001
  116. - multiply: 0.001
  117. unit_of_measurement: kWh
  118.  
  119. # Extra sensor to keep track of plug uptime
  120.  
  121. - platform: uptime
  122. id: uptime_sec
  123.  
  124. text_sensor:
  125. - platform: template
  126. name: ${plug_name}_Uptime Sensor
  127. lambda: |-
  128. int seconds = (id(uptime_sec).state);
  129. int days = seconds / (24 * 3600);
  130. seconds = seconds % (24 * 3600);
  131. int hours = seconds / 3600;
  132. seconds = seconds % 3600;
  133. int minutes = seconds / 60;
  134. seconds = seconds % 60;
  135. return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
  136. icon: mdi:clock-start
  137. update_interval: 113s
  138.  
  139. # - platform: uptime
  140. # name: ${plug_name}_Uptime Sensor
  141.  
  142. # - platform: wifi_signal
  143. # name: ${plug_name}_Wi-Fi_Signal
  144. # update_interval: 60s
  145.  
  146. #text_sensor:
  147. # - platform: version
  148. # name: ${plug_name}_firmware_version
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement