Since the new awesome “Energy Dashboard” was released in Home-Assistent in 2021-08 I immediately felt the urge to use it. As I live on the third floor of an Appartement Building and my meter is in the basement I can’t use a Wi-Fi based approach to read my meter since there is no connectivity. That is where Lora comes in handy. I ordered a Heltec Lora Esp32 V2 Dev Board to play around with and was lucky to have a decent connectivity in my basement (RSSI: ~109 dBm / SNR: ~0 dB - using Akenza as an advisable LoRaWAN connectivity Integrator for Switzerland). Initially I built a similar approach as Home-Assitant Glow where the light pulses of my meter are being count, sent to the TTN and used the Riemann sum integration to calculate the kWh. I didn’t like it as it wanted to make my project battery powered (in the future) and when my household consumes less than 50 watt it runs quite a while to count for at least 2 light pulses. Also, I know that my meter already sums up my energy consumption (kwh) and many other OBIS values, thus I really wanted to get to that data using an optical reading head. As my meter requires an initial sequence to be sent to receive data, I needed a reading head (sometimes also referred to as optical probe), that has a photodiode (for RX) and infrared led (for TX) and use a serial interface (TTL) to interact with it using Arduino.
Project
- Periodically read current power, energy consumption and other OBIS-values from an electricity meter that support the IEC 62056-21 protocol.
- Use LoRa/TTN to send the data to a (public or private) gateway
- The gateway POST’s the data to a Home-Assistant WebHook where the data is applied to several template sensors
- I’m an absolute beginner with Arduino, Platformio and C++ so please have mercy
State
- Project is still work in progress (feel free to contribute / integrated your smart-meter)
- In the beginning I was experimenting arround with the Heltec lora esp32 microcontroller. That microcontroller is fully Arduino / Platformio compatible and work fine as long as you don’t power it by a battery as it consumes a lot of energy even in deep-sleep. Thus I switched to the Heltec Cubecell AB02 series that is specialized for battery operated LoRa use-cases.
- I ran a long dozen of times up and down the staircase (third floor) down to the basement for this project - and yes, I got a sore muscle
My Hardware
Optical Probes:
- Buy: Optical probe OP-333 with RS-232 output signal
- Buy: ttl ir lesekopf lese-schreib-Kopf EHZ Volkszähler Hichi Smartmeter | eBay
- DYI: hardware:controllers:ir-schreib-lesekopf-ttl-ausgang [wiki.volkszaehler.org]
Source:
Home-Assistant
Template Sensors
The strucure of
trigger.json.data
depends on your gateway/provider POST request
- trigger:
- platform: webhook
webhook_id: lorawan-data
id: lorawan-data
unique_id: smart_meter
sensor:
- name: "Smart Meter Power"
unique_id: smart_meter_power
icon: mdi:flash-outline
unit_of_measurement: W
device_class: power
state_class: measurement
state: >-
{% set payloadHex = trigger.json.data.payload_hex | default(none) %}
{% set value = payloadHex[0:4] %}
{% if value == '0000' %}
{{ none }}
{% else %}
{{ value | int(value,16) }}
{% endif %}
- name: "Smart Meter Kwh"
unique_id: smart_meter_kwh
icon: mdi:chart-histogram
unit_of_measurement: "kWh"
state_class: measurement
device_class: energy
#last_reset_type: auto
state: >-
{% set payloadHex = trigger.json.data.payload_hex | default(none) %}
{% set value = payloadHex[4:12] %}
{% if value == '00000000' %}
{{ none }}
{% else %}
{{ value | int(value,16)/100|float }}
{% endif %}
Utility Meter
Needed to integrate the values into the energy dashboard
utility_meter:
hourly_energy:
name: "Hourly Energy Consumption"
source: sensor.smart_meter_kwh
cycle: hourly
daily_energy:
name: "Daily Energy Consumption"
source: sensor.smart_meter_kwh
cycle: daily
Pictures
Electricity Meter and Optical Reading Head:
Home-Assistant Sensors:
Energy Dashboard: