Having issues trying to use a variables, coming from OpenHab

I’ve been fighting with HA to turn off my EV charger when 10kW have been added to save the PV batteries.
I’ve been using openHAB for years but there isn’t a binding for the WallBox charger so I’ve got HA running in a Pi in the garage. In OH it’s this.

var Number Limit

rule "Set Charge Limit"

when
	Item WBSwitch changed to ON
then
	Limit = WBAdded.state + 10
	postUpdate(WBLimit, Limit)
end

rule "Switch off Charger"

when
	Item WBAdded changed
then
	Limit = WBLimit.state
	if (WBAdded.state > Limit) {
		sendCommand(WBSwitch, OFF)
	}
end

I’ve tried automations, variables, helpers. Why is it so difficult to do something that’s so easy in OH?

You’re more likely to get prompt assistance if you create a new topic (as opposed to appending to a long dormant topic about variables).

Post whatever automations you have tried (as opposed to OpenHAB code that requires the reader to understand the difference between postUpdate and sendCommand).

2 automations and an input_number vs 2 rules and a variable.

input_number:
  number_limit:
    name: Number Limit
    min: 0
    max: 1000000

automation:
- alias: Set Charge Limit
  - trigger:
    - platform: state
      entity_id: switch.wb_switch
      to: 'on'
    action:
    - service: input_number.set_value
      target:
        entity_id: input_number.number_limit
      data:
        value: "{{ states('sensor.wb_added') | float + 10 }}"

- alias: Switch off Charger
  - trigger:
    - platform: state
      entity_id: sensor.wb_added
    condition:
    - condition: template
      value_template: "{{ trigger.to_state.state | float > states('input_number.number_limit') | float }}"
    action:
    - service: switch.turn_off
      target:
        entity_id: switch.wb_switch

If the first automation is converted to a Trigger-based Template Sensor, then the Input Number can be eliminated and the solution is reduced to one automation and one Trigger-based Template Sensor.

Yes, I wanted to make it comparable though. There’s a number of ways to do this, it’s just different than he expects.

in regards to this…

template:
- trigger:
    - platform: state
      entity_id: switch.wb_switch
      to: 'on'
  sensor:
  - name: Number Limit
    state: "{{ states('sensor.wb_added') | float + 10 }}"

automation:
- alias: Switch off Charger
  - trigger:
    - platform: state
      entity_id: sensor.wb_added
    condition:
    - condition: template
      value_template: "{{ trigger.to_state.state | float > states('sensor.number_limit') | float }}"
    action:
    - service: switch.turn_off
      target:
        entity_id: switch.wb_switch