DTE (Powerley) Energy Bridge Endpoint error

I think I lost my energy bridge when we had a power outage on the 27th of May. I firewalled the IP so it couldn’t pull updates and was only available to local traffic. Previously, it’s always come back online if powered. I can ping it, and I see that the mqtt port is active, but that’s it. Are there any further debug steps to be done here?

/ # mosquitto_sub -h 172.16.1.10 -p 2883 -t '#' -v

<nothing happens>

/ # telnet 172.16.1.10 2883
Trying 172.16.1.10...
Connected to 172.16.1.10.
Escape character is '^]'.
1 Like

Has anyone been able to get this to work with the new Energy Management stuff? event/metering/summation/minute is reporting Watt-minutes, and I can set that state_class to measurement, and I can convert that to kWh with a template sensor, but I can’t add the state_class to the template sensor.

Just got this working today, but I had to setup the following:

Used the Integration sensor to convert the MQTT data to kWh.

- platform: integration
  source: sensor.dte_energy_bridge #Name of the MQTT sensor#
  name: energy_used
  unit_prefix: k
  round: 2

Then I put that data in the Utility Meter integration.

utility_meter:
  daily_energy:
    source: sensor.energy_used
    cycle: daily

The DTE app uses a static price of 0.19 / kWh so I just went with that.

Do you have a v2 unit?

If so, how exactly did you get it working? Looks like MQTT is the way, but I’m curious if any of the info shared above actually works with a v2 unit still.

I recently got my device not knowing that it was more a broken integration. I’d like to figure out how to connect this to the energy management features.

I’m struggling with getting this setup with my DTE Energy Bridge v2 as well. I actually went and dug out my old v1 device and it still powers up. Wondering if that would still function for me to tap into? Unfortunately can’t seem to get it to bind (I’m probably going about it wrong)

AFAIK the V1 Energy Bridge is no longer supported at all by DTE.

My V2 bridge has been working great with Home Assistant. Since the V2 Bridge can emit MQTT messages directly, no special integration for Home Assistant is required… just an MQTT broker.

I use Mosquitto.

On a device where you have Mosquitto (and thus mosquito_sub) installed, you should be able to run this to verify “you can get data”:

mosquitto_sub -h 192.168.1.102 -p 2883 -i some_identifier -t 'event/metering/summation/minute' -v

(replace 192.168.1.102 in the command above with the IP address of your Energy Bridge, “some_identifier” isn’t important and can be anything since we’re just testing).

When you run this command, you need to wait up to a minute for a “summation” of Watt-minutes in the last 60 seconds. Then you’ll get a new summation every minute.

Once that’s working, you then need to configure Mosquitto’s mosquitto.conf to connect to your Energy Bridge by adding:

connection dte
address 192.168.1.102:2883
start_type automatic
topic event/metering/summation/minute both 0

Finally, tell Home Assistant to connect to your Mosquitto broker (running at the .100 address in the example below), and then use the MQTT sensor as desired. This is what I use:

mqtt:
  broker: 192.168.1.100
  protocol: 3.1
  discovery: true
  discovery_prefix: homeassistant

sensor:
  - platform: mqtt
    name: "Household Electricity Usage"
    state_topic: "event/metering/summation/minute"
    unit_of_measurement: 'Wmin'
    value_template: "{{ value_json.value | round (1) }}"

utility_meter:
  monthly_energy:
    source: sensor.household_electricity_usage
    cycle: monthly
  daily_energy:
    source: sensor.household_electricity_usage
    cycle: daily
1 Like

Thanks for the info!

I have the MQTT broker installed from the add-on store and I was able to test with the sample line (adjusting for local IP of my DTE energy bridge), which appears to work… however, I just don’t understand how to use MQTT. EDIT: I still don’t fully get it, but hey, it’s producing information now…

Where and how did you edit this file? I don’t believe this is what goes into the topic and payload information in the configuration for MQTT in Integrations, right? Am I supposed to somehow access this file directly and edit through a text editor?

I understand the remaining, but this MQTT part is totally foreign to me, so I’m still trying to piece it together. Thanks.

Ended up creating the file directly in /share/mosquitto, which appears to have worked.

@eddyg Do you have these sensors configured with the Energy Dashboard?

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:

  1. Enable the customize flag:

    customize:
      active: true
      folder: mosquitto
    
  2. Create /share/mosquitto/dte.confand 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! :tada:

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”. :wink:

