Amber Electric (Australia) Custom Component

Thanks Tom - this helps.

I’m wondering if the price difference you are seeing is network specific. Sorry to use you as a guinea pig, but if you have semi-working code, I’ll get you to potentially raise a PR to help resolve this issue. To try and fix your issue around network, if you are on a recent version or sensor.py can you please try changing line 168 to

params["network"] = self.network_name

i.e. changing networkName to network and see if this works? I encountered something similar when writing tests yesterday but as no one had raised it I thought it was me.

If this does indeed work, we can merge your changes into the code base.

Thanks again,
Lewis

I actually had the wrong thing in my config (had been experimenting).
network_name: ‘Jemena’ does work - sorry I missed that.

But going back to the first part of my last post, it turns out the difference between the newest sensor file (says 2 months) and the older one (says 4 months), with regard to that particular line I posted is that there is no self. in front of the current_prices[0].wholesale_kwh_price near the end. Once I added the “self.” into it, it seems to be working?

Is this a deliberate omission, or something that was missed? Without me adding the self. I get sensor error

(Just to recap, I have the 4 newest files, but I added self. to those two lines. With just that change, I seem to have live prices. They aren’t showing exactly what the Amber app is showing, but are very close. Maybe this is due to the app having the half hour price and HA pulling the 5min price?)

Edit: it actually looks like the prices being drawn down in HA appear to be half an hour “ahead” of the forecast prices of the Amber app? Is this as expected?

so I can confirm that using sensor.py from June also works for me.
The price is not quite right though.
Amber app says 24c, hass says 22.77
solar in app is 10c, hass says 8.44

EDIT: Tuttle is right, I think it is showing the next 30 min pricing on mine now.

@knackers84 there’s a few other changes from the 4 month old sensor to the 2 month only sensor. (Like 5min pricing periods etc)
If you are having the same issues I was having, try just having the fresh 4 newest files, then edit sensor.py,

Once in sensor.py, find those two lines I mentioned above, and add
self.
to the two of them (one for general, one for solar)

It should read as self.current_prices[0].wholesale_kwh_price if it’s like mine.

I think that will work

done…
edit lines 97 and 100 and added self.

restarting now
broken again

AttributeError: ‘AmberPricingSensor’ object has no attribute ‘current_price’

And you put 4 fresh new files in (the four Lewis provided that are 22 hours old, and 2x 2 months)?

edit:
Doh!

priceS

I think it needs to be made plural for both.

I made both those changes
Plural, and the .self.

yeah, added an S, testing now.
Confirmed working with the S and the .self

1 Like

But is yours now showing “half an hour off”?
My 4:30pm price in HA is the Amber 4:00pm.

Right now it’s spiking but predicted to go down at 4:30pm, but HA is telling me there’s no spike right now (due to using the 4:30 price)

yeah. currently it is 46c, hass shows currently 33c, 4pm is 33c on app.
Best i turn off my automations for when power gets too expensive I guess.

So it appears for whatever reason (the changes we made to the sensor file?) the “current price” (Amber General Usage Price) being shown in HA is just the current “forecast” price. (for the half-hour).

So while we now have the sensor and entity working again, it’s not providing the actual live price that the Amber app is putting out?

Taken at 16:34:

These were taken at 16:37 when it updated to the next half hour:

Based on your feedback Ive taken a look at the sensor.py file. Could you please try this version to see if this now brings you to the correct values compared to the app?

hass-amber-electric/sensor.py at dev · lewisbenge/hass-amber-electric (github.com)

Thanks!

It broke again… sorry @lewisbenge

AttributeError: ‘AmberPricingSensor’ object has no attribute ‘current_prices’

Sorry that one was on me. I forget to hit save and pushed a version that still had an old reference. This one is current: hass-amber-electric/sensor.py at dev · lewisbenge/hass-amber-electric (github.com).

Fingers crossed this combines a fix for these issues - but if not I’ll take another look tomorrow.

1 Like

trying now… ohh that is looking good !
All working and displaying correct pricing now.
Nice one mate… thanks !

1 Like

Nice work Lewis - back up and running. Thanks! :grinning:

Thanks again Lewis, also working perfectly for me!
Hopefully it keeps on chugging along without issue for years to come :slight_smile:

Hi Jon, I’ve found the issue you faced in regard to data being displayed when you are charged to feed into the grid. To correct this, I’ll need to introduce a breaking change into the code.

The currently Amber’s data model, when calculating the cost of energy returns the FiT as a negative value (i.e. you are being charge -$0.08 per KW). In the original release of this code, I rounded this negative value to a positive to be in-line with how Amber displays the value in their app. So, when a positive value (i.e. you are now being charged $0.08 per KW) it was impossible to disambiguate the 2 in the sensor.

So to correct this issue, I need to revert to Amber’s data model where FiT’s will now return a negative value all the time they are revenue generating, and a postive value when they are being charged.

This change is staged in the dev branch on Github and ready to go - however I’d like to know if this may be too disruptive in people automations, as if so I can attempt to write some logic to invert this as per the current implementation, which will mean I won’t be able to correct until I get a bit more spare time. (If anyone else wants to attempt it, you need to remove the abs from ln 98/129 and then wrap a new method around the FiT)

Let me know your thoughts.

Thanks for making the change Lewis :slight_smile:
I’ll give it a crack, my automations are pretty simple, I expect the only changes will be changing
above: to
below: on a couple of automations.
Just for completeness it is possible for both power cost and feed-in to go negative at times, it’s not just feed-in.

Thanks for your continued effort and commitment to this, Amber should throw you a fish for sure!

hmm, my prices seem to be wrong again.
HA showing 46c, amber showing 35c
Anyone else?

Now it is correct. Must have been some weird 5m update thing making it go a bit screwy