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.

No, I’ve had no luck with the 403. It’s a bit annoying since I went with Wallbox because of the HA integration.

My first (unrelated) advice is to stay away from device ids.

But back on topic, I noticed that when unlocking, the wallbox integration always will go unavailable for a short while, and states take some time to register. So what I do is add a wait for the expected states before I turning on charging.

      - service: lock.unlock
        data: {}
        target:
          entity_id: lock.wallbox_portal_locked_unlocked
      - wait_template: "{{ is_state('lock.wallbox_portal_locked_unlocked', 'unlocked') }}"
        continue_on_timeout: true
        timeout: "00:02:30"
      - wait_template: " {{ is_state('switch.wallbox_portal_pause_resume', 'off') }}"
        continue_on_timeout: true
        timeout: "00:02:30"
  - if:
      - condition: state
        entity_id: switch.wallbox_portal_pause_resume
        state: "off"
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.wallbox_portal_pause_resume

This works for me without fail.

I haven’t seen many people raising the 403 error as an issue. Maybe some folks have rooted their Wallbox and can bypass the web api.

I added a 2:30 wait in my automation (for the Wallbox to unlock) as in your example, @Edwin_D , but I still get the 403 error.

solved it by first starting the wallbox in the automation and then immediately closing it again in te same automation

Hey, I’m also interested in building an application for my Wallbox charger. Could you point me in the right direction on where to find the Wallbox API documentation or any resources that could help? I’d love to explore how the API works to create custom automations. Thanks!