jojobrogess / script.deskpifanservice

Libreelec and OSMC Deskpi Pro addon to install fan service and control fan speed.
4 stars 0 forks source link

Testing: OSMC 2023-12-01 #3

Closed inspector71 closed 2 weeks ago

inspector71 commented 6 months ago

Well this might take you by surprise. For reasons all but unknown to even me, I found myself trying your code on OSMC version 2023-12 ( yes, I hate their version naming scheme as well ! ).

Now, bear in mind I still have the fan powered by direct wiring to GPIO but I thought this was a worthwhile start.

The add-on installed into Kodi!

Forgot there was the LE package requirements. But found a way around it that, sort of :)

osmc@OSMC2023-12-1:~$ wget http://addons.libreelec.tv/11.0.0/ARMv8/arm/virtual.rpi-tools/virtual.rpi-tools-11.0.0.0.zip
osmc@OSMC2023-12-1:~$ wget http://addons.libreelec.tv/11.0.0/ARMv8/arm/virtual.system-tools/virtual.system-tools-11.0.0.4.zip
osmc@OSMC2023-12-1:~$ wget https://codeload.github.com/jojobrogess/script.deskpifanservice/zip/refs/heads/main

Unfortunately the actual creating of the deskpi.service and so forth did not work but undoubtedly this is due to small differences between LE and OSMC.

inspector71 commented 6 months ago

More details of first install results:

Troubleshoot, Check Installation

Appears to run OK, but returns the following:

DeskPi Fan Service Integrity Check: FAILED!
Check and collect logs, please contact dev.

[]
Service file(s) missing:
deskpi.service
deskpi-poweroff.service

I guess it is more than likely these checks 'failed' because the paths they were checking might have been LE-specific.

I realise I can verify this theory by checking the code and will try to soon.

Sorry for the downer. I appreciate the addon is not necessarily intended to run on OSMC at this stage.

Troubleshoot, Restart services

I'm going to assume this was not likely to work due to OSMC and leave it at that :) For now, at least.

Troubleshoot, Check Uninstallation

DeskPi Fan Service Integrity Check: FAILED!
Check and collect logs, please contact dev.

[]
Service integrity check passed.

That message could probably be improved. I can help with that :)

jojobrogess commented 6 months ago

I guess it is more than likely these checks 'failed' because the paths they were checking might have been LE-specific.

