[PLUGIN] RotaryEncoder II

Yiehaaw, guys, I’m a fan of yours :grinning:
Adding gpio=22=ip,pu to /boot/userconfig.txt did the trick, for both plugins.

Thank you all very much for your support, and the great plugins, of course!

2 Likes

Hi,

Experiencing a toggle issue using this plugin.

My source is spotify connect, but I have tested with the API and http://IP/api/v1/commands/?cmd=toggle works as I would expect to pause, and then play the song once issued again.

Using the short press option with play/pause toggle does not. I could not for the life of me get the Emit Websocket Message to work for volume or toggle either. Not the issue described here, but curious if that method would work since the API does work.

—INFO
Issue: UNSET VOLATILE in log. This plugin seems to issue CoreCommandRouter::volumioPlay while the API method issues CoreCommandRouter::volumioToggle which then calls CoreCommandRouter::volumioVolatilePlay. Is this plugin detecting the state and calling play/pause respectively instead of triggering a toggle when the option “play/pause toggle” is selected?

Hardware: RPI 4b
Volumio version: 3.324
Plugin Version: 1.0.15
Using KY-040 rotary encoder.

Lines added to userconfig.txt:
gpio=22=ip,pu
gpio=23,24=np

---LOG

Aug 22 19:18:54 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 pressed.
Aug 22 19:18:54 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 starting timers.
Aug 22 19:18:54 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 released after 182ms.
Aug 22 19:18:55 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 doublepush timer elapsed. (false, 1)
Aug 22 19:18:55 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 sending single push command.
Aug 22 19:18:55 yamaplayer volumio[738]: info: [ROTARYENCODER2] emitPushCommand: 3for Rotary: 1
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPause
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::pause
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::stPlaybackTimer
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::servicePause
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::servicePause
Aug 22 19:18:55 yamaplayer volumio[738]: info: Spotify Received pause
Aug 22 19:18:55 yamaplayer volumio[1134]: [Vollibrespot] : Event: Pause { track_id: SpotifyId { id: 271159150861424880642740402164439291646, audio_type: Track }, position_ms: 36997 }
Aug 22 19:18:55 yamaplayer volumio[738]: [SpotifyConnect] <State> pause
Aug 22 19:18:55 yamaplayer volumio[738]: info: [1661195935407] ControllerSpotify::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: touch_display: Setting screensaver timeout to 120 seconds.
Aug 22 19:18:55 yamaplayer volumio[738]: [SpotifyConnect] <Metadata> All That She Wants
Aug 22 19:18:55 yamaplayer volumio[738]: info: [1661195935585] ControllerSpotify::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: touch_display: Setting screensaver timeout to 120 seconds.
Aug 22 19:18:55 yamaplayer volumio[738]: info: touch_display: Using Xserver unix domain socket /tmp/.X11-unix/X0
Aug 22 19:18:55 yamaplayer volumio[1134]: [Vollibrespot] : Event: SinkInactive
Aug 22 19:18:55 yamaplayer volumio[1134]: [Vollibrespot] : Event: PlaybackStopped { track_id: SpotifyId { id: 271159150861424880642740402164439291646, audio_type: Track } }
Aug 22 19:18:55 yamaplayer volumio[738]: [SpotifyConnect] <SinkInactive> Sink released
Aug 22 19:18:55 yamaplayer volumio[738]: info: [1661195935783] ControllerSpotify::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:18:55 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:18:55 yamaplayer volumio[738]: [SpotifyConnect] <PlaybackInactive> Device palyback is inactive
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 pressed.
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 starting timers.
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 released after 169ms.
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 doublepush timer elapsed. (false, 1)
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] Push Button 1 sending single push command.
Aug 22 19:18:57 yamaplayer volumio[738]: info: [ROTARYENCODER2] emitPushCommand: 3for Rotary: 1
Aug 22 19:18:57 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPlay
Aug 22 19:18:57 yamaplayer volumio[738]: verbose: UNSET VOLATILE
Aug 22 19:18:57 yamaplayer volumio[738]: [SpotifyConnect] unSetVolatile called
Aug 22 19:18:57 yamaplayer volumio[738]: info: Spotify Unset Volatile called
Aug 22 19:18:57 yamaplayer volumio[738]: [SpotifyConnect] Relinquishing Volumio State to another service
Aug 22 19:18:57 yamaplayer volumio[738]: [SpotifyConnect] Spotify Received stop
Aug 22 19:18:57 yamaplayer volumio[738]: info: CoreStateMachine::play index undefined
Aug 22 19:18:57 yamaplayer volumio[738]: info: CoreStateMachine::setConsumeUpdateService undefined
Aug 22 19:18:57 yamaplayer volumio[738]: info: CorePlayQueue::getTrack 0
Aug 22 19:18:57 yamaplayer volumio[1134]: [Vollibrespot] : Pause
Aug 22 19:18:57 yamaplayer volumio[738]: [SpotifyConnect] <Pong> Pause


