smartmeter.yaml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. esphome:
  2. name: smartmeter
  3. esp8266:
  4. board: d1_mini
  5. # Enable logging
  6. logger:
  7. hardware_uart: UART0_SWAP
  8. # Enable Home Assistant API
  9. api:
  10. encryption:
  11. key: "nc/DDxg2mjIDat3SJd/7otH9KBA7te/egr9X8pGi1Io="
  12. ota:
  13. password: "37b5b12ce4c3bc1184eb6872a85b48d6"
  14. wifi:
  15. ssid: !secret wifi_ssid
  16. password: !secret wifi_password
  17. # Enable fallback hotspot (captive portal) in case wifi connection fails
  18. ap:
  19. ssid: "Smartmeter Fallback Hotspot"
  20. password: "UzI1eDQxpFcP"
  21. globals:
  22. - id: total_pulses
  23. type: int
  24. restore_value: false
  25. initial_value: '0'
  26. captive_portal:
  27. # SML Example configuration entry
  28. uart:
  29. id: uart_bus
  30. rx_pin: GPIO3
  31. baud_rate: 9600
  32. data_bits: 8
  33. parity: NONE
  34. stop_bits: 1
  35. # This is mainly here because the internal_filter of the pulse_counter on ESP8266
  36. # can only be set to a maximum of 13us, which is way too low. The Reedswitch
  37. # sometimes rapidly switches from ON to OFF, causing a lot of "ghost" pulses.
  38. # The delayed_on filter will make sure that the sensor stayed ON for at least
  39. # 100ms before increasing the counter.
  40. binary_sensor:
  41. - platform: gpio
  42. id: internal_pulse_counter
  43. pin: GPIO16
  44. filters:
  45. - invert:
  46. - delayed_on: 100ms
  47. on_press:
  48. then:
  49. - lambda: id(total_pulses) += 1;
  50. sml:
  51. id: mysml
  52. uart_id: uart_bus
  53. sensor:
  54. - platform: sml
  55. name: "Total energy"
  56. sml_id: mysml
  57. server_id: "0a01445a4700039f12bd"
  58. obis_code: "1-0:1.8.0"
  59. unit_of_measurement: kWh
  60. accuracy_decimals: 1
  61. device_class: energy
  62. state_class: total_increasing
  63. filters:
  64. - multiply: 0.0001
  65. - heartbeat: 10s
  66. - platform: sml
  67. name: "Power"
  68. sml_id: mysml
  69. server_id: "0a01445a4700039f12bd"
  70. obis_code: "1-0:16.7.0"
  71. unit_of_measurement: W
  72. accuracy_decimals: 1
  73. device_class: energy
  74. filters:
  75. - multiply: 0.01
  76. - heartbeat: 10s
  77. - platform: template
  78. name: "Gas used"
  79. device_class: gas
  80. unit_of_measurement: "m³"
  81. state_class: total_increasing
  82. icon: "mdi:fire"
  83. accuracy_decimals: 1
  84. lambda: |-
  85. return id(total_pulses) * 0.1;
  86. text_sensor:
  87. - platform: sml
  88. name: "Total energy text"
  89. sml_id: mysml
  90. server_id: "0a01445a4700039f12bd"
  91. obis_code: "1-0:1.8.0"
  92. format: uint
  93. - platform: sml
  94. name: "Power text"
  95. sml_id: mysml
  96. server_id: "0a01445a4700039f12bd"
  97. obis_code: "1-0:16.7.0"
  98. format: uint
  99. time:
  100. - platform: homeassistant
  101. on_time:
  102. - seconds: 0
  103. minutes: 0
  104. hours: 4
  105. days_of_week: MON-SUN
  106. then:
  107. - switch.toggle: restart_switch
  108. switch:
  109. - platform: restart
  110. name: "Auto Restart"
  111. id: restart_switch