Amplifier Switch Plugin

Juhu! Danke! (Great! Thanks! :smiley: )
Will try it in the next days and post my feedback.

Kein Problem! :slight_smile:

Hope to implement this feature in the official plugin soon. The functionality itself is, as hannes has shown, is done in less than a minute, but working on the UI always bugs me, I somehow always manage to break the XML :unamused:

Geil! Funktioniert!! (Wooohooo! It works!)

Thanks a lot! Great plugin!

EDIT: But unfortunately it doesn’t work when i stream with spotify connect :frowning:
EDIT2: At least i’ve got a workaround for me. I’m using Home Assistant on another RPi Zero W to control some switches and also Volumio. With an automation i can send my relay command and switch my amp, when spotify is streaming.

1 Like

That’s strange, we had this before and according to github.com/balbuze/volumio-plugins/issues/83 this should have been solved.

Hmm, actually it doesn’t work for me when streaming with spotify connect. Just tested it again.
Playling a local song or a song with the “normal” spotify plugin works flawless.

btw, when i play a song with spotify connect, the volumio mediacontrols don’t change. the icon “play” doesn’t change to “pause”. i don’t know if this behaviour is normal.

EDIT: i just found out that your plugin isn’t working with volspotconnect2, but with volspotconnect (there are two different versions)!

Okay, since I’m not using spotify I have no idea about those plugins. But bottomline: If a media plugin, i.e. a plugin that serves an audio stream to volumio, regardless of the source, does not properly implement Volumio’s policy of sending websocket events for play/pause/stop, etc. then the plugin will not trigger AmpSwitch. This however is not a flaw of AmpSwitch, but of the plugin that does not communicate it’s status. I therefore suggest you visit the author’s GitHub and report an issue about this.

Since Spotify Connect uses a separate daemon that is not connected to the mpd of Volumio, it doesn’t really communicate to well to Volumio, which leads to issues such as this. With volspotconnect I got it talking to Volumio, and this pluging should work fine, but volsptoconnect2 uses an entirely different daemon. The first steps are in place, and hopefully soon we should have volspotconnect2 communicating to Volumio soon! :slight_smile:

@Fightclub,
I had some time today, implemented relay pulses as well, but wanted to check with you about the UI naming nomenclature before submitting a PR.
I added a simple toggle, that when enabled gives a ‘pulse duration’ setting

changes here

Oh, I need some help with the DE translation, mein deutsch is ok, aber mein technisches Deutsch is nicht so gut!
What would the ideal translation of pulse width/duration?

Technically, since these are all just different relay types, would you prefer a drop down to select the relay type?
That way we can have : Normal, Latching, Dual_Latching… etc

Cheers!

Hi,
I have a power amplifier in my setup, which can be remotely switched on/off via 6.35 mm jack connector. When there is active voltage of 12 V, it is on, otherwise it is off. It is kinda industry standard, applied by many traditional electronic devices manufacturers. Does anybody know about piece of hardware, which I could connect to Rpi 3 to switch the amplifier on/off using Volumio and Amplifier Switch Plugin?

@spyking: Thanks for the amazing work :slight_smile: The nomenclature looks good to me, also the UI design. At first I thought about merging the latching with the inverter flag into a drop down, like: operation mode: Normal, inverted, latching. But when looking at your solution I realised that you might also want to have inverted latching, so I think it makes more sense to make it two separate switches. I’m just not sure what you mean with the dual latching? Sending two pulses?
Already saw your PR, will look into it in the next few days and add the german translation :slight_smile:

You can solder together a pretty simple circuit that takes the output of the GPIO of the RPi 3 and drives a 12V output to the Amplifier Jack. I guess a MOSFET should suffice, if you really want to have it decoupled you may want to use an opto-isolator and an additional transistor.

1 Like

I initially wanted to have an “Normally Open, Normally Closed, Latching” drop down - but then I thought it became unnecessarily verbose and meh, so left it at this. When you toggle “Latching” - you get the on pulse and off pulse setting, keeping it simple.

