Turn on fan when CPU temp AND not overnight

HI all,
as usual, cannot let this automation to work

sensor:
  - platform: command_line
    command: "sudo /opt/susvd/susv -vin | awk '/Voltage in/ {print $4}'"
    name: Alimentazione
    unit_of_measurement: "V"
    value_template: '{{ value | float }}'
  - platform: command_line
    command: "sudo /opt/susvd/susv -status | awk '/Battery capacity/ {print $4}' |  sed 's/%//g'"
    name: Batteria
    unit_of_measurement: "%"
    value_template: '{{ value | float }}'
  - platform: command_line
    name: Temperatura CPU
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: '{{ value | multiply(0.001) | round(1) }}'

switch:
  - platform: rpi_gpio
    ports:
      18: Ventola CPU

binary_sensor:
  - platform: rpi_gpio
    ports:
      18: Ventola CPU accesa

automation:
  - alias: "Ventola CPU Accesa"
    trigger:
      platform: numeric_state
      entity_id: sensor.temperatura_cpu
#      value_template: '{{ states.sensor.temperatura_cpu.state }}'
      above: 47.0
#    condition:
#      condition: and
#      conditions:
#        - condition: time
#          after: '7:00:00'
#        - condition: time
#          before: '22:00:00'
    action:
      - service: switch.turn_on
        entity_id: switch.ventola_cpu

  - alias: "Ventola CPU Spenta"
    trigger:
      platform: numeric_state
      entity_id: sensor.temperatura_cpu
#      value_template: '{{ states.sensor.temperatura_cpu.state }}'
      below: 45.0
    action:
      - service: switch.turn_off
        entity_id: switch.ventola_cpu

I’d like to turn on cpu fan when temp is over 47°C (but not overnight) and turn it off when temp is below 45°C.
But this automation does not work.

Can someone help me?

Next step should be to use PWM to control fan speed accordingly to CPU temp.

Try making this lowercase with an underscore…
name: temperatura_cpu

I’m assuming you know that the temp is correctly retrieved.

you don’t need to use the and condition with the time component. You can simplify the condition section of your automation.

condition:
  condition: time
  after: '7:00:00'
  before: '22:00:00'