lewisbenge / hass-amber-electric

Home Assistant Component to pull the latest energy prices from Amber Electric
MIT License
27 stars 7 forks source link

** ATTENTION ** #25

Open davewatson91 opened 3 years ago

davewatson91 commented 3 years ago

I have been in contact with Amber -> this API will be deprecated over a 6 month period, with a new API almost ready for release. One of the developers at Amber (creating the API, will also be developing (in his personal capacity I believe) an integration for Home Assistant.

bengAThome commented 3 years ago

Interesting development!

On Fri, 28 May 2021, 3:01 pm David Watson, @.***> wrote:

I have been in contact with Amber -> this API will be deprecated over a 6 month period, with a new API almost ready for release. One of the developers at Amber (creating the API, will also be developing (in his personal capacity I believe) an integration for Home Assistant.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL2ZXXUVJYSXFZ6WKKDTP4PQZANCNFSM45VXORJQ .

micarex commented 3 years ago

I was in contact with them last week as well. I noticed that during the recent price spikes in my area that the API was returning drastically different results to the app. They confirmed that they have done a lot of recent work on the pricing in the app but haven't updated the API accordingly. They then confirmed they are working on a new API but they didn't say one of their devs was going to develop the HA plugin, so that's good news.

davewatson91 commented 3 years ago

at they have done a lot of recent work on the pricing in the app but haven't updated the API accordingly. They then confirmed they are workin

Have noticed the same - we've had some horrible spikes of recent - almost enough to question our change from our previous provider.... Having the API working would certainly help us with mitigating some costs, but it's hard to mitigate with hours of $1+ spikes per evening.

I suspect maybe he's not advertising it too much, as I suspect it will not be an official Amber integration? Hopefully it won't take too long until we see it up and running!

bengAThome commented 3 years ago

Yeah these spikes have been challenging, I was thinking the same that it might be better to go back to single tariff. However the average still seems to be working out. I hope whoever at Amber that does the Dev work engages with us though, and does not just do it on their own...

On Wed, 2 Jun 2021, 8:33 am David Watson, @.***> wrote:

at they have done a lot of recent work on the pricing in the app but haven't updated the API accordingly. They then confirmed they are workin

Have noticed the same - we've had some horrible spikes of recent - almost enough to question our change from our previous provider.... Having the API working would certainly help us with mitigating some costs, but it's hard to mitigate with hours of $1+ spikes per evening.

I suspect maybe he's not advertising it too much, as I suspect it will not be an official Amber integration? Hopefully it won't take too long until we see it up and running!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-852526622, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSLZL7OL5NZS46HZL66TTQVNZ3ANCNFSM45VXORJQ .

madpilot commented 3 years ago

I'm the Amber Dev 👋

madpilot commented 3 years ago

I suspect maybe he's not advertising it too much, as I suspect it will not be an official Amber integration?

Once I've got something that I can start showing you all, I will. The plan is to have it part of Home Assistant core, rather than a custom component, but to start with a custom component makes the most sense, but that won't happen until we finish the API work, which is close, but we are a small team, and my attention is diverted on almost a daily basis.

Big ups to @lewisbenge for getting this component out! I'm using his integration at the moment too. I've been controlling my ducted air conditioning based on network prices (using the same wrong API as all of you - I can't even get access to it remotely yet, and I'm the one writing it!) - it's definitely helped me make a business case for this work.

bengAThome commented 3 years ago

Great to hear Myles! I agree, the current API isn't perfect, but I am manually using it as a check before using power hungry devices, like dryers etc I'm working on using RGB LEDs to provide a traffic light style indication near all these devices, with a bit of extra intelligence. Eg green for cheap etc, but also have them animate the direction. Eg green going Amber red to indicate the price direction is heading up.

The second piece of the puzzle is to get real-time power usage. (Currently using Powerpal) but want to get it automatic too.

On Wed, 2 Jun 2021, 10:12 am Myles Eftos, @.***> wrote:

I suspect maybe he's not advertising it too much, as I suspect it will not be an official Amber integration?

Once I've got something that I can start showing you all, I will. The plan is to have it part of Home Assistant core, rather than a custom component, but to start with a custom component makes the most sense, but that won't happen until we finish the API work, which is close, but we are a small team, and my attention is diverted on almost a daily basis.

Big ups to @lewisbenge https://github.com/lewisbenge for getting this component out! I'm using his integration at the moment too. I've been controlling my ducted air conditioning based on network prices (using the same wrong API as all of you - I can't even get access to it remotely yet, and I'm the one writing it!) - it's definitely helped me make a business case for this work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-852582331, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL3RBZEX4GFQBIN3JHLTQVZOZANCNFSM45VXORJQ .

madpilot commented 3 years ago

The new API will have 24-hour delayed usage, but we don't have access to real-time at the moment. For reactive real-time (ie, how much power are you using this instant) Powerpal or Eagle 200 (or similar) or getting a battery with an API are your best bet

davewatson91 commented 3 years ago

The new API will have 24-hour delayed usage, but we don't have access to real-time at the moment. For reactive real-time (ie, how much power are you using this instant) Powerpal or Eagle 200 (or similar) or getting a battery with an API are your best bet

I've actually just setup ESPHome on an ESP32 to use the CircuitSetup board. I have to admit that this is the best bit of energy monitoring that I've ever used - its accurate, configurable and running ESPHome make it super easy. I will be interested to pull the stats in, but the 24hr delay is still OK for that, so long as the real time pricing is spot on :)

Let us know if you need any help in getting the component off the ground (or working for core)- it is definitely super valuable (I'm switching A/C, Hot Tub & Hot Water Service currently, which combined can avoid inadvertently using 14kWh)

madpilot commented 3 years ago

ESPHome on an ESP32 to use the CircuitSetup board.

Nice! I'm investigating using Zigbee to talk to my smart meter, as it's non-intrusive. However, my meter is quite far from my house and has (ironically) no power, so the Eagle 200 won't work. I'm looking at homebrewing something, possibly solar powered.

bengAThome commented 3 years ago

That's a nice board! Definitely an option once I can afford it :) Powerpal us a great device, but no API. The 24hr delay is fine for me too. It's the spot price that I'd like to be 💯 accurate.

On Wed, 2 Jun 2021, 10:45 am David Watson, @.***> wrote:

The new API will have 24-hour delayed usage, but we don't have access to real-time at the moment. For reactive real-time (ie, how much power are you using this instant) Powerpal or Eagle 200 (or similar) or getting a battery with an API are your best bet

I've actually just setup ESPHome on an ESP32 to use the CircuitSetup board https://circuitsetup.us/product/expandable-6-channel-esp32-energy-meter/. I have to admit that this is the best bit of energy monitoring that I've ever used - its accurate, configurable and running ESPHome make it super easy. I will be interested to pull the stats in, but the 24hr delay is still OK for that, so long as the real time pricing is spot on :)

Let us know if you need any help in getting the component off the ground (or working for core)- it is definitely super valuable (I'm switching A/C, Hot Tub & Hot Water Service currently, which combined can avoid inadvertently using 14kWh)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-852612103, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSLZXGT5VL5M4EY3TRPLTQV5KZANCNFSM45VXORJQ .

davewatson91 commented 3 years ago

ESPHome on an ESP32 to use the CircuitSetup board.

Nice! I'm investigating using Zigbee to talk to my smart meter, as it's non-intrusive. However, my meter is quite far from my house and has (ironically) no power, so the Eagle 200 won't work. I'm looking at homebrewing something, possibly solar powered.

Unfortunately the smart meter I have doesn't have the Zigbee option, only GSM from what I could dig up :( That was ultimately my first goal. The beauty of the CircuitSetup board is that I can manage individual circuits, and take into account power factor, reverse current and such. Example of how I'm currently setup (although not my final intent, just the quick and dirty to get up and running). I've got rules setup to run things when I'm exporting power and such.

image

bengAThome commented 3 years ago

That looks 1000 times better than my dashboard lol.

On Wed, 2 Jun 2021, 11:06 am David Watson, @.***> wrote:

ESPHome on an ESP32 to use the CircuitSetup board.

Nice! I'm investigating using Zigbee to talk to my smart meter, as it's non-intrusive. However, my meter is quite far from my house and has (ironically) no power, so the Eagle 200 won't work. I'm looking at homebrewing something, possibly solar powered.

Unfortunately the smart meter I have doesn't have the Zigbee option, only GSM from what I could dig up :( That was ultimately my first goal. The beauty of the CircuitSetup board is that I can manage individual circuits, and take into account power factor, reverse current and such. Example of how I'm currently setup (although not my final intent, just the quick and dirty to get up and running). I've got rules setup to run things when I'm exporting power and such.

[image: image] https://user-images.githubusercontent.com/51277302/120408498-80e40200-c392-11eb-8fb2-1e24158f6e1b.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-852629940, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL2TU2LZ3TM4BTP6T6DTQV7Z5ANCNFSM45VXORJQ .

madpilot commented 3 years ago

How is everyone writing their automations? YAML, UI, NodeRed, Appdaemon, other?

davewatson91 commented 3 years ago

I migrated to NodeRed about 6 months back, and surprisingly haven't looked back. Running HA / NodeRed in Docker (amongst 20 other containers).

bengAThome commented 3 years ago

Mixture some Yaml, some node-red. Plus use grafana for those sweet graphs :)

On Wed, 2 Jun 2021, 11:28 am David Watson, @.***> wrote:

I migrated to NodeRed about 6 months back, and surprisingly haven't looked back. Running HA / NodeRed in Docker (amongst 20 other containers).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-852640109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL4X3ABD6KFUG4OUDHDTQWCMBANCNFSM45VXORJQ .

micarex commented 3 years ago

How is everyone writing their automations? YAML, UI, NodeRed, Appdaemon, other?

I'm currently using the UI for my automations but I'm in the process of adding AppDaemon because I need to execute more complex logic than what the HASS automations allow. I also need to send REST APIs calls with Digest authentication to my Fronius inverter from a script and as best I can tell, there's nothing in HASS that can do this at the moment.

I'm switching hot water heating, reverse cycle aircon, wireless GPOs (Ikea Tradfri) and wired GPOs (NetIO), and charging battery from grid when Amber price is low and discharging when price is high. The built in automations do a good job for simple tasks and I'll keep them going, but I need to start writing custom Python to add more complex stuff. I'm also doing my more complex graphing & analysis in InfluxDB 2.

Example InfluxDB 2 image

Example HASS Dashboard image

davewatson91 commented 3 years ago

@micarex intrigued as to how you're controlling the flow to/from the grid?

Why the appdaemon vice something like NodeRed?

micarex commented 3 years ago

@micarex intrigued as to how you're controlling the flow to/from the grid?

Why the appdaemon vice something like NodeRed?

I probably could use node red and write my complex logic in js. However I've already written quite a lot of python code to do what I want. I wrote it before I discovered HASS so I figure it is easier for me to keep going with python. I'm in the process of writing a trading algorihtm which detects the best price ranges during the day to buy and sell energy and then I need to control the relays to turn devices on/off based on those time periods. So far I've been using somewhat fixed values (e.g. If Amber feed is price is greater than 15c then discharge battery to grid, but I'm now moving to more sophisticated approach of figuring out the optimum time based on forecast prices. Also determining whether to discharge/charge battery is also heavily influenced by other variables such as time of day and battery SOC. e.g. No point discharging battery and exhausting battery energy at 5 p.m. at 15c feed in if I am only going to have to buy it back at 6-7 pm at 30c to cater for evening energy usage.).