---Log below of the API toggle method:

Aug 22 19:31:06 yamaplayer volumio[738]: info: Continuing Spotify Session
Aug 22 19:31:06 yamaplayer volumio[738]: info: Checking Spotify Web API
Aug 22 19:31:06 yamaplayer volumio[738]: [SpotifyConnect] Vollibrespot Active
Aug 22 19:31:06 yamaplayer volumio[738]: info: CoreStateMachine::setConsumeUpdateService undefined
Aug 22 19:31:06 yamaplayer volumio[738]: info: [1661196666527] ControllerSpotify::pushState
Aug 22 19:31:06 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:06 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:06 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:31:06 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:06 yamaplayer volumio[1134]: [Vollibrespot] : Resolved 50 tracks from <"spotify:playlist:24X0uAQQ7xQRUZbIBXoJEn">
Aug 22 19:31:29 yamaplayer volumio[738]: info:
Aug 22 19:31:29 yamaplayer volumio[738]: ---------------------------- Client requests Volumio toggle
Aug 22 19:31:29 yamaplayer volumio[738]: info: CoreCommandRouter::volumioToggle
Aug 22 19:31:29 yamaplayer volumio[738]: info: CoreStateMachine::pause
Aug 22 19:31:29 yamaplayer volumio[738]: info: CoreStateMachine::stPlaybackTimer
Aug 22 19:31:29 yamaplayer volumio[738]: info: CoreStateMachine::servicePause
Aug 22 19:31:29 yamaplayer volumio[738]: info: CoreCommandRouter::servicePause
Aug 22 19:31:29 yamaplayer volumio[738]: info: Spotify Received pause
Aug 22 19:31:30 yamaplayer volumio[1134]: [Vollibrespot] : Event: Pause { track_id: SpotifyId { id: 332950509448765273390885195956970640202, audio_type: Track }, position_ms: 117493 }
Aug 22 19:31:30 yamaplayer volumio[738]: [SpotifyConnect] <State> pause
Aug 22 19:31:30 yamaplayer volumio[738]: info: [1661196690191] ControllerSpotify::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: touch_display: Setting screensaver timeout to 120 seconds.
Aug 22 19:31:30 yamaplayer volumio[738]: [SpotifyConnect] <Metadata> Creep
Aug 22 19:31:30 yamaplayer volumio[738]: info: [1661196690411] ControllerSpotify::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:30 yamaplayer volumio[1134]: [Vollibrespot] : Event: SinkInactive
Aug 22 19:31:30 yamaplayer volumio[1134]: [Vollibrespot] : Event: PlaybackStopped { track_id: SpotifyId { id: 332950509448765273390885195956970640202, audio_type: Track } }
Aug 22 19:31:30 yamaplayer volumio[738]: [SpotifyConnect] <SinkInactive> Sink released
Aug 22 19:31:30 yamaplayer volumio[738]: info: [1661196690647] ControllerSpotify::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:30 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:30 yamaplayer volumio[738]: [SpotifyConnect] <PlaybackInactive> Device palyback is inactive
Aug 22 19:31:32 yamaplayer volumio[738]: info:
Aug 22 19:31:32 yamaplayer volumio[738]: ---------------------------- Client requests Volumio toggle
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::volumioToggle
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::volumioVolatilePlay
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreStateMachine::volatilePlay
Aug 22 19:31:32 yamaplayer volumio[738]: info: Spotify Play
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Fetching autoplay context uri
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Event: TrackChanged { old_track_id: SpotifyId { id: 332950509448765273390885195956970640202, audio_type: Track }, track_id: SpotifyId { id: 332950509448765273390885195956970640202, audio_type: Track } }
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Autoplay uri resolved to <"spotify:station:playlist:24X0uAQQ7xQRUZbIBXoJEn">
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Resolving uri "spotify:station:playlist:24X0uAQQ7xQRUZbIBXoJEn"
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Event: SinkActive
Aug 22 19:31:32 yamaplayer volumio[738]: [SpotifyConnect] <Metadata> Creep
Aug 22 19:31:32 yamaplayer volumio[738]: info: [1661196692577] ControllerSpotify::pushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:32 yamaplayer volumio[738]: [SpotifyConnect] <SinkActive> Sink acquired
Aug 22 19:31:32 yamaplayer volumio[738]: info: Continuing Spotify Session
Aug 22 19:31:32 yamaplayer volumio[738]: info: Checking Spotify Web API
Aug 22 19:31:32 yamaplayer volumio[738]: [SpotifyConnect] Vollibrespot Active
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreStateMachine::setConsumeUpdateService undefined
Aug 22 19:31:32 yamaplayer volumio[738]: info: [1661196692591] ControllerSpotify::pushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::servicePushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreStateMachine::pushState
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::executeOnPlugin: volumiodiscovery , saveDeviceInfo
Aug 22 19:31:32 yamaplayer volumio[738]: info: CoreCommandRouter::volumioPushState
Aug 22 19:31:32 yamaplayer volumio[1134]: [Vollibrespot] : Resolved 50 tracks from <"spotify:playlist:24X0uAQQ7xQRUZbIBXoJEn">