Sooo… what next? Multi GPIOs? I do have a pre, and power amp… :smiley:

Good move :slight_smile:

Is this really a thing with the two GPIOs? I usually prefer hardwired solutions for this kind of thing, whenever it’s easily possible, gives more reliability and doesn’t unnecessarily populate the GPIOs, but I get the impression that I’m the only one with this idea here :smiley:

Btw, I added the PR for the german language strings. Volumio was faster to integrate your PR than I was with adding the strings :smiley:

1 Like

Any news on this? I am looking for a way to turn on/off my tube amps.

Is there a way to get the version of this plugin with relay pulse already now or do I have to wait for the official release in the plugin manager of Volumio?

Well - I pushed the changes to the official repo
But it looks like the plugin manager is not pulling the updated changes? :confused:

Can I install the new version of the plugin if I download the files from GitHub and upload them as zip file on my volumio

Yes - but I am unsure how the pluginmanager gets the node_modules which aren’t included in the git repo.
But you can try with the attached zip :slight_smile:
ampswitch.zip (1.05 MB)

@Fightclub

I just ran into this error while trying to uninstall the plugin - Any ideas?

Mar 01 18:14:21 volumio volumio[23345]: info: Starting Uninstall of plugin miscellanea - ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: Uninstalling plugin ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: PLUGIN STOP: ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Port: 14
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Inverted: false
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Delay: 720
Mar 01 18:14:21 volumio volumio[23345]: fs.js:610
Mar 01 18:14:21 volumio volumio[23345]: return binding.close(fd);
Mar 01 18:14:21 volumio volumio[23345]: ^
Mar 01 18:14:21 volumio volumio[23345]: Error: EBADF: bad file descriptor, close
Mar 01 18:14:21 volumio volumio[23345]: at Error (native)
Mar 01 18:14:21 volumio volumio[23345]: at Object.fs.closeSync (fs.js:610:18)
Mar 01 18:14:21 volumio volumio[23345]: at Object.<anonymous> (/volumio/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Object.<anonymous> (/data/plugins/miscellanea/ampswitch/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Object.closeSync (/data/plugins/music_service/volspotconnect2/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Gpio.unexport (/data/plugins/miscellanea/ampswitch/node_modules/onoff/onoff.js:354:6)
Mar 01 18:14:21 volumio volumio[23345]: at AmpSwitchController.freeGPIO (/data/plugins/miscellanea/ampswitch/index.js:230:19)
Mar 01 18:14:21 volumio volumio[23345]: at AmpSwitchController.onStop (/data/plugins/miscellanea/ampswitch/index.js:84:10)
Mar 01 18:14:21 volumio volumio[23345]: at PluginManager.stopPlugin (/volumio/app/pluginmanager.js:292:27)
Mar 01 18:14:21 volumio volumio[23345]: at PluginManager.unInstallPlugin (/volumio/app/pluginmanager.js:1149:8)
Mar 01 18:14:21 volumio volumio[23345]: at CoreCommandRouter.unInstallPlugin (/volumio/app/index.js:1343:21)
Mar 01 18:14:21 volumio volumio[23345]: at Socket.<anonymous> (/volumio/app/plugins/user_interface/websocket/index.js:1094:55)
Mar 01 18:14:21 volumio volumio[23345]: at emitTwo (events.js:106:13)
Mar 01 18:14:21 volumio volumio[23345]: at Socket.emit (events.js:191:7)
Mar 01 18:14:21 volumio volumio[23345]: at /volumio/node_modules/socket.io/lib/socket.js:503:12
Mar 01 18:14:21 volumio volumio[23345]: at _combinedTickCallback (internal/process/next_tick.js:73:7)
Mar 01 18:14:21 volumio volumio[23345]: at process._tickCallback (internal/process/next_tick.js:104:9)
Mar 01 18:14:21 volumio volumio-remote-updater[574]: [2018-03-01 18:14:21] [error] handle_read_frame error: websocketpp.transport:7 (End of File)
Mar 01 18:14:21 volumio volumio-remote-updater[574]: [2018-03-01 18:14:21] [disconnect] Disconnect close local:[1006,End of File] remote:[1006]
Mar 01 18:14:21 volumio systemd[1]: volumio.service: main process exited, code=exited, status=1/FAILURE
Mar 01 18:14:21 volumio systemd[1]: Unit volumio.service entered failed state.

Thanks for packing the plugin now it works

@spyking: At the time of writing the initial version of the plugin I ran into this problem once or twice, but, at least to me, it was not reproducible. From what I get from the log it runs into a problem when stopping the plugin and returning its privileges on the GPIO. I’m unsure whether this happens when
a) Plugin is installed and before activation deinstalled again, i.e. it has not been started and thus never claimed the default GPIO
b) a GPIO is being claimed/released that is still allocated by something else
c) some hiccup occurs in the underlying node modules, e.g. onoff

