Wallbox pulsar plus integration?

Can you share your setup? I try to build something as well but good to see your logic.

Warning:
My setup now is purely experimental, to play around, not a solution! As you can see in the graph I’m emulating ‘eco’ mode, not ‘green’ mode. The minimum charge current is 6A. You can also see that it turns into a ‘bang-bang’ controller, falling back to 6A all the time. The loop amplification must be tuned down. This means a larger static error is required. I couldn’t experiment any further because some-one took the car :slight_smile: . The controller should be changed into a PI controller, but with the 30 seconds time constant of the API in the loop I’m not hopeful that would lead to an acceptable result. Hence my constant plea to Wallbox to make eco-Smart useable through the API.

Enough bla bla, for my setup:

In the configuration I have:

input_number:
    # Wallbox        
    wallbox_charging_current_controller_k:
        name: "wallbox controller k value"
        unit_of_measurement: "A/W"
        initial: 0
        min: 0
        max: 0.1
        step: 0.001
        mode: box

sensor:
  - platform: template
    sensors:
        # solar control
        wallbox_charging_current_target:
            value_template: "{{ [[( states('sensor.actual_power') | float(0) * states('input_number.wallbox_charging_current_controller_k') | float(0) * -1.0 ) |round(0), 6] | max, 32] | min }}"

And an automation:

- id: '1654783449787'
  alias: WALLBOX - Excess solar power controller
  description: Controls the charger current to use excess solar power only (i.e. grid
    power to zero)
  trigger:
  - platform: time_pattern
    seconds: /30
  condition: []
  action:
  - service: number.set_value
    data:
      value: '{{ states(''sensor.wallbox_charging_current_target'') | float(0) | round(0)
        }}'
    target:
      entity_id: number.wallbox_portal_max_charging_current
  mode: single

That on 1 fase if I understand correctly. I am on 3 fases. Unfortunately this requires a minimum of 6a solar excess for eco smart to kick in (and 18 for the full solar). I would be great if the software would allow a 3 fase charger to “switch off” 2 of the 3 fases if solar drops but as far as I know that is not feasible today.

1 Like

So you only control the Amp’s of the wallbox? What if these drop below 6amp? Do you automatically pause charging?

So you only control the Amp’s of the wallbox? What if these drop below 6amp? Do you automatically pause charging?

No, I don’t. Charge demand less than 6A is set to 6A. Same as Wallbox ‘eco’ mode. Could automatically pause (just as Wallbox ‘green’ mode). Since the controller is not useable as it is now, I do not feel the need to implement such detail.

That on 1 fase if I understand correctly. I am on 3 fases. Unfortunately this requires a minimum of 6a solar excess for eco smart to kick in (and 18 for the full solar). I would be great if the software would allow a 3 fase charger to “switch off” 2 of the 3 fases if solar drops but as far as I know that is not feasible today.

I think that is totally feasible. But not implemented now.

Just developed something better:

A simple automation that controls the Wallbox charger max current setting up and down (between 6 and 32 A), maintaining the grid power around zero, to use excess solar power only.

The automation increases the max current with 1 A if the grid power is below limit 1, and decreases the max current with 1A if the grid power is above limit 2. Between the limits the max current is left alone.

I have the limit 1 set to -250 W, and the limit 2 set to 250 W. Of course this can easily be changed to other values.

I run the automation every 12 seconds, so a full sweep from 6 to 32 A would take a bit more than 5 minutes. This tames the controller. Again an actual update of the max current setting to Wallbox is only done every 30 seconds by the API. The 12 seconds value can be changes easily.

Nothing is required in the config file.

I hope I did not speak too soon. I cannot test actually charging a car because no sun on the panels anymore today :slight_smile:

The automation:

- id: '1654960233260'
  alias: WALLBOX - Charge current controller
  description: Controls the Wallbox charger max current setting up and down (between
    6 and 32 A), maintaining the grid power around zero, to use excess solar power
    only.
  trigger:
  - platform: time_pattern
    seconds: /12
  action:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: sensor.actual_power
        below: '-250'
      sequence:
      - service: number.set_value
        data:
          value: '{{ [((states(''number.wallbox_portal_max_charging_current'') | float(0)
            + 1.0) | round(0)), 32] | min }}'
        target:
          entity_id: number.wallbox_portal_max_charging_current
    - conditions:
      - condition: numeric_state
        entity_id: sensor.actual_power
        above: '250'
      sequence:
      - service: number.set_value
        data:
          value: '{{ [((states(''number.wallbox_portal_max_charging_current'') | float(0)
            - 1.0) | round(0)), 6] | max }}'
        target:
          entity_id: number.wallbox_portal_max_charging_current
  mode: single

