Red Energy Australia

Red Energy has finally released a mobile app (android, ios) to help track usage on the account directly.

I have sent in an inquiry asking them to allow access to this data via an integration for HA. I am sure if there is enough people that request this they may work on it or someone can try get something working via a custom integration.

3 Likes

this would be amazing! i just learned about the app today and would be awsome to automate based on my electricity usage. so much info avaliable in the app.

Yea its been a great app for checking in periodically and I do plan to have a shelly 3EM installed at the meter for my unit when I finally find someone that has the key for access to give me a validation data set to make sure its all reading correctly anyways.

I’m able to dig down as far as hourly usage which is nice.

Unfortunately there is no pricing data in the app that I can see, nor is there any mention of an API on their website. Not sure if it would be possible to integrate this one at the moment. Did you ever hear back from them @TH3xR34P3R ?

The only thing is that they said thank you for the interest and its something they may look into in the future, just your bog standard response with these things.

2 Likes

This implies that there is a API available:

Nice find, hopefully someone is able to take advantage of it and make an integration that knows how to make one.

Any updates? Wish I knew how to program, might be a good test for copilot :grinning:

Ive started to decompile their mobile app and see if i can work it out, but cant find anything helpful yet.

I might borrow my wifes iphone over the xmas period and see if i can MITMproxy the required data.

The app doesnt seem to have pricing, but it does have consumption data in it.

If anyone here has an iOS device, knows how to use MITMproxy and wants to assist, DM me as I wont get to that bit for a week or 2.

Hey, I did a quick introspection of the iPhone app traffic. Here’s a short summary:

It uses OAuth 2.0 / OpenID Connect flow, with okta (when using a username and password).

POST to https://redenergy.okta.com/api/v1/authn
with request body:

{
  "password": "xxxx",
  "username": "[email protected]",
  "options": {
    "warnBeforePasswordExpired": false,
    "multiOptionalFactorEnroll": false
  }
}

returns a response with a session token.

Requests discovery document:
GET https://login.redenergy.com.au/oauth2/default/.well-known/openid-configuration

This returns the endpoints for login:

{
  "issuer": "https://login.redenergy.com.au/oauth2/default",
  "authorization_endpoint": "https://login.redenergy.com.au/oauth2/default/v1/authorize",
  "token_endpoint": "https://login.redenergy.com.au/oauth2/default/v1/token",
  "userinfo_endpoint": "https://login.redenergy.com.au/oauth2/default/v1/userinfo",
  "registration_endpoint": "https://login.redenergy.com.au/oauth2/v1/clients",
  "jwks_uri": "https://login.redenergy.com.au/oauth2/default/v1/keys",
  ...
}

Sends auth request with locally generated nonce, and session token to:
GET /oauth2/default/v1/authorize?nonce=6jl-XNAylmt...

Returns a short lived auth code in the response.

Client sends POST https://login.redenergy.com.au/oauth2/default/v1/token

and receives back a JSON response with access token, refresh token etc.

An Oauth python library should make most of the above straight forward

From here, you can do a GET to https://selfservice.services.retail.energy/v1/customers/current
(there are other endpoints, but this one seems to have the data we’re interested in)

Response
(personal details removed)

{
  "currentUsage": {
    "fromDate": "2027-12-18",
    "toDate": "2028-01-15",
    "consumptionMj": 0.000,
    "consumptionKwh": 213.974,
    "isConsumptionDollarGstInclusive": false,
    "consumptionDollar": 85.38,
    "generationKwh": 50.659,
    "generationDollar": -2.53,
    "demandCharges": [],
    "maxDemand": 0.000,
    "demandUom": null,
    "demandDollar": 0.00,
    "carbonEmissionTonne": 0.2469,
    "isPricingReliable": true,
    "pricingUnavailabilityReasons": [],
    "averageMinTemperatureC": 0.0,
    "averageMaxTemperatureC": 0.0,
    "serviceToPropertyDollar": 26.00,
    "potdDollar": 0.00,
    "gstDollar": 10.90,
    "totalChargesDollar": 117.14,
    "demandKw": 0.000
  },
  "estimatedUsage": {
    "fromDate": "2024-12-18",
    "toDate": "2025-03-17",
    "consumptionMj": 0.000,
    "consumptionKwh": 1200.333,
    "isConsumptionDollarGstInclusive": false,
    "consumptionDollar": 264.98,
    "generationKwh": 157.218,
    "generationDollar": -7.85,
    "demandCharges": [],
    "maxDemand": 0.000,
    "demandUom": null,
    "demandDollar": 0.00,
    "carbonEmissionTonne": 0.7662,
    "isPricingReliable": false,
    "pricingUnavailabilityReasons": [
      "PRICING_IS_ESTIMATED_ONLY"
    ],
    "averageMinTemperatureC": 0.0,
    "averageMaxTemperatureC": 0.0,
    "serviceToPropertyDollar": 80.69,
    "potdDollar": 0.00,
    "gstDollar": 33.83,
    "totalChargesDollar": 300.54,
    "demandKw": 0.000
  },
  "estimationStatus": "STANDARD_ESTIMATE",
  "latestBillPeriodUsageTrendPercent": -32.8,
  "billedUsageTrend": {
    "asOfDate": "2025-01-16",
    "latestBillPeriodUsageTrendPercent": -32.8,
    "priorBillSummary": {
      "billId": "742Evergreen|3",
      "invoiceNumber": 987654321,
      "fromDate": "2024-06-20",
      "toDate": "2024-09-18",
      "consumptionKwh": 1150.000,
      "consumptionMj": 0.000
    },
    "latestBillSummary": {
      "billId": "742Evergreen|4",
      "invoiceNumber": 123456789,
      "fromDate": "2024-09-19",
      "toDate": "2024-12-17",
      "consumptionKwh": 773.000,
      "consumptionMj": 0.000
    }
  },
  "latestUsageDate": "2025-01-15",
  "estimationType": "PRESENT",
  "asOfDate": "2025-01-16",
  "currentUsageExplanation": {
    "summary": "Usage is actual usage since consumer has an INTERVAL meter and GCMDS data is complete for the period",
    "detail": ""
  },
  "projectedUsageExplanation": {
    "summary": "Usage has been estimated by scaling 29 days actual usage to 90 days",
    "detail": "Multiplying factor = 3.1034"
  },
  "estimationAlgorithmVersion": "V3_0"
}