Cool :sunglasses:
Since I do not own a KY-040, can somebody solve the mystery of the 3 resistors? I thought they are pull-ups for Rotary channels A & B and push-button. But obviously not, right?

I have a KY-040, what are you specifically looking for?

The board has 3x resistor traces with only 2x 10K resistors installed.

The userconfig.txt only resolved the push button, volume up/down worked fine before adding any of it.

Ahhhh. That explains it. There are only two pull-ups not 3. Then I can understand why it works when we enable the internal pull-up and it also explains the erratic behavior (floating input).
Thanks for the picture!
I will look into your other question toward the weekend. Too tired today and too busy over the next days. Your setup is quite different from mine, so I have to study your log in detail

Glad I could help.

Sounds good, I’ll poke around myself and see what I can find as well.

Yeah, my board is exactly the same. Did not see that one resistor is actually missing, fck, very confusing shit, that 040 :grin:

How about putting that hint for configuring that pullup stuff in userconfig.txt inside the plugin-config-page by a nifty little info-mouseover-button, he? Since I’ve failed also with kinda alps-encoder it’s not only a ky-040 issue.

And since people are about to install a hardware plugin, it is to expect they don’t “paddle on a noodle-soup”, like we austrians say :sweat_smile: and are able to fiddle with config.txt’s.

On the other hand, when you do so, how in future do we get magic people like me into the community :thinking::joy:

Using a normal playlist of locally stored media the rotary plugin is working as expected?
If so, it’s more likely a spotify-plugin-issue, I guess.

I don’t have any local media, end goal is to create a Spotify connect speaker system. I did use a local web radio and I believe it did work properly. I’ll confirm tomorrow.

But, the toggle command through the API works perfectly for Spotify. So I would also assume this plugin is doing something different since it’s throwing the error in the logs.

Maybe a combination of both? But so far the only error I can create is from the “play/pause toggle” of this plugin while using Spotify connect.

Local ui play/pause button works and API toggle works.

Had a look at your log. The first six lines look completely good. We send toggle play/pause and Volumio’s CoreCommandRouter acknowledged receipt of the command on line 7: volumioPause.
At 19:18:57 the same block occurs, when you press the button again and in the 7th line the CoreCommandRouter acknowledges again: volumioPlay.
There is no error message from the plug-in nor any other message.

In your other method you are calling volumioToggle while the plug-in uses pause and play. However, you should be able to select sending a Websocket command for your button in the plug-in settings and put „toggle“ into the Command field and leave the data field empty. See if that does the trick.
However, it’s still strange, if the Spotify plug-in reacts correctly on toggle and pause, but not on play. I am not using Spotify, so I never tested your scenario. Might still be worth to check, why the Spotify-plug-in does not react on play. If there is a good reason, I could modify my code to use toggle as well.

I‘ll add it to the readme.md and the context help with the next update.
However, as somebody working in semiconductor reliability, I am still a big fan of external resistors on systems, where the user can change the IO-pad configuration easily :wink:
I may even be able to make the internal pull up configurable from the plug-in settings on one of the long winter nights to come.

Sadly i have yet to figure out what is wrong with the Emit Websocket Message as it will crash the system everytime I try to use it.

—LOG