As for grid flow, at the moment it is fairly simple (in logic) right now which is why I want to improve it.

It have a set of HASS automations which are triggered based on the Amber pricing. image

Based on thresshold values I then run scripts to send MODBUS commands to my Fronius inverter to tell the battery to charge/discharge.

image

But I'd like to improve these to charge at a calculated percentage rate depending on forecast pricess too.

micarex commented 3 years ago

I found that one of the unintended consequences of setting the battery to discharge to grid is that the Fronius inverter then turns on my hot water and aircon relays at the wrong time because the smart meter tells the Fronius that there is excess energy flowing to the grid and under normal circumstances this means I have excess solar going to the grid so I want to consume the energy via hot water heating and running aircon (heating) rather than getting paid a pittance to send it to the grid. However the so called 'smart meter' has no idea why energy is flowing to the grid. So when the battery is discharging to the grid I need to turn off the Fronius relay automations to stop it consuming the energy I am deliberately trying to send to the grid when Amber price is high. This requires me to send a REST API call using digest authentication to the Fronius Inverter.

davewatson91 commented 3 years ago

So they're the same logic pains that I'm running through now. Balancing it with trying to make sure that the hot-tub and hot water service get enough periods of running throughout the day to stay hot, while trying to optimise using the cheapest prices..

What sort of battery storage are you running with the fronius? I've been tossing up with this as the next logical step....

The direction of flow has also been something I've been working on. Turns out that the smart meters are useless for it, but the power monitor I mentioned above does handle current flow direction - has helped with that same problem.

davewatson91 commented 3 years ago

What model Fronius are you running?

micarex commented 3 years ago

What model Fronius are you running?

I have two. A Primo 4.0kw and I also have a Primo Gen24 6.0kw hybrid inverter. I am on the beta program for the Gen24 and the largest model they make is 6.0kw at the moment, so I had to get the Primo 4.0 to make a 10kw system (with 12.54kw of panels). I use the Gen24 for all the smart stuff because it has much more advanced power control. Having said that, most of the stuff I'm doing can also be done with the Primo (or the 3 phase Symo).

micarex commented 3 years ago

Refer https://www.mcelectrical.com.au/wp-content/uploads/2017/02/Fronius_Feature.x29689.pdf page 5 for the basic concept. The Fronius inverters have 4 inbuilt 12v relays that can be use to control contactors to switch 240v loads.

micarex commented 3 years ago

I am using a BYD Battery Box HVM 11.04kwh battery. This is the Fronius recommended battery for use with the Gen24 inverters now that they don't produce batteries themselves.

micarex commented 3 years ago

Can you elaborate on the direciton of flow issue. I can tell direction of flow using my Fronius Smart meter. Power values are negative or positive depending on direction of flow. Refer Power Grid guage in the screen shot I posted. It shows +1016.88w where one I have taken just now shows negative.

