Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- # Home Assistant Glow
- #
- # Read your electricity meter by means of the pulse LED on your
- # meter, useful if you do not have a serial port (P1).
- # © Klaas Schoute
- #
- substitutions:
- device_name: esphome-glow-kunde
- friendly_name: House
- project_version: "3.1.0"
- device_description: "Measure your energy consumption with the pulse LED on your smart meter"
- pulse_pin: GPIO12
- status_led: GPIO5
- # Webserver credentials ⬇ #
- web_username: 'glow'
- web_password: 'esphome'
- dashboard_import:
- package_import_url: github://klaasnicolaas/home-assistant-glow/home_assistant_glow.yaml
- esphome:
- name: '${device_name}'
- comment: '${device_description}'
- project:
- name: "klaasnicolaas.home-assistant-glow"
- version: "${project_version}"
- # Choose the right Platform
- # esp32: https://esphome.io/components/esp32.html
- # esp8266: https://esphome.io/components/esp8266.html
- esp32:
- board: nodemcu-32s
- # WiFi credentials #
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: '${device_name}'
- captive_portal:
- # Enable logging
- logger:
- # Enable improv over serial
- improv_serial:
- # Enable Home Assistant API
- api:
- services:
- - service: reset_total_energy
- then:
- - button.press:
- id: button_reset_total
- ota:
- safe_mode: true
- reboot_timeout: 10min
- num_attempts: 5
- web_server:
- port: 80
- auth:
- username: '${web_username}'
- password: '${web_password}'
- number:
- # Select the correct pulse rate for your meter
- - platform: template
- id: select_pulse_rate
- name: 'Puls rate - imp/kWh'
- optimistic: true
- mode: box
- min_value: 100
- max_value: 10000
- step: 100
- restore_value: yes
- initial_value: 1000
- output:
- # - platform: gpio
- # pin: GPIO5
- # id: output_blue
- - platform: gpio
- pin: GPIO2
- id: output_red
- - platform: gpio
- pin: GPIO4
- id: output_green
- light:
- - platform: binary
- internal: true
- id: led_red
- name: Red
- output: output_red
- # Status LED for connection
- status_led:
- pin:
- # Blue LED
- number: ${status_led}
- button:
- # Restart the ESP
- - platform: restart
- name: "Restart - Glow"
- # Reset the total energy entity
- - platform: template
- name: "Reset - Total Energy"
- id: button_reset_total
- on_press:
- - pulse_meter.set_total_pulses:
- id: sensor_energy_pulse_meter
- value: 0
- # Sensors for ESP version and WIFI information
- text_sensor:
- # Installed version
- - platform: template
- name: "Glow - Installed version"
- id: glow_version
- icon: "mdi:label-outline"
- entity_category: diagnostic
- lambda: |-
- return {"${project_version}"};
- update_interval: 6h
- # ESPHome version
- - platform: version
- hide_timestamp: true
- name: '${friendly_name} - ESPHome Version'
- # IP address and connected SSID
- - platform: wifi_info
- ip_address:
- name: '${friendly_name} - IP Address'
- icon: mdi:wifi
- ssid:
- name: '${friendly_name} - Connected SSID'
- icon: mdi:wifi-strength-2
- sensor:
- # WiFi signal
- - platform: wifi_signal
- name: "${friendly_name} - WiFi Signal"
- update_interval: 120s
- # Pulse meter
- - platform: pulse_meter
- name: '${friendly_name} - Power Consumption'
- id: sensor_energy_pulse_meter
- unit_of_measurement: 'W'
- state_class: measurement
- device_class: power
- icon: mdi:flash-outline
- accuracy_decimals: 0
- pin: ${pulse_pin}
- # internal_filter: 100ms
- on_value:
- then:
- - light.turn_on:
- id: led_red
- - delay: 0.5s
- - light.turn_off:
- id: led_red
- filters:
- # multiply value = (60 / imp value) * 1000
- # - multiply: 60
- - lambda: return x * ((60.0 / id(select_pulse_rate).state) * 1000.0);
- total:
- name: '${friendly_name} - Total Energy'
- id: sensor_total_energy
- unit_of_measurement: 'kWh'
- icon: mdi:circle-slice-3
- state_class: total_increasing
- device_class: energy
- accuracy_decimals: 3
- filters:
- # multiply value = 1 / imp value
- # - multiply: 0.001
- - lambda: return x * (1.0 / id(select_pulse_rate).state);
- # Total day useage
- - platform: total_daily_energy
- name: '${friendly_name} - Daily Energy'
- id: sensor_total_daily_energy
- power_id: sensor_energy_pulse_meter
- unit_of_measurement: 'kWh'
- icon: mdi:circle-slice-3
- state_class: total_increasing
- device_class: energy
- accuracy_decimals: 3
- filters:
- # Multiplication factor from W to kW is 0.001
- - multiply: 0.001
- # Enable time component to reset energy at midnight
- # https://esphome.io/components/time.html#home-assistant-time-source
- time:
- - platform: homeassistant
- id: homeassistant_time
Advertisement
Add Comment
Please, Sign In to add comment