rianadon / the-energy-detective-py

Unofficial library for reading from The Energy Detective power meters
0 stars 3 forks source link

Magic Number Identification #1

Closed realumhelp closed 2 years ago

realumhelp commented 2 years ago

After some playing around I found the following values for the magic numbers used in the interface XML:

MTD is based on a billing cycle which starts on the date listed in the Utility Rate Setup -> What is the Meter Read Date? Not sure if HA is expecting this to be based on the 1st of the Month or if it is configurable in HA. You can query the value with:

http://TED_HOST/api/UtilitySettings.xml
Parse results /w doc["UtilitySettings"]["MeterReadDate"]

Configuration/SystemType - Magic number definitions

0 = [NET] - Normal, your MAINs MTU will only see usage
1 = [NET + GENERATION] - Has energy generation that can feed your house as well as back-feed the utility.
2 = [NET + LOAD] - Has energy generation that only back-feeds to utility and not to the house.

Configuration/MTUType[1-4] - Magic number definitions

0 = [NET] -> NET = LOAD + GENERATION, ignores STAND-ALONE
1 = [LOAD] -> Special Type that ignores GENERATED and STAND-ALONE
2 = [GENERATION] -> Generated load ie: solar, wind, hydro. Usage values are negative to represent generation.
3 = [STAND-ALONE] -> Ensures usage is not double counted in NET or LOAD calculations, similar idea as Spyder CTs /w higher accuracy

The magic values would probably be better served as a Python Enum. Not sure if the HA interface needs anything special to denote a generated load or not as far as their energy statistics go.

rianadon commented 2 years ago

Enum sounds great. Would you like to write a PR? I can also get to it in a bit.

It would be very helpful to have the distinction between generation / load passed to HA! It'll be great to use to name the entities (Production / Consumption), but I don't know of anything else it could be used for.

I don't think meter read date will be useful for HA though. With the new-ish total_increasing state class, Home Assistant can figuring out when the meter drops to zero so we no longer need to figure out what exact time the sensor is resetting.

realumhelp commented 2 years ago

I don't think meter read date will be useful for HA though. With the new-ish total_increasing state class, Home Assistant can figuring out when the meter drops to zero so we no longer need to figure out what exact time the sensor is resetting.

That is good news. It would have been a bit tricky to deal with MTD Avg's otherwise.