saidsay-so / fancy

Control your laptop fans with a fancy ( ͡° ͜ʖ ͡°) software (compatible with NBFC).
https://musikid.github.io/fancy/
Mozilla Public License 2.0
11 stars 0 forks source link

automatic regulation is unclear #18

Closed dumprop closed 2 years ago

dumprop commented 2 years ago

fancy set -a set auto to true But it always still true So, I had to change the auto to false in the config file How to disable auto via cli?

Also, seems that TemperatureThreshold doesn't work on my config ( https://pastebin.com/kyTUa88n ) It always in disabled state (fan speed is 0), how to debug that? (at high temperature, the system takes control and it's too noisy) nbfc works well

saidsay-so commented 2 years ago

The auto switch is automatically set to false when you set a target speed.

And to debug the service, you can set the RUST_LOG variable to debug and check the logs. With systemd, you can do that by running systemctl edit fancy.service and edit the file like this:

### Editing /etc/systemd/system/fancy.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
[Service]
Environment="RUST_LOG=debug"

### Lines below this comment will be discarded

And then restart the service. The service will print in the logs each time it refreshes.

dumprop commented 2 years ago

The auto switch is automatically set to false when you set a target speed.

I mean expected 3 ways: 1) System (smthg like disable fancy) 2) Manual (set % speed) 3) Use config file (I want to say control the fan based on the configuration), but seems -m will fix that

And to debug the service, you can set the RUST_LOG variable to debug and check the logs. With systemd, you can do that by running systemctl edit fancy.service and edit the file like this:

### Editing /etc/systemd/system/fancy.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
[Service]
Environment="RUST_LOG=debug"

### Lines below this comment will be discarded

And then restart the service. The service will print in the logs each time it refreshes.

Wow. Logs: https://pastebin.com/iTktjNNu Seems it enable fan only on critical state

Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::write > Writing [0] to offset Start(47)
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Target fan speed for CPU: 0
Nov 05 19:41:44 fedora fancyd[267243]: ]
Nov 05 19:41:44 fedora fancyd[267243]:     0.0,
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Critical state: false
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Computed temperature: 61.4
Nov 05 19:41:44 fedora fancyd[267243]: }

but on 61.4 it should enable the fan with 15% speed Maybe problem in [0, 0]? (it reads 2 values)

saidsay-so commented 2 years ago

Wow. Logs: https://pastebin.com/iTktjNNu Seems it enable fan only on critical state

Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::write > Writing [0] to offset Start(47)
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Target fan speed for CPU: 0
Nov 05 19:41:44 fedora fancyd[267243]: ]
Nov 05 19:41:44 fedora fancyd[267243]:     0.0,
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Critical state: false
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Computed temperature: 61.4
Nov 05 19:41:44 fedora fancyd[267243]: }

but on 61.4 it should enable the fan with 15% speed Maybe problem in [0, 0]? (it reads 2 values)

Yes it's very verbose! Effectively, it seems to set the speed only when it is critical, which is the expected behavior if auto is false. What is the value returned by fancy get auto?

dumprop commented 2 years ago

Wow. Logs: https://pastebin.com/iTktjNNu Seems it enable fan only on critical state

Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::write > Writing [0] to offset Start(47)
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Target fan speed for CPU: 0
Nov 05 19:41:44 fedora fancyd[267243]: ]
Nov 05 19:41:44 fedora fancyd[267243]:     0.0,
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Critical state: false
Nov 05 19:41:44 fedora fancyd[267243]:  DEBUG fancy_service                    > Computed temperature: 61.4
Nov 05 19:41:44 fedora fancyd[267243]: }

but on 61.4 it should enable the fan with 15% speed Maybe problem in [0, 0]? (it reads 2 values)

Yes it's very verbose! Effectively, it seems to set the speed only when it is critical, which is the expected behavior if auto is false. What is the value returned by fancy get auto?

Yes, it with disabled auto, with enabled it always on 100%