Hope this helps!

Hi @dermotos. Thanks for this information, it gave me hope that I might be able to integrate my Red Energy usage stats into my Home Assistant.

For some bizarre reason I don’t have a password for Red Energy (nor can I get one). I enter my email address and then they send an email with a one-time code.

I tried using mitmproxy on Android to pull tokens on mobile but due to Android security not trusting CA certificates I was unable to progress…sadly.

Did you manage to get it working in the end?

I haven’t had a chance to spend any more time on this yet unfortunately. You should be able to use Proxyman to inspect the traffic on a physical Android device though, I do it all the time for work purposes. You can follow the setup steps, then just setup your WiFi connection on your device to proxy through the Proxyman app on your computer.

1 Like

Got a huge bill this week which sent me on a bit of a journey to see how I can get my energy data more visible to me. Ill probably get something going on a Raspberry Pi but thanks to all who did some prework. I have published what I have done below. Its far from perfect but I hope it helps someone.

Red-Energy-API

Not sure if it could be integrated into HA formally due to the way we are using the API but maybe someone can do something with a custom integration/HACS

4 Likes

Been playing around with ozietank’s Red-Energy-API and managed to dump the data that lined up with my last bill.

From there I was cleaning it up a little with DB Browser and used:

SELECT
    SUM(json_extract(h.value, '$.consumptionDollarIncGst')) AS totalDollarIncGst
FROM usage_data,
     json_each(usage_data.data, '$.halfHours') AS h;

to get a accumulative total over the same billing period. So using that info plus some preknown info its possible to get very close to the correct value (I was within $0.30 by the time I added it all up. The only data I couldn’t find yet was how they track the “Demand” costs, as well as I have a solar system and the usage data doesnt have the solar output in it eiher (maybe have to bring it in from the solar system itself?).

Now by this point im out of my depth but someone may be able to figure out how to tie it all together. We essentially need:

Usage data from the API + Demand Value (Unknown how to exctract) + Service to Property Charge (pre-determined value entered by user) - Solar (determine usage from solar app?) over preset billing days = Estimated costs

Edit: Pulled the exported data from my solar system which unfortunately doesnt match what the power company is seeing, but not in the direct i thought. Over the course of the billing month the solar system thinks it outputted about 289kWh of power where as the electricity company saw 361kWh worth of power.

I had a go at implementing a custom integration for this using the work that was done to extract the API logic.

I’ve been trying to get to testing it on my dev ha environment but I’m struggling to get the ClientID that is required. Any tips would be greatly appreciated?

If anyone wants to have a go the repository is here GitHub - craibo/ha-red-energy-au: Home Assistant Red Energy Integration
You’ll need to install it using HACS as a custom repository

1 Like

Great work!

But where do we find the client id in proxyman? Have all the info coming through but can’t seem to find it

Right now to figure out how to get HTTP Toolkit talking between my phone and my PC so that I can get that client ID lol.

@craibo I’ve tried your integration and have been unable to successfully login. Have created an issue in your repo. Let me know if I can assist with any further debugging.

1 Like

Struggling to capture my client_id as well.

If I point my device at a proxy (tried MITM Proxy and proxyman) with a user cert, the Red Energy reports an error.

With no cert, Red Energy connects but no OAuth details are visible.

I’ve created a Android Virtual Device and installed a MITM cert into system certificates, but then the Red Energy app reports an error and does connect properly. The Red Energy app reports an error even without the proxy inline, so maybe an issue with the apk I’ve downloaded outside of the Play store as I’m using an ASOP image???

Tried to find an old phone that I can root, but no luck as of yet…

Any advice on capturing the client id would be appreciated!

I have released a new version that fixes the Authentication issue and adds a bunch more fields, high level.

There is another version I have in testing which will allow more low level breakdown fields for import, export on both usage and costs.

Hopefully I’ll have time to finish testing and get this release out soon

1 Like