Advertisement
hhakansson

Home Assistant Glow

Jan 11th, 2023
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.46 KB | None | 0 0
  1. esphome:
  2.   name: "esp32-1"
  3.   platform: ESP32
  4.   board: esp32doit-devkit-v1
  5.  
  6. wifi:
  7.   ssid: !secret wifi_s
  8.   password: !secret wifi_p
  9. #  use_address: esp32_1.local
  10. #  manual_ip:
  11.     # Set this to the IP of the ESP
  12. #    static_ip: 10.0.0.198
  13.     # Set this to the IP address of the router. Often ends with .1
  14. #    gateway: 10.0.0.1
  15.     # The subnet of the network. 255.255.255.0 works for most home networks.
  16. #    subnet: 255.255.255.0  
  17.   reboot_timeout: 10s
  18.   power_save_mode: none
  19.  
  20. web_server:
  21.   port: 80
  22.  
  23. substitutions:
  24.   device_name: home-assistant-glow
  25.   friendly_name: EnergyConsumptionMeter
  26.   device_description: "Measure your energy consumption with the pulse LED on your smart meter"
  27.   pulse_pin: GPIO15
  28.   status_led: GPIO32
  29.   # imp/kWh rate ⬇ #
  30.   pulse_rate: '1000'
  31.  
  32. # Enable logging
  33. logger:
  34.   level: VERBOSE
  35.  
  36. # Enable Home Assistant API
  37. api:
  38.   password: !secret api_p
  39.  
  40. ota:
  41.   password: !secret ota_p
  42.  
  43.  
  44. output:
  45.   - platform: gpio
  46.     pin: GPIO27
  47.     id: output_red
  48.    
  49.   - platform: gpio
  50.     pin: GPIO25
  51.     id: output_green
  52.    
  53.   - platform: gpio
  54.     pin: GPIO32
  55.     id: output_blue
  56.  
  57. # blue LED=GPIO32, Grön ledning
  58. # red LED=GPIO27, Blå ledning
  59. # green LED=GPIO25, Röd leding
  60.  
  61. light:
  62.   - platform: binary
  63.     internal: true
  64.     id: led_red
  65.     #name: Red
  66.     output: output_red
  67.  
  68.   - platform: binary
  69.     internal: true
  70.     id: led_blue
  71.     #name: Blue
  72.     output: output_blue
  73.  
  74.   - platform: binary
  75.     internal: true
  76.     id: led_green
  77.     #name: Green
  78.     output: output_green
  79.  
  80. # Status LED for connection
  81. status_led:
  82.   pin:
  83.    # Blue LED
  84.     number: ${status_led}
  85.  
  86. #globals:
  87. #  - id: light_toggler
  88. #    type: int
  89. #    initial_value: '0'
  90.  
  91.  
  92. #switch:
  93. #  - platform: template
  94. #    id: "blue_light"
  95. #    name: "testEnergyConsumption LED Blue"
  96. #    lambda: |-
  97. #      if (id(light_toggler) == 1 ) {
  98. #        return true;
  99. #      } else {
  100. #        return false;
  101. #      }
  102. #
  103. #    turn_on_action:
  104. #      - light.turn_on: led_blue
  105. #      - lambda: id(light_toggler) = 1;
  106. #    turn_off_action:
  107. #      - light.turn_off: led_blue  
  108. #      - lambda: id(light_toggler) = 0;
  109.  
  110.  
  111. # Sensors for ESP version and WIFI information
  112. text_sensor:
  113.   - platform: version
  114.     hide_timestamp: true
  115.     name: "${friendly_name} - ESPHome Version"
  116.   - platform: wifi_info
  117.     ip_address:
  118.       name: "${friendly_name} - IP Address"
  119.       icon: mdi:wifi
  120.     ssid:
  121.       name: "${friendly_name} - Connected SSID"
  122.       icon: mdi:wifi-strength-2
  123.      
  124.      
  125. sensor:
  126.   - platform: pulse_meter
  127.     id: energy_pulse_meter
  128.     name: '${friendly_name} - Power consumption'
  129.     unit_of_measurement: 'W'
  130.     state_class: measurement
  131.     device_class: power
  132.     icon: mdi:flash-outline
  133.     accuracy_decimals: 0
  134.     pin: ${pulse_pin}
  135.     # internal_filter: 100ms
  136.     on_value:
  137.       then:
  138.         - light.turn_on:
  139.             id: led_red
  140.         - delay: 100ms
  141.         - light.turn_off:
  142.             id: led_red
  143.     filters:
  144.      # multiply value = (60 / imp value) * 1000
  145.       # - multiply: 60
  146.       - lambda: return x * ((60.0 / ${pulse_rate}) * 1000.0);
  147.     total:
  148.       name: '${friendly_name} - Total energy'
  149.       unit_of_measurement: 'kWh'
  150.       icon: mdi:circle-slice-3
  151.       state_class: total_increasing
  152.       device_class: energy
  153.       accuracy_decimals: 3
  154.       filters:
  155.        # multiply value = 1 / imp value
  156.         # - multiply: 0.001
  157.         - lambda: return x * (1.0 / ${pulse_rate});
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement