Wallbox Integration, API error + Solar

I’m trying to create an automation which will trigger the charging for my wallbox EV charger. However, it’s not working as expected.

Looking at the errors it appears about 50% of the time it gets a 403 forbidden from the Wallbox API. Is there anyway I can implement some retry logic to keep trying until it successfully change the state?

I’m also looking to modify the automation to use excess solar when the car is plugged in. Any help to do that would also be grateful. I do have an entity tracking when there is excess, but there needs to be excess over 1.6kw and then meter the voltage to the car by the same amount.

alias: Car charger
description: Switches on for the cheapest 4 hours per day
trigger:
  - platform: state
    entity_id:
      - binary_sensor.octopus_energy_target_cheapest_continous_electrity_4_hours
    from: "off"
    to: "on"
condition: []
action:
  - device_id: 6736dee232321f05e427a26296147a74
    domain: lock
    entity_id: 0ce8c401c75ecd73adb08ea030207207
    type: unlock
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      device_id: 6736dee232321f05e427a26296147a74
  - delay:
      hours: 4
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    target:
      device_id:
        - 6736dee232321f05e427a26296147a74
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - device_id: 6736dee232321f05e427a26296147a74
    domain: lock
    entity_id: 0ce8c401c75ecd73adb08ea030207207
    type: lock
mode: single

With my automation I have multiple conditions that check for things like energy rates and solar panel generation before attempting to turn on charging at the Wallbox. I don’t determine excess in real time. I observed the amount my house uses when there are no large draws (e.g., air conditioning not running) and set my solar power generation trigger based on a constant amount above that. Then I set a constant car charging current limit. So if my house draws 1kW and I set the solar power generation trigger at 2kW, I set the car charging current limit so that charging power is around 1kW. Those aren’t the exact numbers.

Any luck with the 403 forbidden error? I am getting the following every time an automation tries to turn on (or off) Wallbox Pause Resume: Error: 403 Client Error: Forbidden for url: https://api.wall-box.com/v3/chargers/xxxxxx/remote-action. As a result, I have been forced to turn on/off charging at the car, but that isn’t working as smoothly.