Yeah I would assume the directory locations are invalid, as well as A LOT of bits of code. this is where .service(s) are saved in libreelec service_library = "/storage/.config/system.d/". (https://osmc.tv/wiki/general/running-scripts-on-startup-and-shutdown/)

this is the location for the config file /flash/config.txt (OSMC location /boot/config.txt) Since libreelec is a readonly filesystem, you have to mount the directory to be able to modify that file, so that code probably breaks in OSMC.

config cant be edited outside of OSMC config editor because values will just be re-written.

I hardcoded the calls to get the settings values, so it reads the settings xml file rather than using xbmcaddon.Addon(script.deskpifanservice).getSetting() It might be smart to switch this back to the original correct methodology, so to minimize that as a problem. (libreelec addon settings.xml location /storage/.kodi/userdata/addon_data/script.deskpifanservice/settings.xml)

Libreelec doesn't have sudo, and I think OSMC does, so I assume none of the systemctl stuff would work if that's the case.


For OSMC to be fully supported within the same addon, there would need to be a way to differentiate the OS's and install things accordingly. Then change the controller library.py file to use the correct getSetting() code, probably compress that library.py file into the utils.py file. And done.

I just got OSMC installed and WIFI connected, FINALLY. I am going through the system right now lol As weird as Libreelec is, OSMC is just as weird, although it does seem closer to traditional linux. Maybe I've just spent too much time inside libre..

I'm going to see if I can get the USB0 stuff working, because making the code work for OSMC without that is pointless. But If I can, it should take no time to get it to install correctly.

inspector71 commented 6 months ago

OSMC is definitely more traditional linux. It's booting Debian to Kodi. I'm really confused why it was so hard for you to create the installation but I've had a lot of fiddly annoying times with creating installable cards in RPi contexts so I guess it's not that unusual, unfortunately.

I would not stress about OSMC compatibility but if you're into it, happy to help you test and possibly tweak some code here or there.

Finally managed to fork your code and tweak a few Strings.po to try and p[ossibly improve the UX a touch. I'll see if I can get into the code a bit more but first glance is still "GARRRGH, Python! Ewwww!!!", hahaha. That's after not seeing a Python file for a little while. If I can proceed beyond that icky feeling, who knows what's possible :)

OSMC definitely has sudo. The default account seems to be osmc rather than root on LE. I'll do some quick research on OSMC addon development. Just 15 minutes but see if I can help you out in the moment...ish. For once!

inspector71 commented 6 months ago

Post a question in the OSMC forum. Just asking if there's any OSMC-specific addon development help.

jojobrogess commented 6 months ago

OSMC is definitely more traditional linux. It's booting Debian to Kodi. I'm really confused why it was so hard for you to create the installation but I've had a lot of fiddly annoying times with creating installable cards in RPi contexts so I guess it's not that unusual, unfortunately.

Honestly think it was the installation process. It's not that clear that you need to use the installer on a micro-sd, select that you want to use a usb as the drive to run off of, the usb drive had to be formatted ntfs and empty, and the micro-sd must remain in while running osmc.


Just tried to add the config flags: 'otg_mode=1', 'dtoverlay=dwc2', 'dr_mode=host'

2024-01-11 18_39_05-Testing OSMC 2023-12-01 · Issue #3 · jojobrogess_script deskpifanservice — Mozil

Let the games begin! lol

Now I am going to install the addon and see if I can get my test serial to send/read info.

inspector71 commented 6 months ago

OSMC is definitely more traditional linux. It's booting Debian to Kodi. I'm really confused why it was so hard for you to create the installation but I've had a lot of fiddly annoying times with creating installable cards in RPi contexts so I guess it's not that unusual, unfortunately.

Honestly think it was the installation process. It's not that clear that you need to use the installer on a micro-sd, select that you want to use a USB as the drive to run off of, the USB drive had to be formatted NTFS and empty, and the micro-sd must remain in while running osmc.

Crikey! Yeah, I didn't realise you were installing to USB. I haven't done that for some time. Not looking forward to doing it again. Is yours running in uas mode? That's another ballache is having to upgrade the firmware on SATA board to get it to support uas.

Just tried to add the config flags: 'otg_mode=1', 'dtoverlay=dwc2', 'dr_mode=host'

2024-01-11 18_39_05-Testing OSMC 2023-12-01 · Issue #3 · jojobrogess_script deskpifanservice — Mozil

Let the games begin! lol

Yeeeha!

Throw your Stetsons to the sky! LOL

You didn't have sudo troubles?

Now I am going to install the addon and see if I can get my test serial to send/read info.

Sweet!

Hopefully pySerial will be a lot easier to install with APT ?

inspector71 commented 6 months ago

Holy Shoot!!!

https://discourse.osmc.tv/t/howto-install-a-vnc-server-on-the-raspberry-pi/1517

Might be possible to run a VNC server on an RPi4, with a newer than Matrix Kodi version, after all???

I'm too anxious to read on!

jojobrogess commented 6 months ago

Hopefully pySerial will be a lot easier to install with APT ?

More than likely yes, but since Libreelec still needs to be supported and I already injected it into the addon and all the code works that way, it might be easier to just leave it installed that way and not worry about the APT installation. Doubtful that updates would break the operation of the addon, but if it's not automatically set up it might be easier to stop that stuff from happening.

Because in testing, we'll know at least the pyserial version installed works.

And I just tested the version I installed within the addon and it works.

Might be possible to run a VNC server on an RPi4, with a newer than Matrix Kodi version, after all???

That would be awesome! Start your testing! To make the addon compatible with OSMC it will only need a few basic changes to the install process/locations. (I'm assuming if OS == or something of the like)

Although I am wondering how I'm going to do all the rpi.tools/system.tools stuff, I don't think that's going to be needed in OSMC. So the addon.xml might need to changed, which would mean the libreelec OS installer would need to adjusted to install/enable them instead of having them installed by default through addon dependencies.

inspector71 commented 6 months ago

Hopefully pySerial will be a lot easier to install with APT ?

More than likely yes, but since LibreELEC still needs to be supported and I already injected it into the addon and all the code works that way, it might be easier to just leave it installed that way and not worry about the APT installation. Doubtful that updates would break the operation of the addon, but if it's not automatically set up it might be easier to stop that stuff from happening.

Yeah, I understand where you're coming from here. Something to consider. The way OSMC is oriented towards rolling, frequent updates doesn't particularly appeal to me. However that would have to be balanced against ensuring users are aware that there may be changes to their system that are not using the standard means of installing packages. Something to think about for sure.

Because in testing, we'll know at least the pyserial version installed works.

As long as that copy of pySerial is reasonably isolated to your addon, probably fine should that be the choice.

And I just tested the version I installed within the addon and it works.

Sensational !!!

Might be possible to run a VNC server on an RPi4, with a newer than Matrix Kodi version, after all???

That would be awesome! Start your testing! To make the addon compatible with OSMC it will only need a few basic changes to the install process/locations. (I'm assuming if OS == or something of the like)

This is beyond exciting. A combination of your addon coding skills and the work to get VNC going beyond the 'sea change' in Kodi is incredible. Just quietly, I suspect the solution identified within the OSMC forum thread could also apply to LE, should I prefer that choice :)

Although I am wondering how I'm going to do all the rpi.tools/system.tools stuff, I don't think that's going to be needed in OSMC. So the addon.xml might need to changed, which would mean the libreelec OS installer would need to adjusted to install/enable them instead of having them installed by default through addon dependencies.

I was wondering about that. The nice bundling of the dependancies in the LibreELEC addons works on OSMC straight out of the box. Beautifully. But would the LE people kick up a stink if those addons were used in an OSMC context? I read somewhere that copyright is complicated for LE but all code they have written is copyright to them and "by LibreELEC' authored addons, like both System Tools and Raspberry Pi Tools most likely fall into that category. But if the RPi.GPIO libraries and pySerial etc is available easily enough via OSMC's APT package system, or otherwise, it's only that sweet simplicity of the LE addon bundling that's is being missed.

jojobrogess commented 6 months ago

I was wondering about that. The nice bundling of the dependancies in the LibreELEC addons works on OSMC straight out of the box. Beautifully. But would the LE people kick up a stink if those addons were used in an OSMC context? I read somewhere that copyright is complicated for LE but all code they have written is copyright to them and "by LibreELEC' authored addons, like both System Tools and Raspberry Pi Tools most likely fall into that category. But if the RPi.GPIO libraries and pySerial etc is available easily enough via OSMC's APT package system, or otherwise, it's only that sweet simplicity of the LE addon bundling that's is being missed.

I found out how to do it:

The dependency may be made optional by setting the optional attribute to true. 
This will only install the dependency when the add-on actually needs it. 
Even if this dependency is missing, the add-on can still be installed. 

<import addon="virtual.rpi-tools" version="10.0.0.111" optional="true"/> <import addon="virtual.system-tools" version="10.0.0.134" optional="true"/> seems to load fine in OSMC

As for copyright, I doubt the addon would be a concern for libre or osmc. Unless I wanted it to be added to the official repo. Copyright for Deskpi, yeah I'd be screwed on that one lol. 0% of the code I have is theirs, but I do use their name and logo/icon.


I was able to re-write the main.py file to dynamically import the file that gets called rather than importing every file all at once and then leaving them there. This will definitely help with leaving things in memory and keeping the overall weight to a minimum. Big win for libre and osmc.

Although it does look like the core of the addon will have to be re-written(install, uninstall, install_int, uninstall_int, restart_services). It does feel A LOT less daunting the 3rd time around haha

I think I already fixed the code for libre, I just have to check it after I finish the osmc stuff.

inspector71 commented 6 months ago

12 Jan. 2024 10:52:18 pm jojobrogess @.***>:

I was wondering about that. The nice bundling of the dependancies in the LibreELEC addons works on OSMC straight out of the box. Beautifully. But would the LE people kick up a stink if those addons were used in an OSMC context? I read somewhere that copyright is complicated for LE but all code they have written is copyright to them and "by LibreELEC' authored addons, like both System Tools[http://addons.libreelec.tv/11.0.0/ARMv8/arm/virtual.system-tools/virtual.system-tools-11.0.0.4.zip] and Raspberry Pi Tools[http://addons.libreelec.tv/11.0.0/ARMv8/arm/virtual.rpi-tools/virtual.rpi-tools-11.0.0.0.zip] most likely fall into that category. But if the RPi.GPIO libraries and pySerial etc is available easily enough via OSMC's APT package system, or otherwise, it's only that sweet simplicity of the LE addon bundling that's is being missed.

I found out how to do it:

The dependency may be made optional by setting the optional attribute to true. This will only install the dependency when the add-on actually needs it. Even if this dependency is missing, the add-on can still be installed. seems to load fine in OSMC

Optional importing seems sensible.

Whether it's best to use the LE bundles or OSMC's APT is questionable, I reckon.

I took a look at the script for VNC support an OSMC user wrote. In it, there is some handling of APT though I'm unsure at a glance why it's necessary other than the forum thread suggesting that using the script was triggering OSMC updates for some reason. If you decide to consider interacting with OSMC's APT packaging system, might be worth a read of that script which can be found here:

https://raw.githubusercontent.com/MarkusLange/VNC-Server-install-script-for-OSMC/master/osmc_vnc_install_cli.bash

... in raw format but, as I'm sure you can determine, here's the repo:

https://github.com/MarkusLange/VNC-Server-install-script-for-OSMC

Functions 'handling' APT (just dubious to dev null) start here:

https://github.com/MarkusLange/VNC-Server-install-script-for-OSMC/blob/e8859a84f6d32677203080ec19a20e025c4d5ba0/osmc_vnc_install_cli.bash#L129

Uses APT to install some dependencies:

https://github.com/MarkusLange/VNC-Server-install-script-for-OSMC/blob/e8859a84f6d32677203080ec19a20e025c4d5ba0/osmc_vnc_install_cli.bash#L291

As for copyright, I doubt the addon would be a concern for libre or osmc. Unless I wanted it to be added to the official repo. Copyright for Deskpi, yeah I'd be screwed on that one lol. 0% of the code I have is theirs, but I do use their name and logo/icon.

I don't see their logo anywhere. Is that added in the version you're working on now?


I was able to re-write the main.py file to dynamically import the file that gets called rather than importing every file all at once and then leaving them there. This will definitely help with leaving things in memory and keeping the overall weight to a minimum. Big win for libre and osmc.

Although it does look like the core of the addon will have to be re-written(install, uninstall, install_int, uninstall_int, restart_services). It does feel A LOT less daunting the 3rd time around haha

I think I already fixed the code for libre, I just have to check it after I finish the osmc stuff.

Superb effort!

Let me know when you're ready to test 😃👍🏻

jojobrogess commented 2 weeks ago

OSMC support has been added.