image

davewatson91 commented 3 years ago

Yeah ok - so that's the same, and you have the same generation stats - why not roll those metrics as a conditional check into the automations for the relays? (i.e. if producing x watts, don't turn off, or if feed in tarrif is high, don't turn on, to maximise production).

micarex commented 3 years ago

Yeah ok - so that's the same, and you have the same generation stats - why not roll those metrics as a conditional check into the automations for the relays? (i.e. if producing x watts, don't turn off, or if feed in tarrif is high, don't turn on, to maximise production).

I'm already doing some checks of metrics in the HA automations, but there's a more fundamental limitation that I came across.

The problem is that the Fronius relay setting are not that sophisticated. And HASS can't actually control the relays directly because there is no published REST API or MODBUS commands to control the relays. You just set the values in the UI. e.g.

image

So my automations are currently split between HA and the Fronius inverter. The Fronius does hot water diversion and reverse cycle aircon, and I'm using HA for battery charge/discharge and GPOs.

My next step is to get HA to control the lot so that they all work in harmony. I had to figure out a way for HA to control the relays. This bit was very tricky. Since there is not official interface on the inverter to make this happen, I ended up sniffing the network traffic with wireshark between the UI and the inverter. Turns out there is a set of internal APIs and JSON values that I have learned to mimick. Using this method I can control the configuration of the relays (on/off and thressholds) programmatically. However the Fronius requires digest authentication for the internal APIs to work. I have a few hundreds lines of python to do the digest auth and construct the appropriate API calls. I successfully got this running via AppDaemon a couple of weeks ago.

