DTE (Powerley) Energy Bridge Endpoint error

Sure enough…

Install the mosquitto client

apt-get install mosquitto-clients

then you can watch all topics with:

mosquitto_sub -h 192.168.0.xxx -p 2883 -t '#'

if you need to auth…

mosquitto_sub -h 192.168.0.xxx -p 2883 -u user -P password -v -t '#'

happy hunting

1 Like

Thanks for the code. I am able to install mosquitto, but when I run that line, I get no response. If I have the debug option selected:

I wonder what I am doing wrong. The same thing happens when adding -u admin -P trinity (or any other username/password combination that I try). I know that port 2883 is listening, and port 1883 is not.

1 Like

In order to troubleshoot you’ll need to understand how everything works,

Your power meter actually has a zibgee sending unit builtin. The Bridge connects to your power meter via zigbee. The bridge is also running an IP Stack and a MQTT server so you can indirectly retrieve data from you power meter on an IP Network.

If you use the phone app, launching the app publishes a message to the topic “request/is_app_open” on bridges MQTT broker that in turn starts publishing data to the topic “event/metering/instantaneous_demand”

The best advice I can give you is:

  1. Make sure your bridge is “close” to your power meter. Knowing that the power meter actually talks Zigbee is helpfully. This is because Zigbee is a short distance wireless protocol on the 2.4Ghz spectrum. 2.4GHz is pretty crowded these days and you may be subject to interference. Making sure the bridge gets a strong signal helps.

  2. Try power cycling the bridge.

  3. If your bridge has a ethernet port try using that instead of the wireless interface.

  4. Make sure the phone app works. If you can get information from the phone app you should be able to poll the MQTT server directly.

  5. Try simulating the phone app.Open 2 terminal windows and try the following

Terminal 1 Subscribe to all topics verbosely

mosquitto_sub -h 192.168.1.122 -p 2883 -t '#' -v

Terminal 2 publish to topic remote/request/is_app_open

mosquitto_pub -h 192.168.1.122 -p 2883 -u admin -P trinity -t 'request/is_app_open' -m '{"request_id": "ha-monitor"}'
1 Like

So I was following this thread interested in using the connection for my own dashboard. Being new to MQTT alot of this went over my head.
For any one else in a similar situation I was able to use MQTTLens (A chrome extension)
To start viewing the data coming through. The only settings I need to input were the IP address of my device, and the port: 2883. after I subscribed to ‘#’ and was able to see messages coming through. If you don’t see any data try opening the app on your phone or publish the app request message like was said by Kidmock

After much ado, I found that the app wasn’t really grabbing data as consistently as possible, probably why there were no results from the Mosquitto. I factory reset the unit, but then it wouldn’t bind (in an apartment building, I’m pretty far from the meter TBH). I was able to get it to bind by setting up a cellular data hotspot + a USB battery bank and let it bind 2 feet from the meter. Then I slowly brought it in side, got it on my wired network, and it stayed connected. Finally I tried Mosquitto and it worked! I get an instantaneous demand! I’ve added it to my PRTG monitoring solution to great lovely graphs:

2 Likes

I was wondering if someone could help me get this working. I have a DTE Bridge v2. I am using MQTT Mosquitto broker to control some Tasmoto plugs and lights. In lovelace I see the entity DTE energy bridge but it shows Unknown.

In my configuration.yaml I have

mqtt:
    broker: 192.168.1.208
    port: 1883
    client_id: homeassistant-1
    username: my_mqtt_unsername
    password: mqtt_password

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

and under Mosquitto Broker under configuration I have the following:

logins: []
anonymous: false
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
connection: dte
address: '192.168.1.235:2883'
try_private: false
start_type: automatic
topic: 'event/metering/# in 0'

I get this in my Mosquitto broker logs. I think it sees the dte bridge, but I can’t get any data.

