TedPro, Ted 6000 Sensor Configuration

I purchased a TedPro (Ted6000) energy Meter. When i activated the built in Ted5000 sensor, it failed to initialize. This started me down the path to figure out what was wrong. The company that makes this device has changed the API. The xml has changed quite a bit. So i did some research and found the correct settings to get this to work under the TED5000 built in energy sensor. Here are the changes i made to get this to work.
You can find the file at

homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/ted5000.py

Change the following

"""Set up the Ted5000 sensor."""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
name = config.get(CONF_NAME)
url = 'http://{}:{}/api/LiveData.xml'.format(host, port)

“”“Initialize the sensor.”""
units = {‘W’: ‘power’, ‘V’: ‘voltage’}

mtus = int(doc[“LiveData”][“System”][“NumberMTU”]):

for mtu in range(1, mtus + 1):
power = int(doc[“LiveData”][“Power”][“MTU%d” % mtu]
[“PowerNow”])
voltage = int(doc[“LiveData”][“Voltage”][“MTU%d” % mtu]
[“VoltageNow”])

to
“”“Set up the Ted5000 sensor.”""
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
name = config.get(CONF_NAME)
url = ‘http://{}:{}/api/SystemOverview.xml’.format(host, port)

“”“Initialize the sensor.”""
units = {‘W’: ‘Value’, ‘V’: ‘Voltage’}
This section is under “”“Get the latest data from the Ted5000 XML API.”""

mtus = int(“1”)

for mtu in range(1, mtus + 1):
power = int(doc[“DialDataDetail”][“MTUVal”][“MTU%d” % mtu]
[“Value”])
voltage = int(doc[“DialDataDetail”][“MTUVal”][“MTU%d” % mtu]
[“Voltage”])

I hope this helps someone down the road. I wouldn’t mind if someone with better knowledge of Python could provide a better solution for the “mtus=int()” section.

Super interested in this. Is it possible for you put together some type of implementation guide for how to make this work?

I can try and put something together this weekend. I have also implemented a custom sensor for costs. Current costs and anticipated monthly bill.

Looking back i would think it best to implement everything thru a custom sensor.

Any chance you had a moment to put something together?

For starters i use home assistant on a Ubuntu server running under a python virtual environment.

I originally modified the built in TED 5000 sensor file to pick up the energy use from my TED. After thinking about this for some time i believe this is not the best choice. An update could possibly over write the file, etc.

Instead i believe you can just create custom sensors as needed.

This guide also assumes you have your TED already set up and operational as a stand alone device.

Record the ip number you configured for your TED unit.

  1. Start by creating a folder in your homeassistant folder. Name this folder “custom_components”. If this folder already exists you can skip this step.
    I also generated another sub folder titled “sensor”
  2. Generate a new file in the custom_components/sensor folder, mine is titled “ted6kHRLycost.py”
    Change the ip number in the “url1” section of the following copied code to match your TED unit.

Copy the following into the new file

import logging
from datetime import timedelta
import requests
import xmltodict
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle

REQUIREMENTS = [‘xmltodict==0.11.0’]

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)
url1= ‘http://192.168.10.4/api/DashData.xml?T=1&D=0&M=0

def setup_platform(hass, config, add_devices, discovery_info=None):
“”“Set up the Ted6000 sensor.”""
add_devices([TedCost()])

class TedCost(Entity):
“”“Implementation of a Ted6000 sensor.”""

def __init__(self):
    """Initialize the sensor."""
    self._state = None

@property
def name(self):
    """Return the name of the sensor."""
    return 'Current Cost'
    
@property
def state(self):
    """Return the state of the resources."""
    return self._state

@property
def unit_of_measurement(self):
    """Return the unit the value is expressed in."""
    return 'Dollars'

@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
     """Get the latest data from the Ted6000 XML API."""
     request = requests.get(url1, timeout=10)
     doc1 = xmltodict.parse(request.text)
     self._state = (int(doc1["DashData"]["Now"])/100)
  1. Now go to your Home assistant configuration file and add the following under your “sensor” section. Please make sure to verify proper indent as this is a yaml file.
  • platform: ted6kHRLycost
    close and save your configuration file

You can also reference the homeassistant website for more in site on how to configure a custom sensor,
Restart homeassistant, your new sensor should appear.

Ossey try that out and see if it works for you.

Thanks! Let me give it a try later this week.

Any movement on this? I’d like to see if/how TED’s are being use for Hass.

Thanks,

Ambi

Bump. Thinking of buying a TED Pro, wondering if I’m going to have issues?

Ive been trying to get this to work, but with no luck :frowning:

I decided against TED; I got the IotaWatt and it works great.

Trying this today, new Home Assistant user with an existing Ted Pro. I’ve set this up as you indicate, but Config is not finding the integration at all. I’m sure this is something simple, but for the life of me I can’t figure out what’s missing. Happy to do whatever debugging is necessary, once I get started.

I have changed the way I have been pulling the power reading. I’m only looking for the power use.

I added the following under the sensor section of my configuration file.

- platform: rest
  resource_template: http://192.168.10.4/api/DashData.xml
  name: Ted 5000
  scan_interval: 5
  value_template: "OK"
  json_attributes_path: "$.DashData"
  json_attributes:
    - "Now"
- platform: template
  sensors:
    ted5000_power:
      friendly_name: Power Consumption
      value_template: "{{ state_attr('sensor.ted_5000', 'Now') }}"