-- Logs begin at Mon 2022-08-22 21:15:14 UTC. --
Aug 23 14:38:44 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:44 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:44 yamaplayer volumio-streaming-daemon[2439]: Environment: production
Aug 23 14:38:44 yamaplayer volumio[2221]: info: Fetching Streaming Services browse cache
Aug 23 14:38:45 yamaplayer volumio[2221]: error: Failed to add MyVolumio device: {"message":"USER_NOT_FOUND"}
Aug 23 14:38:45 yamaplayer volumio[2221]: info: Updating MyVolumio device info
Aug 23 14:38:45 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:45 yamaplayer volumio[2221]: error: Failed to update MyVolumio device: {"message":"DEVICE_NOT_FOUND"}
Aug 23 14:38:46 yamaplayer volumio-streaming-daemon[2439]: Environment: production
Aug 23 14:38:46 yamaplayer volumio[2221]: info: Fetching Streaming Services browse cache
Aug 23 14:38:49 yamaplayer volumio[2221]: info: MYVOLUMIO: Adding device
Aug 23 14:38:49 yamaplayer volumio[2221]: info: MYVOLUMIO: Evaluating Server
Aug 23 14:38:49 yamaplayer volumio[2221]: info: Setting Geolocation for MyVolumio to us3
Aug 23 14:38:49 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:49 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:49 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:49 yamaplayer volumio[2221]: error: Failed to add MyVolumio device: {"message":"USER_NOT_FOUND"}
Aug 23 14:38:50 yamaplayer volumio[2221]: info: Updating MyVolumio device info
Aug 23 14:38:50 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:50 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:50 yamaplayer volumio[2221]: info: CoreCommandRouter::executeOnPlugin: system , getConfigParam
Aug 23 14:38:51 yamaplayer volumio[2221]: error: Failed to update MyVolumio device: {"message":"DEVICE_NOT_FOUND"}
Aug 23 14:38:52 yamaplayer volumio[2221]: info: [ROTARYENCODER2] Push Button 1 pressed.
Aug 23 14:38:52 yamaplayer volumio[2221]: info: [ROTARYENCODER2] Push Button 1 starting timers.
Aug 23 14:38:52 yamaplayer volumio[2221]: info: [ROTARYENCODER2] Push Button 1 released after 170ms.
Aug 23 14:38:53 yamaplayer volumio[2221]: info: [ROTARYENCODER2] Push Button 1 doublepush timer elapsed. (false, 1)
Aug 23 14:38:53 yamaplayer volumio[2221]: info: [ROTARYENCODER2] Push Button 1 sending single push command.
Aug 23 14:38:53 yamaplayer volumio[2221]: |||||||||||||||||||||||| WARNING: FATAL ERROR |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Aug 23 14:38:53 yamaplayer volumio[2221]: SyntaxError: Unexpected end of JSON input
Aug 23 14:38:53 yamaplayer volumio[2221]:     at JSON.parse (<anonymous>)
Aug 23 14:38:53 yamaplayer volumio[2221]:     at rotaryencoder2.emitPushCommand (/data/plugins/system_hardware/rotaryencoder2/index.js:725:17)
Aug 23 14:38:53 yamaplayer volumio[2221]:     at Timeout._onTimeout (/data/plugins/system_hardware/rotaryencoder2/index.js:532:18)
Aug 23 14:38:53 yamaplayer volumio[2221]:     at listOnTimeout (internal/timers.js:554:17)
Aug 23 14:38:53 yamaplayer volumio[2221]:     at processTimers (internal/timers.js:497:7)
Aug 23 14:38:53 yamaplayer volumio[2221]: |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Aug 23 14:38:53 yamaplayer sudo[2490]:  volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/journalctl --since=2022-08-23 14:37
Aug 23 14:38:53 yamaplayer sudo[2490]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 23 14:38:53 yamaplayer sudo[2490]: pam_unix(sudo:session): session closed for user root
Aug 23 14:38:53 yamaplayer volumio-remote-updater[491]: [2022-08-23 14:38:53] [error] handle_read_frame error: websocketpp.transport:7 (End of File)
Aug 23 14:38:53 yamaplayer volumio-remote-updater[491]: [2022-08-23 14:38:53] [disconnect] Disconnect close local:[1006,End of File] remote:[1006]
Aug 23 14:38:53 yamaplayer systemd[1]: volumio.service: Main process exited, code=exited, status=1/FAILURE
Aug 23 14:38:53 yamaplayer systemd[1]: volumio.service: Failed with result 'exit-code'.
Aug 23 14:38:53 yamaplayer systemd[1]: Started dynamicswap service.
Aug 23 14:38:53 yamaplayer systemd[1]: dynamicswap.service: Succeeded.
Aug 23 14:38:54 yamaplayer systemd[1]: volumio.service: Service RestartSec=100ms expired, scheduling restart.
Aug 23 14:38:54 yamaplayer systemd[1]: volumio.service: Scheduled restart job, restart counter is at 3.
Aug 23 14:38:54 yamaplayer systemd[1]: Started dynamicswap service.
Aug 23 14:38:54 yamaplayer systemd[1]: Stopped Volumio Backend Module.
Aug 23 14:38:54 yamaplayer systemd[1]: Started Volumio Backend Module.
Aug 23 14:38:54 yamaplayer systemd[1]: dynamicswap.service: Succeeded.
Aug 23 14:38:55 yamaplayer volumio[2501]: info: -------------------------------------------
Aug 23 14:38:55 yamaplayer volumio[2501]: info: -----            Volumio3              ----
Aug 23 14:38:55 yamaplayer volumio[2501]: info: -------------------------------------------
Aug 23 14:38:55 yamaplayer volumio[2501]: info: -----          System startup          ----
Aug 23 14:38:55 yamaplayer volumio[2501]: info: -------------------------------------------

