Raspberry Pi CPU Fan Automation

Yes, it’s the age old “fun” of physical pin numbering vs BCM pin numbering (plus of course functional naming like TXD and RXD).

Concerning your other question - I think it’s only on or off, no percentage speed. I’ve not actually tried to put a variable voltage on the control lead and see what happens, but the thing looks so small and simple I expect it’s just a gating switch on the 5v/gnd connections to the fan and either on or off.

Hi
can you past the pwmled addon setup? do you have it all in configuration.yaml?

Hello, please help me, i can’t make this to work, I am very new to home assitant and i don’t understand a lot.
I copy paste the code but i get the next error:

Invalid config for [switch.command_line]: [name] is an invalid option for [switch.command_line]. Check: switch.command_line->name. (See ?, line ?).
Platform error switch.numeric_state - Integration 'numeric_state' not found.
Platform error switch.numeric_state - Integration 'numeric_state' not found.

this is the yaml config:

# Raspberry Pi Cooling Fan
switch:
  - platform: rpi_gpio
    ports:
      4: RPI Cooling Fan

  - platform: command_line
    name: CPU Temp
    command: "/bin/cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: '{{ (value | int / 1000) | int }}'
  
  - alias: 'RPI Cooling Fan einschalten'
    trigger:
    platform: numeric_state
    entity_id: sensor.cpu_temp
    above: 55
    action:
      service: switch.turn_on
      entity_id: switch.rpi_cooling_fan

  - alias: 'Pi Lüfter ausschalten'
    trigger:
    platform: numeric_state
    entity_id: sensor.cpu_temp
    below: 36
    action:
      service: switch.turn_off
      entity_id: switch.rpi_cooling_fan

The CPU temperature is a sensor, not a switch.

Just above the - platform: command_line put sensor: fully indented to the left (in-line with your existing switch: header).

sensor:
  - platform: command_line
    name: CPU Temp
    command: "/bin/cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: '{{ (value | int / 1000) | int }}'

Similarly the other two items to turn the fan on and off are automations, not switches.Those are better entered via the GUI rather than by changing the configuration.yaml file.

Be careful, rpi_gpio integration is deprecated and will be removed from HA as an official integration in June

True, although hopefully it will be replaced by an installable alternative.

Otherwise from what I’ve seen, several users who do have stuff hooked up to GPIO (more serious than just a case fan anyway) are gonna get grumpy…

Is the blue (connected to gpio 14) on Raspberry fan case not the same as RPM speed signal?
I’m trying to do the exact same thing with a 5V Noctua fan but I can’t get the rpi_gpio switch to do anything. The fan is running full speed as soon as the pi is powered. I would like to be able to turn on/off with a rpi_gpio switch.

On mine the fan comes on when the Pi is shut down, as the pin used goes high.

From what I can see the case fan is just on or off, it’s not speed controllable.

Thank you very much, it’s working now!