Mario77 thanks, I could finally reproduce the issue:
The underlying lggpio library tries to create a pipe in the current working directory - when starting the python script via a systemd service or autostart.sh that will be the root directory which is read-only in LE so everything goes south. Running the script from the console will also fail if you "cd /" before...
I'd say this is a major design flaw in gpiozero / lg-gpio (it shouldn't write anything to the current directory in the first place) but fortunately there's an easy workaround:
Change the working directory to a directory where you have write permissions - eg /tmp
In the service file just add a WorkingDirectory setting, in autostart do a cd /tmp before starting the python script.
[Unit]
Description=to control fan based on temperature
Before=kodi.service
[Service]
Type=simple
WorkingDirectory=/tmp
ExecStart=/usr/bin/python3 /storage/.kodi/addons/service.fan/fan.py
Restart=always
RestartSec=20
[Install]
WantedBy=multi-user.target
Display More
so long,
Hias