(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.

1 Like

Unfortunately it seems that the Energy Dashboard was not designed to handle a frequently-updating energy entity like the Energy Bridge which sends minutely summations. :disappointed:

The long-term statistics table (which the Energy Dashboard relies on) only records updates once per hour.

I tried using an hourly Utility Meter entity with a new state-based template sensor, but it doesn’t help, since the Energy Dashboard reads the hourly sensor once per hour, and so only gets the usage for the current hour up until the minute it reads it. (So if the Energy Dashboard reads it at 12 after the hour, the hourly utility minute only has 12 minutes of usage for the current hour.) We need some to get the previous hour’s total.

I can’t think of anything else to try at this point, but am open to suggestions.

Really appreciate the update and explicit instructions for set up!

I ended up testing this mini card format I found in this post on Reddit last night and noticed that the sensor.energy_spent entity shows up in the energy dashboard as an option. I’m still testing to determine how well it works, but sharing in case it inspires anything you’ve been doing here with your sensor tests.

I’ve been using what someone above has done. Here is what I have in all of my configurations and it seems to be working pretty well. However, I cannot get the DTE insight app to work so I can’t compare home assistant to their data.

./sensors.yaml:

  - platform: mqtt
    name: "DTE Energy Bridge"
    state_topic: "event/metering/summation/minute"
    unit_of_measurement: 'W'
    value_template: "{{ value_json.value }}"

  - platform: integration
    source: sensor.dte_energy_bridge #Name of the MQTT sensor#
    name: energy_used
    unit_prefix: k
    round: 2

./configuration.yaml:

sensors: sensors.yaml
utility_meter:
  daily_energy:
    source: sensor.energy_used
    cycle: daily

/share/mosquitto/dte.conf:

connection dte
address <ip addr:x.x.x.x>:2883
clientid homeassistant-1
try_private false
start_type automatic
topic # both 0

inside mosquitto Add-on configuration:

logins:
  - username: local-user
    password: <some password>
customize:
  active: true
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
anonymous: false
1 Like

Indeed, the mini-card graphs are what I’ve been using prior to trying to use the new Energy Dashboard. The cards look really nice, and they still work for me… my ramblings above were me hoping to add the “stuff” necessary to make the data from the Energy Bridge compatible with the Energy Dashboard as well.


There is no need to use the Integration integration with the minute/summation readings from the Energy Bridge. These readings are Watt-minutes, which is already measuring energy, not power, so integration is not necessary.

The Energy Bridge also sends event/metering/instantaneous_demand messages every 3 seconds, and these are instantaneous power readings (and thus measured in Watts) and those values would be suitable for integration via a Riemann sum.

But since the Energy Bridge is already generating “real” energy consumption readings every minute via the summation message, there is no need to store all the extra data and integrate those instantaneous power measurements. (This is also why my mosquitto.conf only subscribes to event/metering/summation/minute from the Energy Bridge. Subscribing to the # wildcard includes all the instantaneous_demand messages.)

Interesting. Maybe I’m not following what’s not connecting correctly for you in the Energy Dashboard. I mentioned the Reddit post above as I added those items as prescribed to my system and found that the sensor.energy_spent is reporting data through “energy_daily standard” and this shows up in the Energy Dashboard. It appears to be fairly close to the kWh and cost I see in the DTE Insight app. Should it not be?

It’s because of the Integration integration.

With that in place for the energy_spent sensor, it takes the minutely summation readings from the Energy Bridge (which are in Watt-minutes, already a unit of energy, not Watts, a unit of power) and treats them as “instantaneous” power readings, integrating that reading over time using the Riemann sum algorithm to estimate an energy reading.

It’s totally fine though… and probably a good work-around. The difference between doing the Riemann sum and simply summing the Watt-minutes values for the hour may even be negligible. It’s just technically incorrect, since you’re integrating energy values (which already have a time component, in this case, measured in Watt-minutes) instead of a power values (which are measured in something like Watts).

I’ve submitted a pull request to add support for differential value sensors (like the Energy Bridge) to the utility_meter integration. Right now, utility_meter only supports cumulative value sensors (so it always adds the difference between the current reading and the previous reading). With any luck, it will get approved and show up in a future release…

Edit to add: Using the Integration integration on the event/metering/instantaneous_demand MQTT message that gets sent every 3 seconds by the Energy Bridge would be correct, since those are power readings, measured in Watts, and the Riemann sum would integrate that to a fairly accurate energy reading since it is updated every 3 seconds… :wink:

Welp, looks like this temporary workaround has an expiration date.

Entity sensor.energy_daily_standard_cost (<class ‘homeassistant.components.energy.sensor.EnergyCostSensor’>) with state_class measurement has set last_reset. Setting last_reset is deprecated and will be unsupported from Home Assistant Core 2021.11. Please update your configuration if state_class is manually configured, otherwise create a bug report at Issues · home-assistant/core · GitHub

If anyone finds the best workaround for integrating this information into HA, please share!

I upgraded to 2021.9.6 yesterday and it seems like it may be working with a simple configuration like this:

  - platform: mqtt
    name: "Household Electricity Usage"
    unique_id: energy_bridge_summation_minute_kwh
    icon: mdi:transmission-tower
    device_class: energy
    state_class: measurement
    state_topic: "event/metering/summation/minute"
    # the summation message gives the "Watt-minutes" used each minute; convert it to "kiloWatt-hours"
    value_template: "{{ value_json.value | float / 60000 }}"
    unit_of_measurement: 'kWh'
    # 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) }}"

You’ll get a deprecation warning, but we can figure out how to address that in a later version.

The cost calculation isn’t correct (not sure what’s up with that), but the hourly graph of energy consumption matches the Insight app very closely on a couple hours I checked. For example, I “zoomed in” on the graph in the Insight app so it was displaying exactly one hour and it said “Total usage for 17:00-18:00: 1.3 kWh”, the Energy graph in HA showed 1.27 kWh for the same hour.

what is your config files

Sorry, my configuration no longer works as the meter itself will not emit the signal that the Powerley box reads to pull data. My electric company decided to stop the program. It’s a huge bummer.

When I enter the command nothing gets displayed, just constant cursor blinking after hitting enter

I get invalid topic ‘#’