Raspberry PI PWM Fan controller dosen't work after 2023.6

Hey guys!
So… i run HA on a Raspberry PI, and since i didn’t like that little fan sound, i figured out how to PWM control my fan using pyscript and pigpio, this was ~2-3 years ago, and i don’t remember where i found the codes i am using. The problem now is that since 2023.6, i dosen’t work anymore! And i figure this has something to do with Python 3.11. But since i don’t know anything about python, i am hoping someone here could help!

So - i have “Pyscript Python scripting” activated, with one script “rpi_cpu_fan_pwm.py”, and then i have pigpio installed, and then i have this lines in the config.yaml

This first line is to display the fan PWM in Home Assistant

  - platform: template
    sensors:
        fan_pwd:
            value_template: "20"
            friendly_name: "Fan rpm"
            unit_of_measurement: "% RPM"

And this line is to get the Raspberry CPU temperature, with the update i had to change “command_line” since that was “- platform: command_line” before.

command_line:
  - sensor:
      name: RSB CPU Temperature
      command: "cat /sys/class/thermal/thermal_zone0/temp"
      unit_of_measurement: "°C"
      value_template: '{{ value | multiply(0.001) | round(1) }}'
      scan_interval: 10

This is the .py file:

I really hope someone with more skills could take a look at this and help me figure it out…

Thank you!

Found the solution, it was just that for some reason - the destination of where the script took the CPU temperatur, didn’t work after 2023.6

If I were to use the template sensor according to the new format, do I need to change something in the py script?

template:
  - sensor:
      - name: "Fan rpm"
        state: "20"
        unit_of_measurement: "% RPM"
        unique_id: sensor_fan_pwd

Yes, you need to type it like this;

sensor:
  - platform: template
    sensors:
        fan_pwd:
            value_template: "20"
            friendly_name: "Fan rpm"
            unit_of_measurement: "% RPM"

Ok, but what if he removes it in the future
- platform_template because it is deprecated and the new format above is recommended.

It would be enough to change the line in py
sensor.fan_pwd = duty_cycle
on real sensor according to the new format
sensor.xxx_xx = duty_cycle ?