Teaser:

Screenshot 2022-06-11 221935

Quick update:
Started testing with first sun on the panels this morning. The controller works like a charm. Will post some traces later.

The HA dashboard with charge mode setting is also taking shape. The principle works.

There is just one problem: it works. After me playing around last night, I left it in ‘Eco’ mode. My son came home late at night and connected a car expecting it to be fully charged early in the morning. But it only charged at 6A (eco mode), the car was not fully charged this morning. This function has it’s risks.

Traces as promised:
The controller doing it’s thing for the last 2 hours. The big dip to 6A is where the washing machine started (heating up the water), the smaller dip to 9A before that is the wife’s hairdryer.

@hesselonline
Small thing here. Not a bug, but an enhancement request. The link to GitHub you posted is for bugs only !?

The number ‘number.wallbox_portal_max_charging_current’ does not have a unit of measurement assigned by the integration, should be ‘A’.

PS
Apologies for the long message with different issues. I can’t post more than 3 consecutive messages. Interesting limitation …

3 Likes

Very interesting to see your charts @VdR

To me it seems that your choice of 12 second intervals between 1 Amp steps in charging current is just about perfect. The amount of energy exported to the grid consists of very narrow spikes so it won’t add up to much. Likewise the amount of energy imported from the grid is also very small.

Thinking back to my days at university where I learnt about PID controllers, it seems to me that you don’t have any I or any D, but just the P (proportional) component, with a 1 Amp per 12 second rate limit, acting as a low-pass filter. This keeps things very simple and it may well be good enough. Too much loop gain with higher bandwidth and you get oscillations as was happening in the earlier chart.

Great work!

Yes it seems to be tuned very well.

I believe it does have sort of an I component, the charger current keeps increasing or decreasing (1A per 12 seconds) as long there is an error (exported or imported power), but with a dead zone (-250 to 250 W), and independent of the size of the error.

There could be an optimization with the dead zone limits, depending if you want a balance between export/import, make sure you never export, or make sure you never import, the zone can be shifted. It should not be made smaller than 1A (about 230W).

Still fine tuning the ‘Green’ mode, to properly control the pause/resume.

Question to the community:
How to avoid a situation as described above with my son not getting the expected charge because of ‘green’ or ‘eco’ mode?

For context: I’m the only nerd in the family, my wife and two sons do not have HA on their phones and will not look at, let alone use, the tablet with HA interface in the kitchen.

Option 1: I can make a schedule that changes the charge mode to ‘max’ at 22:00, so any car connected will be charged the next day. Disadvantage, if I did not need the full charge, I miss the opportunity the next day to use my excess solar.

Option 2: I put a big button connected to HA (ESPHome) close the Wallbox to force ‘max’ charging (or multiple buttons to select the charge mode) in case I need it. Most other smart chargers I have seen have such a selector on the unit …

Other thoughts?

1 Like

Coming back to the power reporting bug (charge power not consistently reported by the Wallbox over WiFi). With the mode controller it is again of interest to see the charger power. So I have set up a work around that seems to do the job reasonably well.

I defined a sensor that takes the reported power, except when going zero while the status is ‘charging’, then it retains the previously reported value. This works well except at the end of the charge, because it takes a while before the status changes to ‘waiting for car demand’.

In the configuration file:

sensor:

        # alternative (advanced workaround as long as reported power is not solved)
        wallbox_portal_charging_power_w_tracked:
            value_template: >
                {% if states('sensor.wallbox_portal_status_description') == "Charging" %}
                    {% if states('sensor.wallbox_portal_charging_power_w') == "0" %}
                        {{ states('sensor.wallbox_portal_charging_power_w_tracked') | float(0) | round(0) }}
                    {% else %}
                        {{ states('sensor.wallbox_portal_charging_power_w') | float(0) | round(0) }}
                    {% endif %}
                {% else %}
                    {{ "0" }}
                {% endif %}
            unit_of_measurement: "W"

Can use this workaround until Wallbox has figured out how to send data over WiFi.

1 Like

For the empty car, does your car API report anything? EG distance driven since last charge or battery state? If so you could override solar mode based on one of those parameters. This is what I intend to do, if <50 switch to grey mode. Depending on the weather forecast I can, through a service call, also cap the battery at 50-100% to leave headroom for solar the following day.