[05:27:09] INFO: Setup mosquitto configuration
[05:27:09] INFO: No local user available
[05:27:10] INFO: Initialize Hass.io Add-on services
[05:27:10] INFO: Initialize Home Assistant discovery
[05:27:10] INFO: Start Mosquitto daemon
1588933630: mosquitto version 1.6.3 starting
1588933630: Config loaded from /etc/mosquitto.conf.
1588933630: Loading plugin: /usr/share/mosquitto/auth-plug.so
1588933630: |-- *** auth-plug: startup
1588933630: ├── Username/password checking enabled.
1588933630: ├── TLS-PSK checking enabled.
1588933630: └── Extended authentication not enabled.
1588933630: Opening ipv4 listen socket on port 1883.
1588933630: Opening ipv6 listen socket on port 1883.
1588933630: Opening websockets listen socket on port 1884.
1588933630: Opening ipv4 listen socket on port 8883.
1588933630: Opening ipv6 listen socket on port 8883.
1588933630: Opening websockets listen socket on port 8884.
1588933630: Warning: Mosquitto should not be run as root/administrator.
1588933631: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1588933631: New client connected from 172.30.32.1 as home-assistant-1 (p2, c1, k60, u’homeassistant’).
1588933638: New connection from 192.168.1.218 on port 1883.
[INFO] found mqtt on Home Assistant
1588933640: New client connected from 192.168.1.218 as DVES_048B57 (p2, c1, k30, u’mqtt’).

You can narrow down your problems by using command line mqtt client:

  1. Direct to the Energy Bridge:
mosquitto_sub -h 192.168.1.235 -p 2883 -t '#' -v

Does that work? Do you see topics published?

  1. To your mosquitto broker all topics
mosquitto_sub -h 192.168.1.208 -p 1883 -u my_mqtt_unsername -p mqtt_password -t '#' -v 

Does that work do you see Topics for Tasmoto etc.?

  1. And lastly to your broker subscribing to just the topics from you bridge:
mosquitto_sub -h 192.168.1.208 -p 1883 -u my_mqtt_unsername -p mqtt_password -t 'event/metering/#' -v

If 1 doesn’t work check your network, power cycle the bridge, move the bridge close to you power meter or maybe your bridge just doesn’t work.

If 1 and 2 work and 3 doesn’t it’s your mosquitto config.

Thanks for getting back to me, I tried the above but not very knoledable with MQTT yet, I wasn’t sure how to do command line with MQTT. I did download a program called MQTT CLI which looks like it allows MQTT by command line… I wasn’t able to get any information but think I may be doing something wrong. I am looking into it to see if I am using it correctly. Also I installed MQTTLens which is an addon for chrome. I am able to connect to the energy bridge with MQTTLens but can’t get any messages when I publish “#”. Also set up a connection to my tasmota device but not able to see any messages from that either. So I am going to keep playing with it and see if I can figure it out.

The place where you put “connection dte” in is wrong.

Assuming you use hass.io, the configuration in the mqtt addon should contain

customize:
  active: true
  folder: mosquitto

Then samba into your home assistant, open the folder share, create a folder named “mosquitto” inside, then create a text file with a name of your choosing and extension .conf (e.g. dte.conf)

paste this into your that new text file

connection dte
address 192.168.???.???:2883
try_private false
start_type automatic
topic event/metering/# in 0

You also don’t need this in your configuration.yaml

mqtt:
    broker: 192.168.1.208
    port: 1883
    client_id: homeassistant-1
    username: my_mqtt_unsername
    password: mqtt_password

Hi everyone, long time lurker, first time poster. I’ve been watching HA and this thread for a long time. I am an AEP customer and they discontinued their Power Monitoring App on December 1st. So I figured it was time to setup Home Assistant and MQTT.

Thank you so much to everyone in this thread, and especially @dandelion and @kidmock.

Since the endpoint/topic, password, and setup have changed a few times, I thought I’d write up a how-to based on my experience. Hopefully this will help someone starting from scratch since AEP left us high and dry.