I always wanted to make it a bit more robust using some error handling like try ... catch .... , but I have not run into this problem again and no one else reported it until now, so motivation was rather low :wink:
Maybe you can try to fiddle around with it a bit to verify that one or none of the above points is actually the case, I’m currently pretty busy and just sporadically find the time to look in here.

Dear all,

has anyone used ampswitch on the pine64?
i’m not too much into coding, if you could me direct me in the right direction i would be really happy :slight_smile:

cheers

journalctl says the following:

Mar 31 16:41:37 pandit volumio[3899]: Discovery: Started advertising... pandit - undefined
Mar 31 16:41:37 pandit volumio[3899]: info: CoreCommandRouter::executeOnPlugin: system , registerCallback
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "albumart"...
** Mar 31 16:41:37 pandit volumio[3899]: info: Plugin example_plugin is not enabled
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "updater_comm"...
Mar 31 16:41:37 pandit volumio[3899]: info: Plugin mpdemulation is not enabled
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "rest_api"...
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "websocket"...
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "volspotconnect2"...
Mar 31 16:41:38 pandit volumio[3899]: info: ___________ START PLUGINS ___________
** Mar 31 16:41:38 pandit volumio[3899]: info: PLUGIN START: ampswitch
Mar 31 16:41:38 pandit volumio[3899]: fs.js:641
Mar 31 16:41:38 pandit volumio[3899]: return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Mar 31 16:41:38 pandit volumio[3899]: ^
Mar 31 16:41:38 pandit volumio[3899]: Error: EACCES: permission denied, open '/sys/class/gpio/export'
Mar 31 16:41:38 pandit volumio[3899]: at Error (native)
Mar 31 16:41:38 pandit volumio[3899]: at Object.fs.openSync (fs.js:641:18)
Mar 31 16:41:38 pandit volumio[3899]: at Object.fs.writeFileSync (fs.js:1347:33)
Mar 31 16:41:38 pandit volumio[3899]: at new Gpio (/data/plugins/miscellanea/ampswitch/node_modules/onoff/onoff.js:84:8)
Mar 31 16:41:38 pandit volumio[3899]: at AmpSwitchController.ampGPIOInit (/data/plugins/miscellanea/ampswitch/index.js:155:21)
Mar 31 16:41:38 pandit volumio[3899]: at AmpSwitchController.onStart (/data/plugins/miscellanea/ampswitch/index.js:60:10)
Mar 31 16:41:38 pandit volumio[3899]: at PluginManager.startPlugin (/volumio/app/pluginmanager.js:256:27)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.<anonymous> (/volumio/app/pluginmanager.js:332:29)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.forEach (/volumio/node_modules/hashmap/hashmap.js:157:10)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.proto.(anonymous function) [as forEach] (/volumio/node_modules/hashmap/hashmap.js:169:7)
Mar 31 16:41:38 pandit systemd[1]: volumio.service: main process exited, code=exited, status=1/FAILURE
Mar 31 16:41:38 pandit systemd[1]: Unit volumio.service entered failed state.