What does your sensor “actual power” represent? Is this Amp? For me not much sense changing the amp, my max solar output is 7a so I cap mine at 6a (for green mode) and 16a (for grey off peak)

Currently I monitor the excess power generated, if it exceeds 2k watt for 2 minutes then a Boolean switches on, if again for 2 minutes, it moves below (in case charger is idle) or net consumption > 2k (if charger is charging) it switches off. These values are reported by my smart meter.

The 2 minute delay is to avoid switching too often. The Boolean subsequently triggers a pause/resume on the wallbox.

Realize I can do this more efficiently but the Boolean allows me to debug more easily

Neither of our cars (Polestar 2, Fiat 500e) have an API. I don’t think any logic can predict how the car should be charged, live has too many variables.

‘actual power’ in my case is what actually is delivered by the grid (or received when negative). It’s power in “W”. Could have used ‘actual current’, but in the end the meter meters power.

If your max solar is 7A , with the charger minimum being 6A, you indeed only need an on/off (pause/resume) controller for ‘green’ mode and a ‘max’ mode, no point to have ‘eco’ mode :slight_smile: .

I take it your solar is 7A three phase? You mentioned before that the charger current is minimum 6A per phase? That is a big disadvantage indeed. No useful ‘eco’ mode. But you switch the charger on at 2 kW, that is about 3A per phase. Starting to charge at 6A per phase immediately exceeds the 2 kW excess solar. I would expect the system to continuously switch on and off?

I should have expressed myself more clearly, sorry. That’s 3 phase indeed, so approx 2kw max solar output per fase, Total 5.8kw max, at this time of the year I generate 4kw or more between 10am and 15pm - total power generation of 40-45kwh per day at the moment. In winter this drops to as low as 100kwh per month. So very much need the off peak grey charge as well :grinning:

At 7amp per phase my car charger consumes nearly all my solar as long as nothing else is on. Eco-mode (wallbox style) works between 9am and 16pm at this time of year with limited on off switching. Did not try full green.

I would welcome the option to charge on 1 phase as it would allow me to use excess solar more optimally @Oriol_FP , is this feature being developed for the pulsar plus? EG allowing the 3 phase charger to switch to 1 phase?

Have another 3 years before net metering is phased out so no rush… :wink:

Hi Roland. The single and three phase WallBox Pulsar Plus are identical, except for the electrical grid connection. Mine is fitted with a 4 pole 63A change over switch. 1 phase - off - 3 phase. Reason for 4 pole is to also switch off the neutral when off - a requirement here… The charger automatically charges using the number of phases connected when it is powered on. I have this so I can charge (faster) using all 3 phases over night on cheap electricity, but during the day I can charge on 1 phase. Even though I have 3 phase solar (3 separate systems - no load balancing) - using only one phase lets me be sure I always have the required 1.4kW excess on this phase…

The WB app does not report 1 or 3 phase - I wonder if this info is in the API? Great if it is? Otherwise a switch on a ESP to select 1 or 3 phase charge active, and then you could do a eco charge on 3 phases by being sure there is more than 1.4kw (6A) available on each phase…

Currently I have a ESP with a 3 position switch mounted next to my WallBox - so I can select eco, emergency, night modes - and 3 LED’s to give conformation of mode selected.

eco = start @ 6A if >7A available for > 5min, then step up / down current or pause if needed to keep a 1A buffer (will eventually decrease this).
emergency = ignore solar excess and time of day and charge at max rate anyway
night = start charging after 9pm (when our electricity is cheaper)

I will eventually add a second switch mounted beside the charger to let me tell the system I am in 3 phase charge mode (but much better if this info is in the API, and then we know automatically - how can we check, or have it added??) - then I will monitor all 3 solar phases for >1.4Kw on each phase, etc. We don’t have net metering, so I would like to do this now :slight_smile:

Really interesting stuff… have just paid for the car - pickup in a few days - so can start testing soon.

I am doing this in Node-RED with HA - thanks @GrantK for pointing me in this direction… gives a nice visual representation of the logic flow…

BTW, even better yet - if the charger is wired to 3 phase, let the user select via WB app / HA API whether to charge using 1 or 3 phases - then we could automate this (if only one phase has > 1.4kW then single phase charge, if all 3 phases have > 1.4kW each, then 3 phase charge) - I wonder if WallBox is listening :slight_smile:

The 6A (1.4kW) limitation is (I understand) set by the car charging standard internationally - on single phase you need 1.4kW, and on 3 phase you need 1.4kW x 3.

2 Likes

