svinedyret

Glow

Feb 26th, 2023
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | Software | 0 0
  1. ---
  2. # Home Assistant Glow
  3. #
  4. # Read your electricity meter by means of the pulse LED on your
  5. # meter, useful if you do not have a serial port (P1).
  6. # © Klaas Schoute
  7. #
  8. substitutions:
  9. device_name: esphome-glow-kunde
  10. friendly_name: House
  11. project_version: "3.1.0"
  12. device_description: "Measure your energy consumption with the pulse LED on your smart meter"
  13. pulse_pin: GPIO12
  14. status_led: GPIO5
  15.  
  16. # Webserver credentials ⬇ #
  17. web_username: 'glow'
  18. web_password: 'esphome'
  19.  
  20. dashboard_import:
  21. package_import_url: github://klaasnicolaas/home-assistant-glow/home_assistant_glow.yaml
  22.  
  23. esphome:
  24. name: '${device_name}'
  25. comment: '${device_description}'
  26. project:
  27. name: "klaasnicolaas.home-assistant-glow"
  28. version: "${project_version}"
  29.  
  30. # Choose the right Platform
  31. # esp32: https://esphome.io/components/esp32.html
  32. # esp8266: https://esphome.io/components/esp8266.html
  33. esp32:
  34. board: nodemcu-32s
  35.  
  36. # WiFi credentials #
  37. wifi:
  38. ssid: !secret wifi_ssid
  39. password: !secret wifi_password
  40.  
  41. # Enable fallback hotspot (captive portal) in case wifi connection fails
  42. ap:
  43. ssid: '${device_name}'
  44.  
  45. captive_portal:
  46.  
  47. # Enable logging
  48. logger:
  49.  
  50. # Enable improv over serial
  51. improv_serial:
  52.  
  53. # Enable Home Assistant API
  54. api:
  55. services:
  56. - service: reset_total_energy
  57. then:
  58. - button.press:
  59. id: button_reset_total
  60.  
  61. ota:
  62. safe_mode: true
  63. reboot_timeout: 10min
  64. num_attempts: 5
  65.  
  66. web_server:
  67. port: 80
  68. auth:
  69. username: '${web_username}'
  70. password: '${web_password}'
  71.  
  72. number:
  73. # Select the correct pulse rate for your meter
  74. - platform: template
  75. id: select_pulse_rate
  76. name: 'Puls rate - imp/kWh'
  77. optimistic: true
  78. mode: box
  79. min_value: 100
  80. max_value: 10000
  81. step: 100
  82. restore_value: yes
  83. initial_value: 1000
  84.  
  85. output:
  86. # - platform: gpio
  87. # pin: GPIO5
  88. # id: output_blue
  89. - platform: gpio
  90. pin: GPIO2
  91. id: output_red
  92. - platform: gpio
  93. pin: GPIO4
  94. id: output_green
  95.  
  96. light:
  97. - platform: binary
  98. internal: true
  99. id: led_red
  100. name: Red
  101. output: output_red
  102.  
  103. # Status LED for connection
  104. status_led:
  105. pin:
  106. # Blue LED
  107. number: ${status_led}
  108.  
  109. button:
  110. # Restart the ESP
  111. - platform: restart
  112. name: "Restart - Glow"
  113. # Reset the total energy entity
  114. - platform: template
  115. name: "Reset - Total Energy"
  116. id: button_reset_total
  117. on_press:
  118. - pulse_meter.set_total_pulses:
  119. id: sensor_energy_pulse_meter
  120. value: 0
  121.  
  122. # Sensors for ESP version and WIFI information
  123. text_sensor:
  124. # Installed version
  125. - platform: template
  126. name: "Glow - Installed version"
  127. id: glow_version
  128. icon: "mdi:label-outline"
  129. entity_category: diagnostic
  130. lambda: |-
  131. return {"${project_version}"};
  132. update_interval: 6h
  133. # ESPHome version
  134. - platform: version
  135. hide_timestamp: true
  136. name: '${friendly_name} - ESPHome Version'
  137. # IP address and connected SSID
  138. - platform: wifi_info
  139. ip_address:
  140. name: '${friendly_name} - IP Address'
  141. icon: mdi:wifi
  142. ssid:
  143. name: '${friendly_name} - Connected SSID'
  144. icon: mdi:wifi-strength-2
  145.  
  146. sensor:
  147. # WiFi signal
  148. - platform: wifi_signal
  149. name: "${friendly_name} - WiFi Signal"
  150. update_interval: 120s
  151.  
  152. # Pulse meter
  153. - platform: pulse_meter
  154. name: '${friendly_name} - Power Consumption'
  155. id: sensor_energy_pulse_meter
  156. unit_of_measurement: 'W'
  157. state_class: measurement
  158. device_class: power
  159. icon: mdi:flash-outline
  160. accuracy_decimals: 0
  161. pin: ${pulse_pin}
  162. # internal_filter: 100ms
  163. on_value:
  164. then:
  165. - light.turn_on:
  166. id: led_red
  167. - delay: 0.5s
  168. - light.turn_off:
  169. id: led_red
  170. filters:
  171. # multiply value = (60 / imp value) * 1000
  172. # - multiply: 60
  173. - lambda: return x * ((60.0 / id(select_pulse_rate).state) * 1000.0);
  174. total:
  175. name: '${friendly_name} - Total Energy'
  176. id: sensor_total_energy
  177. unit_of_measurement: 'kWh'
  178. icon: mdi:circle-slice-3
  179. state_class: total_increasing
  180. device_class: energy
  181. accuracy_decimals: 3
  182. filters:
  183. # multiply value = 1 / imp value
  184. # - multiply: 0.001
  185. - lambda: return x * (1.0 / id(select_pulse_rate).state);
  186. # Total day useage
  187. - platform: total_daily_energy
  188. name: '${friendly_name} - Daily Energy'
  189. id: sensor_total_daily_energy
  190. power_id: sensor_energy_pulse_meter
  191. unit_of_measurement: 'kWh'
  192. icon: mdi:circle-slice-3
  193. state_class: total_increasing
  194. device_class: energy
  195. accuracy_decimals: 3
  196. filters:
  197. # Multiplication factor from W to kW is 0.001
  198. - multiply: 0.001
  199.  
  200. # Enable time component to reset energy at midnight
  201. # https://esphome.io/components/time.html#home-assistant-time-source
  202. time:
  203. - platform: homeassistant
  204. id: homeassistant_time
Advertisement
Add Comment
Please, Sign In to add comment