This is what my web browser is seeing from the Ted unit.

<DashData>
    <Now>4069</Now>
    <TDY>40365</TDY>
    <MTD>1547965</MTD>
    <Avg>58015</Avg>
    <Proj>1740463</Proj>
    <Voltage>1225</Voltage>
    <Phase>131</Phase>
</DashData>
1 Like

Thanks, that worked! I was also able to add the other readings by adding them to the “json_attributes” list and the “value_template” lists, and to define them as additional sensors.

Is there a way to scale the data? The values are in watts and watt-hours, voltage is in 0.1V units. Thanks for all the help!

1 Like

I’ve managed to integrate my TED Pro/6000. I have the Spyder so that I can read individual circuits, which is what I was really after. (The total panel load isn’t as useful due to how my property is wired overall)

I used Node Red to poll the XML api webpage that is exposed. (You can find it for your TED at the link that previous folks have mentioned, so http://YOUR.IP.HERE/api/SpyderData.xml if you have the Spyder)

Start with an injection node (I’m polling every 2 seconds, but still playing around wiht it). Then use the HTTP request node to the link for your TED API page. Then drop in an XML to JSON node since Home Assistant can’t natively read XML. Then a function node to read the data. My code for my node is below. Edit yours accordingly. Then I send my to my MQTT server to read into Home Assistant.

let spyderGroups = msg.payload.SpyderData.Spyder;

// Define sensor mappings
let sensors = {
    "barn/living_room": spyderGroups[0].Group[0].Now[0],
    "barn/lights_1": spyderGroups[0].Group[3].Now[0],
    "barn/lights_3": spyderGroups[0].Group[4].Now[0],
    "barn/lights_2": spyderGroups[0].Group[5].Now[0],
    "barn/well": spyderGroups[1].Group[0].Now[0],
    "barn/heat_pump": spyderGroups[1].Group[1].Now[0],
    "barn/dryer": spyderGroups[1].Group[2].Now[0],
    "barn/boiler": spyderGroups[1].Group[3].Now[0],
    "barn/water_heater": spyderGroups[1].Group[5].Now[0],
    "barn/server_rack": spyderGroups[1].Group[7].Now[0]
};

let messages = [];
for (let topic in sensors) {
    messages.push({ topic: "spyder/" + topic, payload: sensors[topic] });
}

return [messages];

I did setup my mqtt sensors in the configuration.yaml file so I could define units and device class, like so:

mqtt:
  sensor:
    - name: "Barn Lights 1 Power"
      state_topic: "spyder/barn/lights_1"
      unit_of_measurement: "W"
      device_class: power

I only imported the power readings and then used helpers in Home Assistant to create energy sensors from the power readings so I could import it into my Energy page.

Good Luck!

Here’s my full Node Red JSON if you’d like to see it:

[{"id":"spyder_flow","type":"tab","label":"Spyder Power Sensors","disabled":false,"info":""},{"id":"http_request","type":"http request","z":"spyder_flow","name":"Get Spyder Data","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://YOUR.TED.IP.HERE/api/SpyderData.xml","tls":"","persist":false,"proxy":"","authType":"","x":270,"y":240,"wires":[["xml_to_json"]]},{"id":"xml_to_json","type":"xml","z":"spyder_flow","name":"Convert XML to JSON","property":"payload","attr":"","chr":"","x":460,"y":140,"wires":[["split_sensors"]]},{"id":"split_sensors","type":"function","z":"spyder_flow","name":"Extract Sensor Data","func":"let spyderGroups = msg.payload.SpyderData.Spyder;\n\n// Define sensor mappings\nlet sensors = {\n    \"barn/living_room\": spyderGroups[0].Group[0].Now[0],\n    \"barn/lights_1\": spyderGroups[0].Group[3].Now[0],\n    \"barn/lights_3\": spyderGroups[0].Group[4].Now[0],\n    \"barn/lights_2\": spyderGroups[0].Group[5].Now[0],\n    \"barn/well\": spyderGroups[1].Group[0].Now[0],\n    \"barn/heat_pump\": spyderGroups[1].Group[1].Now[0],\n    \"barn/dryer\": spyderGroups[1].Group[2].Now[0],\n    \"barn/boiler\": spyderGroups[1].Group[3].Now[0],\n    \"barn/water_heater\": spyderGroups[1].Group[5].Now[0],\n    \"barn/server_rack\": spyderGroups[1].Group[7].Now[0]\n};\n\nlet messages = [];\nfor (let topic in sensors) {\n    messages.push({ topic: \"spyder/\" + topic, payload: sensors[topic] });\n}\n\nreturn [messages];","outputs":1,"x":680,"y":220,"wires":[["mqtt_out"]]},{"id":"mqtt_out","type":"mqtt out","z":"spyder_flow","name":"Send to MQTT","topic":"","qos":"0","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e9b5242fb5363506","x":880,"y":140,"wires":[]},{"id":"inject_trigger","type":"inject","z":"spyder_flow","name":"Trigger Every 2s","props":[{"p":"payload"}],"repeat":"2","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"str","x":100,"y":160,"wires":[["http_request"]]},{"id":"e9b5242fb5363506","type":"mqtt-broker","name":"mosquito","broker":"YOUR.MQTT.IP.HERE","port":1883,"clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":60,"cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]