I have the ‘green’ mode working properly as well now. Connected a car last night, charging started this morning as soon as there was 1.5 kW excess for 5 min and the charge power increased nicely with increased solar power. Then I realized we need the car fully charge by noon and hit the ‘max’ button.

Surely there is always some finetuning to do, but here is the full implementation:

The automation controlling the charger current limit for the ‘green’ and ‘eco’ modes has a small update to only activate when the status is ‘Charging’, this prevents the current limit from creeping to 32A before charging even started.

- id: '1654960233260'
  alias: WALLBOX - Charger current controller
  description: Controls the Wallbox charger max current setting up and down (between
    6 and 32 A), maintaining the grid power around zero, to use excess solar power
    only.
  trigger:
  - platform: time_pattern
    seconds: /12
  condition:
  - condition: state
    entity_id: input_boolean.charger_max
    state: 'off'
  - condition: state
    entity_id: sensor.wallbox_portal_status_description
    state: Charging
  action:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: sensor.actual_power
        below: '-250'
      sequence:
      - service: number.set_value
        data:
          value: '{{ [((states(''number.wallbox_portal_max_charging_current'') | float(0)
            + 1.0) | round(0)), 32] | min }}'
        target:
          entity_id: number.wallbox_portal_max_charging_current
    - conditions:
      - condition: numeric_state
        entity_id: sensor.actual_power
        above: '250'
      sequence:
      - service: number.set_value
        data:
          value: '{{ [((states(''number.wallbox_portal_max_charging_current'') | float(0)
            - 1.0) | round(0)), 6] | max }}'
        target:
          entity_id: number.wallbox_portal_max_charging_current
  mode: single

To create the charge mode selection buttons on the HA dashboard I added the following to the configuration file:

input_boolean:

    # Wallbox
    charger_green:
        name: "Wallbox green mode"

    charger_eco:
        name: "Wallbox eco mode"
        
    charger_max:
        name: "Wallbox max mode"

Each of these have a script associated to run the actions required to change charge mode:

# Charger control scripts

charger_green:
    sequence:
    - service: input_boolean.turn_on
      entity_id: input_boolean.charger_green
      
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_eco
      
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_max
      
    - service: number.set_value
      data:
        value: "6"
        entity_id: number.wallbox_portal_max_charging_current
        
charger_eco:
    sequence:
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_green
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.charger_eco
      
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_max

    - service: number.set_value
      data:
        value: "6"
        entity_id: number.wallbox_portal_max_charging_current
        
charger_max:
    sequence:
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_green
      
    - service: input_boolean.turn_off
      entity_id: input_boolean.charger_eco
      
    - service: input_boolean.turn_on
      entity_id: input_boolean.charger_max
      
    - service: number.set_value
      data:
        value: "32"
        entity_id: number.wallbox_portal_max_charging_current

And there are two additional automations to pause and resume the charger in ‘green’ mode:

- id: '1654977801663'
  alias: WALLBOX - Charger pause controller - Resume
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.actual_power
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: '-1500'
  condition:
  - condition: state
    entity_id: input_boolean.charger_green
    state: 'on'
  - condition: state
    entity_id: sensor.wallbox_portal_status_description
    state: Paused
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.wallbox_portal_pause_resume
  mode: single
- id: '1654978038793'
  alias: WALLBOX - Charger pause controller - Pause
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.actual_power
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: '250'
  condition:
  - condition: state
    entity_id: input_boolean.charger_green
    state: 'on'
  - condition: state
    entity_id: sensor.wallbox_portal_status_description
    state: Charging
  action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.wallbox_portal_pause_resume
  mode: single

And finally, to put it all together, this is what is in my dashboard:

type: vertical-stack
cards:
  - show_name: true
    show_icon: false
    type: button
    tap_action:
      action: toggle
    name: CHARGER CONTROLLER
  - type: horizontal-stack
    cards:
      - show_name: true
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: script.charger_green
          data: {}
          target: {}
        entity: input_boolean.charger_green
        name: Green
        icon: mdi:leaf
        icon_height: 80px
      - show_name: true
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: script.charger_eco
          data: {}
          target: {}
        entity: input_boolean.charger_eco
        name: Eco
        icon: mdi:weather-sunny
        icon_height: 80px
        show_state: false
      - show_name: true
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: script.charger_max
          data: {}
          target: {}
        entity: input_boolean.charger_max
        name: Max
        icon: mdi:flash
        icon_height: 80px
  - type: entities
    entities:
      - entity: number.wallbox_portal_max_charging_current
        name: Current limit
      - entity: switch.wallbox_portal_pause_resume
        name: Enabled
  - type: history-graph
    entities:
      - entity: sensor.wallbox_portal_max_charging_current
        name: Charger Current Limit
    hours_to_show: 24
  - type: history-graph
    entities:
      - entity: sensor.actual_power
        name: Mains Power
    hours_to_show: 24
  - type: history-graph
    entities:
      - entity: switch.wallbox_portal_pause_resume
        name: Enabled

