BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
535 stars 49 forks source link

Redemption of Octoplus Points automatically #805

Closed Nurgus closed 2 months ago

Nurgus commented 3 months ago

Describe the feature

Is it possible to redeem Octoplus Points? If not, is it possible to add this feature? I don't see any point in holding them, just redeem them automagically.

Expected behaviour

A service call to redeem some or all Octoplus Points

Use Case

Octoplus Points redeemed automatically.

Confirmation

BottlecapDave commented 2 months ago

Hello and sorry for the late response.

This should be possible. There are limitations on number of points that are redeemable (number has to be divisible by 8). Therefore when added it should include the following

  1. The points sensor should be updated to include an attribute which determines the number of redeemable points.
  2. A new service (octopus_energy_redeem_all_redeemable_points) which takes the applicable points sensor and calls the api endpoint providing the value of the above attribute. 2a. If there are no redeemable points available, an error should occur 2b. Upon success, should remove the number of redeemed points from both the attribute and state.
  3. Unit and integration tests for the above
  4. Blueprint which calls the service if the redeemable points attribute goes over a configurable threshold.

Example API call

mutation redeem_points($accountNumber: String!) { 
  redeemLoyaltyPointsForAccountCredit(input: {
    accountNumber: $accountNumber,
    points: 8
  }) {
    pointsRedeemed
  }
}
BottlecapDave commented 2 months ago

This has now been included as part of v10.3.0

Nurgus commented 2 months ago

Awesome! Thanks!

maddogspeighty commented 2 months ago

Hi, how do I go about setting this up, I can see the entity but how do I setup the blueprint.

I tried using the install blueprint option you have but it gives an unknown error.

BottlecapDave commented 2 months ago

Sorry there was a slight bug in the docs around the installation of the blueprint, which should now be fixed.

maddogspeighty commented 2 months ago

That fixed it, thanks.