MiczFlor / RPi-Jukebox-RFID

A Raspberry Pi jukebox, playing local music, podcasts, web radio and streams triggered by RFID cards, web app or home automation. All plug and play via USB. GPIO scripts available.
http://phoniebox.de
MIT License
1.4k stars 398 forks source link

GPIO Default Behaviour after Reboot? #1744

Open Karli2727 opened 2 years ago

Karli2727 commented 2 years ago

I have a very trivial issue, I built a Box with GPIO buttons and it works like a charm. My child however is still very young and when we are playing something for her she randomly pushes buttons which can be quite annoying :-) So I disabled the gpio buttons on the web interface - which works fine.

image

however after a reboot the gpio settings return to being active, it does not remember the setting I chose on the web interface.

I also tried setting the default option in the gpio_settings.ini to false but it did not have an effect.

image

The only way to actually disable the buttons is to set every single button to enabled : false in gpio_settings.ini - which means that I cannot reactivate it from the GUI if I need the buttons to work for some time.

image

I am running Raspbian GNU/Linux 11 (bullseye) which I freshly installed in January 2022 from the newest installer.

Am I doing something terribly wrong here or is this a bug?

All the best Karl

Karli2727 commented 2 years ago

I'm sorry if I have done something wrong with submitting this issue, but is there a reason why I haven't gotten any reaction on it for the past 9 days? I saw that other issues were answered or at least labelled a couple of hours after they've been submitted. Did I break some code of conduct here?

I edited the initial post now with screenshots. Also I realised that I had some issue with case sensitivity when I put enabled : false I accidently wrote enabled : False when I was trying to disable the individual buttons which resulted in it not working properly. However the Default Button behaviour does not load properly regardless of the case sensitivity issue.

pabera commented 2 years ago

Hey Karl!

I'm sorry if I have done something wrong with submitting this issue, but is there a reason why I haven't gotten any reaction on it for the past 9 days?

No one tries to avoid your post but usually people only answer when they really have something to say. And maybe that wasn't the case for your request.

The problem you describe is probably correct, and I don't have a solution for you now. This is mainly due to the fact that you are using 2.x but the current development focus is on 3.x.

I actually like the idea of switching of GPIO buttons on demand and of course, it should remain active after reboot as well. Why don't you tag this issue as future3 and a feature request so it can be considered.

Unless you are able to fix it yourself, there might not be much support at the moment for such a feature in 2.x.

Karli2727 commented 2 years ago

Thank you very much for your reply. I understand the development focuses on 3.x and it would be great if it was considered there.

I wouldn't classify this as a feature though because it already exists in the current GUI with the implemented Toggle Button, just that the state is not saved upon reboot which it should be because it is a general setting of the box.

Also I am afraid I don't have the power to label this thread, at least I don't have the symbol next to the labels section to do so.

Update: I managed to implement a workaround. I detect the online status of the box with a ping sensor from home-assistant and if it goes online I'm sending a mqtt command to disable the gpio controls, it works as long as the box is booted within my wifi network which at the moment is almost always the case.

AlvinSchiller commented 9 months ago

Though this is a bit old, here would be a local solution to save the state even after reboot:

Open the file htdocs/inc.header.php and go to line 331 (starting with gpiostatus). Add && /usr/bin/sudo /bin/systemctl enable phoniebox-gpio-control.service to the turnon definition. Add && /usr/bin/sudo /bin/systemctl disable phoniebox-gpio-control.service to the turnoff definition.

The result should look someting like this:

    'gpiostatus' => array(
        'turnon' => "/usr/bin/sudo /bin/systemctl start phoniebox-gpio-control.service && /usr/bin/sudo /bin/systemctl enable phoniebox-gpio-control.service",                    // start the gpio control service
        'turnoff' => "/usr/bin/sudo /bin/systemctl stop phoniebox-gpio-control.service && /usr/bin/sudo /bin/systemctl disable phoniebox-gpio-control.service"                     // stop the gpio control service
    ),

With the enable / disable commands the state of the service is preserved on reboot.

AlvinSchiller commented 9 months ago

Another idea for the described case, would be to set the hold_mode of the Buttons to Postpone. This delays the execution with hold_time. So you have to hold the buttons a while and not just single push them.