Which will give you something like this:

NOTES:

The automations can be realized/edited from the HA user interface. You can copy the code above into the automations.yaml file and then edit in the HA user interface.

Surely there is a way to simplify this. Let me know.

To be clear, this setup does NOT make use of the Wallbox eco-Smart functions because these cannot be managed through the API, or even the Wallbox app on WiFi. This setup creates similar functionality and is accessible from the HA dashboard using the official HA Wallbox integration (another shoutout @hesselonline for making this possible).

Copy with pride. Give me your opinion.

11 Likes

Hi @RT1080
This is a very interesting request, thanks for sharing.
I already noted this insight/feedback in my repository of insights and also shared this to the affected Product Owner of Ecosmart function.

Interesting intermediate solution reported here with 4 pole 63A change over switch. I am listening @andypnz . Not sure for how long, but till now, you are debating really interesting “jobs to be done

1 Like

This single phase / three phase switching is indeed mighty interesting.

The Wallbox has a relay on each phase and on neutral (also the single phase units at least in the Belgium market), so it should be able to do this without additional hardware. At least using a three phase unit on a single phase. Not sure about using a single phase unit on three phase. The four relays are there, but I believe the type 2 cable on the single phase units is, guess what, single phase.

In principle you could also use 2 phases and switch from 1 to 2 to 3 phases. A three phase supply without neutral (yeah that still exists) is to be connected as 2 phases and one neutral.

I’m curious what local regulations have to say about this, and if all cars will be ok with the number of phases switching like that. But, he, why not?

I would not switch the number of phases with the car plugged in. And I would only supply a 3 phase capable car with either 1 or 3 phases - and if 1 phase, always on the L1 output…

WallBox confirmed a 1 or 3 phase selection switch was no problem :slight_smile: Of course, you need a 3 phase Type 2 lead + a 3 phase capable car to think about 3 phase charging :slight_smile: Not to mention a 3 phase supply… About to add 3 phase Eco ( >1.4kW on all 3 phases) and 3 phase semi-Eco (>1.4kw on 2 phases, and >1kw on the 3rd) to my code.

I almost have my Node-Red automation complete. And a new mode added - “Eco/Night” - this was an interesting idea I had today - I have a switch to select this mode on the dashboard (the other mode selections are on a ESP8266 with LED feedback - I might add another switch + LED here…). When active, it will eco charge using solar. Of course, as the sun sets the charge will pause. But in this mode, after night rate (cheaper electricity) starts (here @ 9pm) the charger will start again at max charge rate. So Eco, with a guaranteed fully charged car in the morning… cheap as chips :slight_smile: @ Oriol_FP Another nice mode for the WallBox OEM Eco smart :slight_smile:

2 Likes

@andypnz - Andrew, I have a question for you…

When charging at night, how do you avoid your batteries being discharged by the Pulsar Plus?

I presume your solar power system normally compensates for power used on each phase according to the house loads on that phase, thus avoiding using power from the grid. But if you have cheap night rates from 9pm, presumably you want power used during this time to come from the grid, rather than your batteries. Curious as to how you manage this.

We don’t have a battery - for us, the economics just did not stack up - unlikely to save what the battery cost before the battery is end of life… But I would be surprised if a ‘smart’ battery system did not let you decide when the battery will provide / supplement power v’s power from the grid. Those with high tech battery systems will have the answers here I am sure.

Yes, I have the ability to program a schedule, specifying whether the battery charges or discharges, the rate in Watts at which charging/discharging occurs, etc. Can also schedule import or export, along with the rate in Watts. So the tools are there, but I can’t access them from HA. I was just curious to know what you might have come up with.

For us, having a hybrid inverter with battery backup, is more about security of supply, than financial return. We are only able to export at 3.5kW max due to transformer constraints imposed by Northpower. So that severely limits how much we can earn in solar credits, hence it makes sense to store and use as much of our own power as possible. The cheapest rate we can buy power overnight is 25c per kWh, which I suspect is a lot more than you’re paying.

2 Likes