Amplifier Switch Plugin

Yeah, I’m sure. That was actually my first assumption - exactly the sort of error I’d be likely to make. But I checked it repeatedly, and tried a number of different variations (“Delay (ms)”, “Delay - ms”, “Delay ms”, etc.) And no matter what, the “m” always turned into an “M”. It was looking like no matter what, Volumio was set to capitalise the first letter of every word. I just tried another test … I changed it to “Delay caps aRE fuN!” which was rendered as “Delay Caps ARE FuN!”. This seems to confirn that the UI rendering engine in Volumio is set to automatically capitalise the first letter of every word on the UI element labels, regardless of what’s actually in the json. This seems like a bug to me, but perhaps the devs had some rationale for it.

By the way, I actually managed to do this without ever creating/uploading a new zip file. I just edited the json file directly on my live system. I wasn’t sure it would work, as I didn’t know if the json files were all parsed once at boot time, or if they were parsed only as needed, but its clear now that they are parsed on demand, and that furthermore the parsed results aren’t cached at all. All one has to do to see the results of editing the json is to leave and then re-enter the plugin settings page. No need to reboot, disable/re-enable, etc. I’ve read that manually editing files may cause update failures, but this doesn’t seem to apply to plug-in files, as I’ve had no issues there (I edit index.js for the ir_remote plugin to change the GPIO pin used and also uploaded my own remote config files). The only gotcha is that updating the plugin blows away all your manual changes.

This looks like a bug in the rendering to me, too. Could you please issue a bug report in the Volumio GitHub?

Done. Volumio2-UI issue #394

Hello,

i would like to use the ampswitch PlugIn to switch my “old” Yamaha amplifier on and off.
I checked inside the amp and found the pins where the standby button is soldered on. The Button shortcuts these Pins when you press it.
When you press the Button the amp will power on, if you press the Button again the amp goes to standby.
So with every edge of a shortcut on these pins the amp changes from standby to on.
I assume that the ampswitch plugin is switching the selected outport on if the amp sould be on and off when you want it to be off. (Or inverted).
Would it be possible that it just creates an Pulse whenever it wants to change the state of the amplifier?
I am quite new to rapberry. Where do i find for example port 14 in hardware? Or is this just a software port and i need some IO hardware?

regards Han

Correct, the output follows the play state. Of course it’s possible to send a short pulse. However there is still a large gap between having a voltage on a raspberry pin for a short time and emulating a physical switch in circuitry. I would suggest you first learn how to do the latter and then we can sort out the software :wink: But there are much better sources on the internet to tell you how to this then I can ever be.

Hello Fightclub,
thanks for your answer!
I know that you have to have some kind of optocoupler to shorten the amp circuit, but that is the next Problem :slight_smile:
You get the state of volumio from “volumio status” ? I am hearing music with spotify and found out that it is not showing the play status. So I searched another way to find out if music is playing. With the command "cut -d: -f2 /proc/asound/BossDAX/pcmp/sub0/status | head -1l " I get an “RUNNING” oder a “closed” when i hear nothing.
The question is now how do I get this information in your index.js where you check the play status and how to make a pulse from you on and off status. But the second topic is surely the simpler one.
Maybe the status of the DAC is the more reliable source if some music is playing. The bad thing is that everybody has another sound device…

regards Han

The problem is that listening to a socket connection is a passive thing, while polling the status of some file and doing stuff with it is an active task that needs to be executed in a high frequency, contradicting Volumio’s policy of power efficiency. Sure you can do your cut command with one core on 100% power, but don’t be surprised if your music then stops playing. The only true solution to fix this problem is for balbuze to implement the connection to the commandRouter, which as far as I see is currently prohibited by the horrible documentation of librespot. So if you want to solve the problem I’d suggest to start with volspotconnect2.

Hi!
Volspotconnect use a lib from spotify and provides a webUI on port 4000. I often thaught to integrate it in Volumio, but I never done it as the lib was supposed to be shutdown by spotify in june (but not clear)… But it still works today (I think)…
Volspotconnect2 use librespot. You can get the state (and I started some test with a small script you’'ll in the plugin directory on github “cutinfo”.
And last point, librespot can execute a command when it starts plyaing and when it stops. It’s ready in the plugin, but not activated.
Have a look at volspotconnect2.tmpl, uncomment last line (remove #) and modify the script called onstart.sh to execute the command you need (power on amp).
Hope it will help by waiting a better solution.

Thanks for your answers!
I see why my idea is not reallya good thing. :frowning: Still learning the basiscs…
I saw the cutinfo file. But wouldn’t it be the same “polling” if i take the information from that file?
When exactly will tha onstart.sh be executet? Only if I activate volspot in volumio or always if i stream music with volspot?

Humm, I don’t use the plugin, but I suppose that you need to send a command to the GPIO in onstart1.sh
something like that

sudo sh -c "echo XX > /sys/class/gpio/export" sudo sh -c "echo out >/sys/class/gpio/gpioXX/direction" sudo sh -c "echo 1 >/sys/class/gpio/gpioXX/value"
where XX is the port number
WARNING!!! THIS IS JUST A EXAMPLE OF CODE I DIDN’T CHECK IT IT MAY DAMAGE YOUR SYSTEM IF YOU USE A WRONG PORT

I have been doing pretty much this but with Spotify-Connect-Web by modifying the console-callbacks.py.
I basically run an OnConnect.sh and an OnLeave.sh before and after acquiring and releasing the ALSA sinks:-)

Just a small update -
The latest volspotoconnect now works just fine with the Amplifier Switch plugin. I am still actively working on it to get other features in there - but with respect to this plugin, it works :slight_smile:

Perfect. Thank you for your efforts! This is the way it’s supposed to be and it’s not only Spotify that benefits from these improvements. Big thumbs up.

Hi,

thanks for the update. In the meantime i managed to get it working myself. I wrote c-code which is opening the status file of my soundcard every second. So if somebody is interested just say something.
Can you adjust how long your plugin switches the pin on when it detects playback? I am currently switching the on/standby pins of my amp with a relay, so its a pulse for on and a pulse for off.

regards Nator

The plugin doesn’t support relay pulses in the current version, but there seems to be some interest in that. I will add this when I have the time.

Hi there,
I would like to switch on/off my amp more easely too, but it’s a Digital Amp (SMSL AD18)… is it possible to do it using your plugin ? Or is it a complete different thing ?

1 Like

You need some way to switch on/off your amp electronically using a pin on your raspberry or bbb.

I would love to get this option too. In my case I can use UDP or MQTT. But how about starting a user defined script when starting or stopping, where everyone can write his own command to get things done.

Thanks in advance.

Sounds like a nice idea, at least for more experienced users. Will try to implement this soon.

Cool. Glad to hear that.
Looking forward to the implementation.