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
"""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’}
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.
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.
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”
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
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)
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.
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.
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!