Trouble with an automation

Probably a complete noob question, but I’m trying to make my first automations to turn on and off a Shelly 1 that I’ve got connected to my EV charger. The automation in question is supposed to turn off the Shelly1 if the battery charge on my solar is below 40% and the time isn’t between half past midnight and 4:30am, yet every time I “Run Actions” on the automation it turns off the Shelly1.

The code is as follows:

id: '1658601285827'
alias: Turn off the EV charger if the battery is low
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.battery_state_of_capacity
    below: '0.4'
    attribute: unit_of_measurement
condition:
  - condition: time
    before: '00:30:00'
    after: '04:30:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - type: turn_off
    device_id: 2dd4b248485c26e079f27d2c2b54ba1d
    entity_id: switch.shelly1_485519ca0ae8
    domain: switch
mode: single

I’m wondering how to express the sensor.battery_state_of_capacity - is “0.4” 40%? or does it require “40”? either way it turns off the Shelly when I run it.

You only have actions for off. Where are the “on” actions?

Also if you run the automation manually with “Run actions” it does exactly that, it runs the actions without looking at the conditions.

There’s an service in Developer Tools → Services to trigger an automation that lets you include the conditions as an option.