So that was a long answer to your question, but now I should now be able to automate the lot from HA dynamically setting the relays settings on the Fronius. And I can incorporate whatever other conditions and variables into the mix as you've suggested.

davewatson91 commented 3 years ago

yeah wow - I missed the fundamental piece about the relays not being externally controllable.

I will be bookmarking this, after reading up on the fronius, it looks like it may fit the bill for what I need.....

Thanks!

bengAThome commented 3 years ago

Just curious, how will you go with the remote power grid control? Where they will turn off your export if the grid gets unstable.

On Mon, 7 Jun 2021, 1:57 pm David Watson, @.***> wrote:

yeah wow - I missed the fundamental piece about the relays not being externally controllable.

I will be bookmarking this, after reading up on the fronius, it looks like it may fit the bill for what I need.....

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-855556407, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL4Z753545DY6VSSZOLTRQ7QZANCNFSM45VXORJQ .

micarex commented 3 years ago

Just curious, how will you go with the remote power grid control? Where they will turn off your export if the grid gets unstable.

Thankfully this doesn't happen in Vic yet. But if it does get introduced the Fronius Gen24 inverter supports it via the built in Demand Response Modes. I haven't thought much about it, but I would likely compare the PV production against the amount going to the grid and ramp up my consumption based on whatever the grid refuses to take. I might be able to read the DRM modes via MODBUS as well to make this easier, but I haven't checked.

gorillica commented 3 years ago

@davewatson91, how did you set up your Lovelace dashboard, particularly the graph of price prediction? I've been wracking my brains over that!

Glad to hear that there’s the prospect of progress with the new API, @madpilot! I'm only a new Amber customer (haven't even had a smart meter installed yet), but am looking forward to getting automations in Node-Red to turn off high-draw devices (ACs, floor heating, perhaps even dishwasher/washing machine to prevent them being turned on during price-spikes…).

davewatson91 commented 3 years ago

It's certainly not mine! - Credit comes from here: https://community.home-assistant.io/t/apexcharts-card-a-highly-customizable-graph-card/272877/48

My lovelace code below:

type: custom:apexcharts-card
graph_span: 48h
header:
  show: true
  title: Amber Price Prediction (General Usage - E1)
span:
  start: hour
  offset: '-24h'
apex_config:
  chart:
    type: area
    height: 300
  stroke:
    show: true
    width: 2
    curve: smooth
  legend:
    show: false
  dataLabels:
    enabled: false
  xaxis:
    type: datetime
    labels:
      datetimeFormatter:
        month: ddd
        day: ddd
  fill:
    type: gradient
    gradient:
      shadeIntensity: 1
      inverseColors: false
      opacityFrom: 0.45
      opacityTo: 0.05
      stops:
        - 20
        - 100
        - 100
        - 100
series:
  - entity: sensor.amber_general_usage_price
    name: Predicted Price
    type: area
    extend_to_end: false
    data_generator: |
      return entity.attributes.price_forcecast.map((entry) => {
        return [new Date(entry.pricing_period), entry.price];
      });
  - entity: sensor.amber_general_usage_price
    name: Historic Price
    type: area
    extend_to_end: false
type: custom:apexcharts-card
graph_span: 59h
header:
  show: true
  title: Amber Price Prediction (Solar Feed-In)
span:
  start: hour
  offset: '-1d'
apex_config:
  chart:
    type: area
    height: 300
  stroke:
    show: true
    width: 3
    curve: smooth
  legend:
    show: false
  dataLabels:
    enabled: false
  xaxis:
    type: datetime
    labels:
      datetimeFormatter:
        month: ddd
        day: ddd
  fill:
    type: gradient
    gradient:
      shadeIntensity: 1
      inverseColors: true
      opacityFrom: 0.45
      opacityTo: 0.05
      stops:
        - 20
        - 100
        - 100
        - 100