Nov 05 20:39:22 fedora systemd[1]: fancy.service: Deactivated successfully.
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::write > Writing [255] to offset Start(47)
Nov 05 20:39:22 fedora fancyd[346194]:  INFO  fancy_service                    > Exiting
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::write > Writing [7] to offset Start(47)
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold fan speed: 100
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold: 1
Nov 05 20:39:22 fedora fancyd[346194]: ]
Nov 05 20:39:22 fedora fancyd[346194]:     100.0,
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Critical state: false
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Computed temperature: 57
Nov 05 20:39:22 fedora fancyd[346194]: }
Nov 05 20:39:22 fedora fancyd[346194]:     "CPU": 57.0,
Nov 05 20:39:22 fedora fancyd[346194]:     "NVME": 47.85,
Nov 05 20:39:22 fedora fancyd[346194]:     "ACPI": 63.0,
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Temperatures: {
Nov 05 20:39:22 fedora systemd[1]: Stopping Fancy Service Daemon...
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::write > Writing [7] to offset Start(47)
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold fan speed: 100
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold: 1
Nov 05 20:39:22 fedora fancyd[346194]: ]
Nov 05 20:39:22 fedora fancyd[346194]:     100.0,
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Critical state: false
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Computed temperature: 57
Nov 05 20:39:22 fedora fancyd[346194]: }
Nov 05 20:39:22 fedora fancyd[346194]:     "CPU": 57.0,
Nov 05 20:39:22 fedora fancyd[346194]:     "NVME": 47.85,
Nov 05 20:39:22 fedora fancyd[346194]:     "ACPI": 63.0,
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Temperatures: {
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::write > Writing [7] to offset Start(47)
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold fan speed: 100
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Threshold: 1
Nov 05 20:39:22 fedora fancyd[346194]: ]
Nov 05 20:39:22 fedora fancyd[346194]:     100.0,
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Fans speeds: [
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service::ec_control::read  > Reading at offset Start(47) the value [0, 0]
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Critical state: false
Nov 05 20:39:22 fedora fancyd[346194]:  DEBUG fancy_service                    > Computed temperature: 57
Nov 05 20:39:22 fedora fancyd[346194]: }
saidsay-so commented 2 years ago

So the issue was that the tag closing </FanConfiguration> in your configuration was put before the temperature thresholds tag, which means that the fan configuration did not have any thresholds.

--- oldconfig   2021-11-05 19:42:13.705410962 +0100
+++ newconfig   2021-11-05 19:39:13.352730833 +0100
@@ -12,7 +12,6 @@
       <ResetRequired>true</ResetRequired>
       <FanSpeedResetValue>255</FanSpeedResetValue>
       <FanDisplayName>CPU</FanDisplayName>
-    </FanConfiguration>
       <TemperatureThresholds>
        <TemperatureThreshold>
           <UpThreshold>50</UpThreshold>
@@ -40,6 +39,8 @@
           <FanSpeed>60</FanSpeed>
         </TemperatureThreshold>
       </TemperatureThresholds>
+    </FanConfiguration>
   </FanConfigurations>
   <RegisterWriteConfigurations />
 </FanControlConfigV2>
+

In consequence, the service assigned the default thresholds to your config.

dumprop commented 2 years ago

So the issue was that the tag closing </FanConfiguration> in your configuration was put before the temperature thresholds tag, which means that the fan configuration did not have any thresholds.

--- oldconfig 2021-11-05 19:42:13.705410962 +0100
+++ newconfig 2021-11-05 19:39:13.352730833 +0100
@@ -12,7 +12,6 @@
       <ResetRequired>true</ResetRequired>
       <FanSpeedResetValue>255</FanSpeedResetValue>
       <FanDisplayName>CPU</FanDisplayName>
-    </FanConfiguration>
       <TemperatureThresholds>
      <TemperatureThreshold>
           <UpThreshold>50</UpThreshold>
@@ -40,6 +39,8 @@
           <FanSpeed>60</FanSpeed>
         </TemperatureThreshold>
       </TemperatureThresholds>
+    </FanConfiguration>
   </FanConfigurations>
   <RegisterWriteConfigurations />
 </FanControlConfigV2>
+

In consequence, the service assigned the default thresholds to your config.

Cool shot ! Probably some warnings as in nbfc-linux could be helpful for detect something like that :)

dumprop commented 2 years ago

So the issue was that the tag closing </FanConfiguration> in your configuration was put before the temperature thresholds tag, which means that the fan configuration did not have any thresholds.

--- oldconfig 2021-11-05 19:42:13.705410962 +0100
+++ newconfig 2021-11-05 19:39:13.352730833 +0100
@@ -12,7 +12,6 @@
       <ResetRequired>true</ResetRequired>
       <FanSpeedResetValue>255</FanSpeedResetValue>
       <FanDisplayName>CPU</FanDisplayName>
-    </FanConfiguration>
       <TemperatureThresholds>
      <TemperatureThreshold>
           <UpThreshold>50</UpThreshold>
@@ -40,6 +39,8 @@
           <FanSpeed>60</FanSpeed>
         </TemperatureThreshold>
       </TemperatureThresholds>