I think the following instructions should work regardless of how you setup Home Assistant, but I am running it in a VM. Additionally I setup a firewall rule on my router to prevent the power bridge connecting to the internet and possibly downloading some instruction to shut down. (hopefully that was a good idea).

  1. Install Home Assistant using the Getting Started Guide. https://www.home-assistant.io/getting-started/
  2. Install Add-ons: Supervisor -> Add-on Store
    • File Editor
    • Samba Share
    • Mosquitto Broker
  3. Configure Samba: Supervisor -> Dashboard -> Samba Share -> Configuration
    3.1 Edit the username (can be anything, used to connect to file share)
    3.2 Set a password for the share
  4. Restart the Host not just Home Assistant
  5. On another computer browse to the shared folder \\<IPofHomeAssistant>\share, using the username and password setup in step 3.
  6. Create a folder named “mosquitto” inside \share (\\<IPofHomeAssistant>\share\mosquitto)
  7. Create a text file named “dte.conf”
  8. Paste the following into dte.conf
    connection dte
    address <IP of Energy Bridge>:2883
    try_private false
    start_type automatic
    topic event/metering/# in 0
  1. Configure the MQTT Integration: Configuration -> Integrations -> MQTT
    9.1 Clik Configure
    9.2 Select MQTT Discovery
  2. Edit the Mosquito Broker Configuration: Supervisor -> Mosquitto Broker -> Configuration
    logins: []
    anonymous: false
    customize:
        active: true
        folder: mosquitto
    certfile: fullchain.pem
    keyfile: privkey.pem
    require_certificate: false
  1. Open File Editor: Supervisor -> File Editor -> Open Web UI
  2. Edit Configuration.yaml and add:
    sensor:
        - platform: mqtt
          name: "Energy Bridge"
          state_topic: "event/metering/summation/minute"
          unit_of_measurement: "W"
          value_template: "{{value_json.value}}"
  1. Turn on Advanced Mode: User Profile -> Advanced Mode
  2. Check for valid configuration: Configuration -> Server Controls -> Check Configuration
  3. Restart the Application: Configuration -> Server Controls -> Restart

I think that is it, but you may have to do a “IT Crowd special” and turn it all off and back on again.

I can’t wait to dig in more to Home Assistant, and thank you again to everyone in this thread.

1 Like

Any idea what is the latest user/password for Powerley AEP energy bridge?
I am getting:
$ mosquitto_sub -h 192.168.1.249 -p 2883 -t ‘#’ -v
Connection error: Connection Refused: identifier rejected.
$ mosquitto_sub -h 192.168.1.249 -p 2883 -u admin -P trinity -t ‘#’
Connection error: Connection Refused: identifier rejected.

Never mind, I figured out identifier was invalid. It is working now:
mosquitto_sub -h 192.168.1.249 -p 2883 -t ‘#’ -v -i powerley-energybridge-homecontrol
event/metering/instantaneous_demand {“time”:1607834226255,“demand”:1125}

1 Like

My AEP power bridge stopped working with update from Home Assistant OS 5.8 to 5.9. I just had it set up as an entity card to show instantaneous demand and now it says “Entity is non-numeric: sensor.aep_energy_bridge”. Does anyone know what would have changed in 5.9?

My configuration.yaml has:

sensor:
 # Main meter electrical flow courtesy AEP
 - platform: mqtt
   name: "AEP Energy Bridge"
   state_topic: "event/metering/instantaneous_demand"
   unit_of_measurement: 'W'
   value_template: "{{ value_json.demand }}"

mqtt:
  broker: 192.168.0.5
  port: 2883
  client_id: home-assistant-1
1 Like

For anyone who already has an MQTT server I wrote this simple Python 3.8 script to redirect messages from Powerly to their existing server.

Run it like this:

python mqtt_redirector.py <powerly addr>:2883 <MQTT addr> "powerly/"

Leave it running somewhere and all Powerly messages will be redirected to the “powerly/” topic on your existing server.

To integrate with HA, I created a script (Configuration -> Scripts) with the following sequence:

Action type: Call service
Service: mqtt.publish
Service data:
payload: |
  {
    "name": "Instantaneous power",
    "state_topic": "powerly/event/metering/instantaneous_demand",
    "unit_of_measurement": "W",
    "device_class": "power",
    "value_template": "{{ '{{ value_json.demand }}' }}",
    "unique_id": "powerlyinstantaneousdemand",
    "device": {
        "identifiers": ["powerlyenergybridge"],
        "name": "Energy Bridge",
        "model": "EB2.0",
        "manufacturer": "Powerley",
        "sw_version": "mqtt"
    }
  }          
retain: true
topic: homeassistant/sensor/powerly/instantaneous_demand/config
Action type: Call service
Service: mqtt.publish
Service data:
payload: |
  {
    "name": "Average power",
    "state_topic": "powerly/event/metering/summation/minute",
    "unit_of_measurement": "W",
    "device_class": "power",
    "value_template": "{{ '{{ value_json.value }}' }}",
    "unique_id": "powerlysummation",
    "device": {
        "identifiers": ["powerlyenergybridge"],
        "name": "Energy Bridge",
        "model": "EB2.0",
        "manufacturer": "Powerley",
        "sw_version": "mqtt"
    }
  }          
retain: true
topic: homeassistant/sensor/powerly/summation_minute/config

Press the run button and the energy bridge should show up as a new device.

1 Like

From the the error message, it sounds like your value might be interpreted as a string try making your value_template

value_template: "{{ value_json.demand | int }}"

or

value_template: "{{ value_json.demand | float }}"

Alternatively, I use the 1 minute summation topic instead of the demand topic

    state_topic: "event/metering/summation/minute"
    unit_of_measurement: 'W'
    value_template: "{{ value_json.value | round}}"

Any reason not to configure the existing MQTT broker to connect to the energy bridge directly (as shown in several of the the replies above)? That what I do with mosquito (my broker), and that seems simpler than relying on another process to act as a relay.


Also, for what it’s worth… I don’t log the “instantaneous demand” topic any more since it’s just that: an “instantaneous” reading of the power being used at the exact time the reading was taken. If a hair dryer using 1500W was turned off just prior to the instantaneous reading, it wouldn’t show any of the energy impact from the hair dryer. All those frequent instantaneous readings were just taking up space in the recorder / history database.

The useful reading is the “minutely summation”, which is actually measured in “Wmin” (watt-minutes), a unit of energy. Instead of being an instantaneous look at how much power is being used, this tells you how much energy was used in the last minute—even if a load was present for only part of that minute.

Since Wmin are not a very common unit, I use a template sensor to convert the reading to kWh (kilowatt-hours), which is the same unit commonly reported by other energy sensors (via MQTT with Tasmota, for example) so they can all appear on the same history graph.

For example:

sensor:
  - platform: mqtt
    name: Energy Usage
    state_topic: "event/metering/summation/minute"
    # technically “Wmin” but using “W” lets it appear on other “power” graphs
    unit_of_measurement: W
    value_template: "{{ value_json.value }}"

  - platform: template
    sensors:
      household_energy_kwh:
        friendly_name: Household Energy
        value_template: "{{ 'unknown' if states('sensor.energy_usage') == 'unknown' else (states('sensor.energy_usage') | float / 60 / 1000) | round(2) }}"
        unit_of_measurement: kWh

I feed the raw minutely summation data to the Utility Meter service to accumulate daily and monthly totals, like this:

utility_meter:
  monthly_energy:
    source: sensor.energy_usage
    cycle: monthly
  daily_energy:
    source: sensor.energy_usage
    cycle: daily

And then I convert that data to kWh, since that’s what I’m used to seeing on my bill:

  - platform: template
    sensors:
      daily_energy_kwh:
        friendly_name: Daily Energy
        unit_of_measurement: kWh
        value_template: "{{ (states('sensor.daily_energy') | float / 1000) | round (2) }}"

      monthly_energy_kwh:
        friendly_name: Monthly Energy
        unit_of_measurement: kWh
        value_template: "{{ (states('sensor.monthly_energy') | float / 1000 ) | round (2) }}"
1 Like

I appreciate the suggestions, but none of these are working for me on Home Assistant OS 5.9. I’m just going to chalk it up as a lesson not to upgrade things that are working.

I thought I’d try to get this working for me, so I tried connecting through MQTT Explorer to verify it had MQTT running.
Well it connects with any user and password, but no topics are seen.

Any ideas?

Rob

I got it working.
Ends up MQTT Explorer in Windows and some of the other apps don’t like the Energy Bridge server for some reason. Mosquitto_sub on the raspberry pi worked, but then I couldn’t get the Mosquitto Broker Add-on to act as a bridge using the gui confguration.
I tried adding the mosquitto directory and conf file to the config/share directory and the add-on couldn’t find conf file. I ended up using putty to get into the debug interface and adding the mosquitto directory to /mnt/data/supervisor/share which with the customize.active option set to true in the gui got it to act as a bridge.