Glad you figured out the Mosqutto thing. I run Home Assistant and Mosquitto as Docker containers, so things are different than if you install Mosqutto as a Hass Add-On.
For reference for anybody else, it seems like the steps for HASS would be to go Mosqutto’s “Add-on configuration” and:
-
Enable the customize flag:
customize:
active: true
folder: mosquitto
-
Create /share/mosquitto/dte.conf
and put in the lines I listed above (as being in my mosquitto.conf file) to create the connection to the Energy Bridge. (The /share
folder can be accessed via SMB, or on the host filesystem under /usr/share/hassio/share
.)
As for the Energy Dashboard, I didn’t realize this had been released!
Here’s my updated config so the Energy Bridge shows up as an available sensor, with my first guess as to how to set the (required) last_reset_value
. (If anybody has any suggestions on a better implementation, let me know!)
The Energy Dashboard is incompatible with sensors that reset every minute, so adding the parameters below does NOT work. See my updated approach in later comment.
#### IGNORE BELOW!!! IT IS INCOMPATIBLE WITH THE ENERGY DASHBOARD! #####
sensor:
- platform: mqtt
name: "Household Electricity Usage"
icon: mdi:transmission-tower
state_topic: "event/metering/summation/minute"
unit_of_measurement: 'kWh'
# the Energy Bridge returns "Watt-minutes" every minute in the "value"; convert it to kilowatt-hours
value_template: "{{ value_json.value | float / 60000 }}"
last_reset_topic: "event/metering/summation/minute"
# the "time" in the message is a Unix-like timestamp (in milliseconds) of the start of the last reading
last_reset_value_template: "{{ now().fromtimestamp(value_json.time / 1000).replace(tzinfo=now().tzinfo) }}"
device_class: energy
state_class: measurement
#### IGNORE ABOVE!!! IT IS INCOMPATIBLE WITH THE ENERGY DASHBOARD! #####
AFAIK, the Energy Dashboard requires the units to be kWh. Because this results in pretty small values, I also create a template sensor that converts the value back to Watts (technically, Watt-minutes, but for consistency with other things that report power usage, I’m calling it “Watts”):
- platform: template
sensors:
household_electricity_usage_w:
friendly_name: Household Energy
value_template: "{{ 'unknown' if states('sensor.household_electricity_usage') == 'unknown' else (states('sensor.household_electricity_usage') | float * 60000) | round(0) }}"
unit_of_measurement: 'W'
I can use this sensor to put a graph of electricity usage (in a history graph) on my dashboard, or put it in a badge, and see values like “972W” instead of “.0162 kWh”.
(Don’t forget to restart HA after changing your config.)
To set up the Energy dashboard, I went to the Energy config page, under Grid Consumption clicked Add Consumption. On the next screen, selected “Household Electricity Usage” from the dropdown, selected Use static price (the easiest, and close enough for estimating usage costs), and entered 0.19 USD/kWh. Clicked Save, then Next, Next and finally Show My Energy Dashboard.
Mine doesn’t show any data yet, but it says it can take a few hours? You should be able to go to Developer Tools > States and select sensor.household_electricity_usage
and see the value (and last_reset
timestamp) update each minute.