+    </FanConfiguration>
   </FanConfigurations>
   <RegisterWriteConfigurations />
 </FanControlConfigV2>
+

In consequence, the service assigned the default thresholds to your config.

Hmm, are you sure in that? Currently seems it invalud config file and it uses old configuration, hah

saidsay-so commented 2 years ago

I am pretty sure of it, I tested how the files are parsed.

Invalid configuration:

...
                    temperature_thresholds: [
                        TemperatureThreshold {
                            up_threshold: 0,
                            down_threshold: 0,
                            fan_speed: 0.0,
                        },
                        TemperatureThreshold {
                            up_threshold: 50,
                            down_threshold: 40,
                            fan_speed: 100.0,
                        },
                    ],
                },
...

Valid configuration:

...
                    temperature_thresholds: [
                        TemperatureThreshold {
                            up_threshold: 50,
                            down_threshold: 0,
                            fan_speed: 0.0,
                        },
                        TemperatureThreshold {
                            up_threshold: 51,
                            down_threshold: 65,
                            fan_speed: 15.0,
                        },
                        TemperatureThreshold {
                            up_threshold: 70,
                            down_threshold: 66,
                            fan_speed: 30.0,
                        },
                        TemperatureThreshold {
                            up_threshold: 71,
                            down_threshold: 76,
                            fan_speed: 45.0,
                        },
                        TemperatureThreshold {
                            up_threshold: 80,
                            down_threshold: 77,
                            fan_speed: 60.0,
                        },
                    ],
                },
 ...

Valid configuration file:

<?xml version="1.0"?>
<FanControlConfigV2 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NotebookModel>Lenovo Yoga Slim7</NotebookModel>
  <Author>dumprop</Author>
  <ReadWriteWords>false</ReadWriteWords>
  <FanConfigurations>
    <FanConfiguration>
      <ReadRegister>47</ReadRegister>
      <WriteRegister>47</WriteRegister>
      <MinSpeedValue>0</MinSpeedValue>
      <MaxSpeedValue>7</MaxSpeedValue>
      <ResetRequired>true</ResetRequired>
      <FanSpeedResetValue>255</FanSpeedResetValue>
      <FanDisplayName>CPU</FanDisplayName>
      <TemperatureThresholds>
        <TemperatureThreshold>
          <UpThreshold>50</UpThreshold>
          <DownThreshold>0</DownThreshold>
          <FanSpeed>0</FanSpeed>
        </TemperatureThreshold>
        <TemperatureThreshold>
          <UpThreshold>51</UpThreshold>
          <DownThreshold>65</DownThreshold>
          <FanSpeed>15</FanSpeed>
        </TemperatureThreshold>
        <TemperatureThreshold>
          <UpThreshold>70</UpThreshold>
          <DownThreshold>66</DownThreshold>
          <FanSpeed>30</FanSpeed>
        </TemperatureThreshold>
        <TemperatureThreshold>
          <UpThreshold>71</UpThreshold>
          <DownThreshold>76</DownThreshold>
          <FanSpeed>45</FanSpeed>
        </TemperatureThreshold>
        <TemperatureThreshold>
          <UpThreshold>80</UpThreshold>
          <DownThreshold>77</DownThreshold>
          <FanSpeed>60</FanSpeed>
        </TemperatureThreshold>
      </TemperatureThresholds>
    </FanConfiguration>
  </FanConfigurations>
  <RegisterWriteConfigurations />
</FanControlConfigV2>
dumprop commented 2 years ago

I am pretty sure of it, I tested how the files are parsed.

I still have a problem even on your config (installed fancy today again):

Nov 06 14:45:56 fedora fancyd[8821]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Nov 06 14:45:56 fedora fancyd[8821]: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Check { name: "Lenovo Yoga Slim7", source: MaxFanSpeedThresholdRequired }', service/src/main.rs:162:74

Seems related to https://github.com/MusiKid/fancy/issues/17

dumprop commented 2 years ago

Off-top: probably there no build for F35 (in fact there should be no any changes because it compiled on my F35) image

saidsay-so commented 2 years ago

This is because Fancy has additional checks to validate a configuration (see https://github.com/hirschmann/nbfc/tree/master/Core/StagWare.Configurations/Validation/Rules). I hid the additional checks behind a flag which has to be directly set from the service configuration for now.

dumprop commented 2 years ago

This is because Fancy has additional checks to validate a configuration (see https://github.com/hirschmann/nbfc/tree/master/Core/StagWare.Configurations/Validation/Rules). I hid the additional checks behind a flag which has to be directly set from the service configuration for now.

Cool, all works well :partying_face: