|
|
| (One intermediate revision by the same user not shown) |
| Line 134: |
Line 134: |
|
| |
|
| {{#ev:youtube|https://youtu.be/vwg4oLCBA_w}} | | {{#ev:youtube|https://youtu.be/vwg4oLCBA_w}} |
|
| |
| ===Usage Examples===
| |
| {{Red|*All cases below are generously shared by our passionate users. This section is for collection and display only, serving as a reference for all users in need.}}
| |
|
| |
| <div style="font-weight:bold; padding:5px 0; border-bottom:1px solid #ddd;">
| |
| <span class="mw-customtoggle-NASPiExample1" style="cursor:pointer; color:#0645ad;">▼ Expand</span> 📋 <b>Example 1: CPU Temperature-Based Automatic Fan Speed Control (Home Assistant)</b>
| |
| </div>
| |
|
| |
|
| |
| <div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-NASPiExample1">
| |
| {| class="wikitable"
| |
| |<b>Goal</b>||Realize PWM fan speed control through Raspberry Pi GPIO pins. The fan automatically adjusts its rotating speed based on CPU temperature. A hysteresis mechanism is adopted to prevent frequent start-stop cycles, implementing intelligent temperature-controlled variable-speed heat dissipation.
| |
| |-
| |
| |<b>Devices</b>||Raspberry Pi 4B, Geekworm NASPi Kit
| |
| |-
| |
| |<b>OS</b>||Home Assistant
| |
| |}
| |
|
| |
|
| |
| <b>Step 1: Read CPU Temperature in HAOS</b>
| |
|
| |
| To control the fan, we first need to monitor the temperature.
| |
| :*Go to Settings > Devices & Services in Home Assistant.
| |
| :*Click on Add Integration in the bottom right corner and search for System Monitor.
| |
| :*Add the integration and ensure the processor temperature sensor (usually <code>sensor.processor_temperature</code>) is enabled.
| |
|
| |
|
| |
| <b>Step 2: Install the "pigpio" Add-on</b>
| |
|
| |
| To allow HAOS to communicate with the GPIO pins on a hardware level, we need a small background daemon.
| |
| :*Go to Settings > Add-ons > Add-on Store.
| |
| :*Click the three dots in the top right corner and select Repositories.
| |
| :*Add this updated community repository: [https://github.com/Poeschl-HomeAssistant-Addons/repository](https://github.com/Poeschl-HomeAssistant-Addons/repository)
| |
| :*Reload the page, search the list for the pigpio add-on, and install it.
| |
| :*<b>Important:</b> Enable the toggles for Start on boot and Watchdog, then start the add-on.
| |
|
| |
|
| |
| <b>Step 3: Install the PWM Integration via HACS</b>
| |
| :*Open HACS (Home Assistant Community Store) from your sidebar.
| |
| :*Click the three dots in the top right corner and select Custom repositories.
| |
| :*Paste the URL [https://github.com/RedMeKool/HA-Raspberry-pi-GPIO-PWM](https://github.com/RedMeKool/HA-Raspberry-pi-GPIO-PWM) into the input field.
| |
| :*Select Integration as the category and click Add.
| |
| :*Now, search for Raspberry Pi GPIO PWM in HACS, download the integration, and completely restart Home Assistant.
| |
|
| |
|
| |
| <b>Step 4: Configure the Fan</b>
| |
|
| |
| Next, we tell Home Assistant that there is a PWM device connected to GPIO pin 18.
| |
| :*Open your <code>configuration.yaml</code> (e.g., via the "File editor" or "Studio Code Server" add-on).
| |
| :*Add the following code:
| |
| <div style="margin-left: 2em;">
| |
| <pre>
| |
| light:
| |
| - platform: rpi_gpio_pwm
| |
| leds:
| |
| - name: NASPi Cooler
| |
| pin: 18
| |
| </pre>
| |
| </div>
| |
| :*Save the file and restart Home Assistant once more.
| |
| :*<b>Hardware Note:</b> You now have an entity called <code>light.naspi_cooler</code>. You can toggle it on your dashboard and increase the "brightness" to test it.
| |
| ::<b>Caution:</b> Due to the hardware design, the included Geekworm fan often requires at least 60–65% power (brightness) just to start spinning!
| |
|
| |
|
| |
| <b>Step 5: The Automation</b>
| |
|
| |
| Finally, we link the CPU temperature to the "brightness" of our pseudo-light, using hysteresis to prevent the fan from constantly turning on and off.
| |
| :*Go to Settings > Automations and create a new automation.
| |
| :*Click the three dots in the top right corner and switch to Edit in YAML mode.
| |
| :*Overwrite everything with this:
| |
| <div style="margin-left: 2em;">
| |
| <pre>
| |
| alias: "System: NASPi Fan Control"
| |
| mode: restart
| |
| trigger:
| |
| - platform: state
| |
| entity_id: sensor.processor_temperature
| |
| action:
| |
| - choose:
| |
| # LEVEL 2 (100%): When temp rises ABOVE 60°C
| |
| - conditions:
| |
| - condition: numeric_state
| |
| entity_id: sensor.processor_temperature
| |
| above: 60
| |
| sequence:
| |
| - service: light.turn_on
| |
| target:
| |
| entity_id: light.naspi_cooler
| |
| data:
| |
| brightness_pct: 100
| |
| # LEVEL 1 (70%): When temp is between 53°C and 60°C
| |
| # 53°C acts as the turn-on hysteresis!
| |
| - conditions:
| |
| - condition: numeric_state
| |
| entity_id: sensor.processor_temperature
| |
| above: 53
| |
| - condition: numeric_state
| |
| entity_id: sensor.processor_temperature
| |
| below: 60
| |
| sequence:
| |
| - service: light.turn_on
| |
| target:
| |
| entity_id: light.naspi_cooler
| |
| data:
| |
| brightness_pct: 70
| |
| # TURN OFF: Only when temp drops BELOW 48°C (turn-off hysteresis)
| |
| # AND the temperature has been that low for at least 1 minute (time filter)
| |
| - conditions:
| |
| - condition: numeric_state
| |
| entity_id: sensor.processor_temperature
| |
| below: 48
| |
| - condition: template
| |
| value_template: "{{ (now() - states.sensor.processor_temperature.last_changed).total_seconds() > 60 }}"
| |
| sequence:
| |
| - service: light.turn_off
| |
| target:
| |
| entity_id: light.naspi_cooler
| |
| # Default behavior: Do nothing, keep current state
| |
| default: []
| |
| </pre>
| |
| </div>
| |
|
| |
| </div>
| |
|
| |
|
| ==Packing List== | | ==Packing List== |