Did not try it myself yet, because my test-system is not workable at the moment. Websocket works normally in another setup I‘m heavily using, but I never tried the toggle command. Will check toward the weekend why it crashes, but currently have no time. Will respond asap

yea it is strange, nothing for websocket works for me. I originally followed the steps exactly and tried doing volume + & - via the emit command. Same results of crashing.

Hi! Thanks for the bug report - it is acutally my fault - apologies. I implemented the websocket emit functionality for something more complex (sending commands between the rotary and another plugin I am working on).
When I wrote the docs, I wanted to show a very simple example, but after I improved my code to do the complex stuff, I broke the simple stuff explained in the docs. Unfortunately, I never tried it again, because it is not really important for me.
I made a quick and simple fix (beta 1.0.17) that will work with the complex and the simple stuff. It works on my test system. For the moment that should solve your issue, if you put toggle into command and nothing into data, as shown above.
Currently I cannot do more… will see if I can also implement toggle in the drop-down later with more than 30 minutes time.
Let me know if it works.

Works perfectly, toggle now pauses / plays spotify connect without any issues.

I also got next track to work with double click via the websocket.

Thank you!

Just to finish with my KY-040 issue, and for your list of compatible encoders, the conclusio:

No capacitors or resistors on any pins needed, the KY-040 has two 10k resistors onboard for clk/dt, but obviously not for the switch, so the gpio-pullup needs to be enabled for the push button gpio.

A debounce value of 40ms is good and has no negative effect by rotating. Below that value or zero only every second/third push works.

Regards,
Phil

1 Like

Thanks,will add it in the next update of the docs! (Including the setting for the internal PU)

Hello,

I have an RPi4 + AMP100 (Hifiberry) with Volumio 3.378. I installed the Rotary Encoder II plugin but it looks live I have issue with my rotary encoder (KY-040 I guess).

Here is what I get with : journalctl | grep -i encoder*

Dec 10 18:26:06 litra kernel: bcm2835-codec bcm2835-codec: Loaded V4L2 encode
Dec 10 18:26:36 litra volumio[814]: info: Loading plugin "rotaryencoder2"...
Dec 10 18:26:37 litra sudo[974]:  volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay rotary-encoder pin_a=22 pin_b=17 relative_axis=true steps-per-period=2
Dec 10 18:26:38 litra kernel: rotary-encoder rotary@16: gray
Dec 10 18:26:38 litra kernel: rotary-encoder rotary@16: unable to get gpios: -16
Dec 10 18:26:38 litra kernel: rotary-encoder: probe of rotary@16 failed with error -16
Dec 10 18:26:39 litra volumio[814]: error: [ROTARYENCODER2] addEventHandle: stderr: /bin/cat: /dev/input/by-path/platform-rotary@16-event: No such file or directory

1 Like

Quote from Hifiberry website https://www.hifiberry.com/docs/hardware/gpio-usage-of-hifiberry-boards/

HiFiBerry Amp100

GPIO2-3 (pins 3 and 5) are used by our products for configuration. If you are experienced with I2C, you might add other slave devices. If you a a novice, we don’t recommend this at all.
GPIOs 18-21 (pins 12, 35, 38 and 40) are used for the sound interface. You can’t use these for any other purpose.
GPIO4 is used to control the MUTE function of the power stage. Pulling it to high will mute the output.
GPIO17 is used to reset the power stage (active low).

Seems from your diagram you are trying to use GPIO 17 with the rotary encoder, which is also being used by the Hifiberry.
Maybe the Problem ?

1 Like