Package: tedpy
TEDpyUnofficial library for reading from The Energy Detective power metersThis library supports the TED5000 and TED6000 devices.It is based on@realumhelp'sted6000py, Home Assistant's ted5000 implementation, and@gtdiehland@jesserizzo'senvoy_reader. Also huge thanks to@realumhelpfor helping write and review much of the code!UsagefromtedpyimportcreateTEDHOST='ted6000'# Use asyncio to deal with the async methodstry:reader=awaitcreateTED(HOST)awaitreader.update()reader.print_to_console()# Print all informationprint(reader.energy())# Total energyprint(reader.consumption())# Load energy onlyprint(reader.production())# Generated energy onlyprint(reader.mtus[0].energy())# Energy per MTUprint(reader.mtus[0].power())print(reader.spyders[0].ctgroups[0].energy())# Energy per ctgroupexcepthttpx.HTTPError:# Handle connection errors from createTED and updateTestingTo print out your energy meter's values, runpoetry run python -m tedpy.The module's tests can be run usingpoetry run pytest(make sure youpoetry installfirst!).DevelopmentInstall dependencies:poetry installInstall pre-commit hooks:poetry run pre-commit installDevelop!NotesSystem typesThe energy meter may be configured as 1 of 3 possibleSystemTypes:NET,NET_GEN, andLOAD_GEN(referred to in documentation asNET_LOAD).NET,GEN, andLOADare the possible MTU types defined as the following:NET: Consumption from the gridGEN: Solar power productionLOAD: Consumption from the grid, in the case where you are directly feeding the grid with solarIf you have not connected solar power to the meter, your system type is most likelyNET. Otherwise, you are likely usingNET_GENtype (measuring both grid consumption and solar power production). If you do not use an internal breaker for solar power and instead feed it directly back into the grid, you will haveLOAD_GENtype.The TED6000 API returns NET (net power), GEN (power generated), and LOAD (power consumed by appliances). Below is a table summarizing how these are populated for each system type.-(x)indicatesxis negated. Calculated fields are italicized.SystemTypeNETGENLOADNETtotal consumption00NET_GENgrid consumption-(solar power produced)grid consumption + solar power producedLOAD_GENgrid consumption - solar production-(solar power produced to grid)grid consumptionWhen using the.energy(),.production(), and.consumption()methods, the original values of the GEN column are inverted, and.consumption()is populated for theNETtype:SystemType.energy().production().consumption()NETtotal consumption0total consumptionNET_GENgrid consumptionsolar power producedgrid consumption + solar power producedLOAD_GENgrid consumption - solar productionsolar power produced to gridgrid consumptionInverted GEN valuesTo keep consistency with the.consumption()method, MTUs configured asGENwill additionally return positiveEnergyYieldvalues (i.e. their negative values will be inverted to positive values). It is recommended you format MTU values as such:data="Production"if(mtu.type==MtuType.GENERATION)else"Consumption"returnf"{mtu.description}{data}:{mtu.energy()}"TED5000 consumption and productionThe TED5000 API does not return a total system.production()and.consumption()value, so the library calculates one itself.
Production is defined as the energy sum of all MTUs marked as type "LOAD", and Consumption is defined as the energy sum of all MTUs marked as type "GEN".NET and stand-alone types of MTUs are not included in these totals, whereas they are included in the.energy()total of the system.TED5000 power factorSee#7for info on how the power factor is calculated. There is a field returned by the API, but the documentation does not mention this field so the power factor is instead calculated manually.