series:
  - entity: sensor.amber_solar_feed_in_tariff
    name: Predicted Price
    type: area
    extend_to_end: false
    data_generator: |
      return entity.attributes.price_forcecast.map((entry) => {
        return [new Date(entry.pricing_period), entry.price];
      });
  - entity: sensor.amber_solar_feed_in_tariff
    name: Historic Price
    type: area
    extend_to_end: false
bacco007 commented 3 years ago

That's my setup! :)

I hope it still works I haven't had a chance to look at it recently

davewatson91 commented 3 years ago

That's my setup! :)

I hope it still works I haven't had a chance to look at it recently

Thanks for sharing originally - certainly working for me still!

gorillica commented 3 years ago

Thanks, @davewatson91 and @bacco007! That's really helpful. I've been meaning to try the Apex Charts card, but have been a bit daunted. I've got the historic data showing now, but will need to fiddle, as your data generator for the forecasts doesn't seem to be working for me on first try…

J-Lich commented 3 years ago

Thanks @bacco007! Still using your setup also. works well. Keen to see this new API and what it brings!

Screenshot_2021-06-12 13 32 46_5vGP16

chiefcomm commented 3 years ago

Hi @davewatson91 I'm interested in the CircuitSetup board. Did you source locally or from the US? Ultimately what power supply did you go with as I do not want to blow mine apart when it arrives :-) I should add I'm in Australia therefore need a AU power supply...

davewatson91 commented 3 years ago

Hi @davewatson91 I'm interested in the CircuitSetup board. Did you source locally or from the US? Ultimately what power supply did you go with as I do not want to blow mine apart when it arrives :-) I should add I'm in Australia therefore need a AU power supply...

Sourced straight from the US.. Shipping was quite painful, and got held up in customs for a fortnight in Aus.

Power supply was a nice easy one from Jaycar - worked a treat. Running ESPHome on mine, and doing the rest in Home Assistant.

adampetrovic commented 3 years ago

Is this the new API we're looking for? cc @madpilot

https://app.amber.com.au/developers/

madpilot commented 3 years ago

Yup.

I should have a new HA component in the next day or two. Unfortunately the Python OpenAPI generator did a hatchet job, so I needed to build the interface manually

davewatson91 commented 3 years ago

Yup.

I should have a new HA component in the next day or two.

Wow, super impressed with your turnaround. Looking forward to it!

Thankyou very much!

chiefcomm commented 3 years ago

Yup.

I should have a new HA component in the next day or two.

Legend love your work, can't wait to start using it. Thanks

madpilot commented 3 years ago

Here's a really early cut: https://github.com/madpilot/hass-amber-electric

image

It's not really well tested yet, but i you are feeling lucky, install it and start giving me feedback (on the other repo).

If you aren't a dev, this may very well break, so maybe wait until it's a little more stable... 😄

davewatson91 commented 3 years ago

About to have a play. Looks like issues aren't open on your new repo.

Also because you forked it from the other one, I can't work out how to fork it again (since this is already a fork) - wanted to update the API url on the instructions (url should be https://app.amber.com.au/developers/ I believe)

madpilot commented 3 years ago

Just turned them on

bengAThome commented 3 years ago

Fantastic news! I'm not able to test it for a couple if weeks but will definitely give it a shot as soon as I can.

On Tue, 22 Jun 2021, 4:46 pm Myles Eftos, @.***> wrote:

Just turned them on

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lewisbenge/hass-amber-electric/issues/25#issuecomment-865644077, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTQSL53QB27QTYTHAZQOLTTUAWS3ANCNFSM45VXORJQ .

mikemortimer commented 3 years ago

@madpilot 🙏 awesome work! working really really well

bacco007 commented 3 years ago

Bugger - looks like I cant move across, was tracking the cost to see how it aligned with our usage before committing - now you need an account to log in.

Good work though! Good to see it get some support

chiefcomm commented 3 years ago

@madpilot this is terrific, love your work. image