balbuze / volumio-plugins

volumio's plugins from balbuze
190 stars 60 forks source link

volspotconnect2: change volumio status from idle to playing (or something else) #101

Closed richpuch closed 6 years ago

richpuch commented 6 years ago

Thanks for volspotconnect2....working great on my install of volumio. I'm running a clean install of volumio with just the volspotconnect2 plugin.

Question: I'm using home assistant, and have an automation when Volumio changes state from idle (or any other state) to playing it will turn on a z-waveplug thus turning on my amplifier and EQ. Works great and save me steps from going and turning it on every time I want to play music. Now that I'm using the volspotconnect2 plugin, I was wondering if there is any chance of changing the status of volumio from idle to something else when using the plugin. This would trigger an automation in home assistant to power on the amplifier and EQ when the status chnage is detected?

Once again...great plug-in makes my back yard life more njoyable with firiends.

balbuze commented 6 years ago

Hi, Volspotconnect2 still needs a lot of work... But I see two way of achieving what you want 1- Adding in command in /data/plugins/music-service/volspotconnect2/onstart1.sh . There is command to stop volumio playing something else when spotify starts, but you can add your own script. 2- Using volspotconnect. Everything is done, with album art and title displayed in volumio UI, and the state updated. (the easiest way)

richpuch commented 6 years ago

Thanks a bunch...I took method 1 and got it working:

!/bin/bash

wget "localhost:3000/api/v1/commands/?cmd=stop" wget "localhost:3000/api/v1/commands/?cmd=volume&volume=70" /usr/bin/curl -X POST -H "x-ha-access: PASSWORD" \ -H "Content-Type: application/json" \ -d '{"entity_id": "switch.zooz_plug_1_switch"}' \ http://x.x.x.x:8123/api/services/switch/turn_on

Obvious PASSWORD is my password and x.x.x.x is IP of home assistant.

Great plugin...love it!!!!

richpuch commented 6 years ago

balbuze,

Does onstart1.sh still get called by volspotconnect2? I updated to latest version and I can't get my line of code to execute...if I cut and paste to command line it works..but not from the script. If I execute the script by doing ./onstart1.sh I get the desired results.

Thanks in advance

balbuze commented 6 years ago

hi! it still use onstart1.sh... After you added your line, make sure onstart1.sh is still executable (sudo chmod +x onstart1.sh) I just tested it on a fresh install and it works.

richpuch commented 6 years ago

Thanks for quick response...prior to doing the chmod command my permissions looked like this: -rwxr-xr-x 1 volumio volumio 331 Jan 31 17:46 onstart1.sh

I did the chmod command and still it doesn't seem to be called...I removed my line of code and added a simple touch command to make the script create a blank file and still get nothing...the volumio plays my spotify music...but the onstart1.sh file isn't called (at least it doesn't seem to be). Here is what it looks like:

!/bin/bash

/usr/bin/curl "localhost:3000/api/v1/commands/?cmd=stop" touch /data/plugins/music_service/volspotconnect2/txt.txt

If I execute the file "./onstart1.sh" from a command line prompt, it creates the txt.txt file.

In Volumio pluggins it is showing up as Volumio Spotify Connect2 ver0.4.9

I assume, every time I select play or when a song changes in spotify it should call the script...at least thats how it worked in the previous version.

balbuze commented 6 years ago

try usr/bin/touch /data/plugins/music_service/volspotconnect2/txt.txt to see if better

balbuze commented 6 years ago

/usr/bin/touch /data/plugins/music_service/volspotconnect2/txt.txt

richpuch commented 6 years ago

still nothing:

cat onstart1.sh

!/bin/bash

/usr/bin/curl "localhost:3000/api/v1/commands/?cmd=stop" /usr/bin/touch /data/plugins/music_service/volspotconnect2/txt.txt

balbuze commented 6 years ago

And with & between commands?

richpuch commented 6 years ago

I reinstalled previous version 0.4.6 and it works...trying to go back to 0.4.9.

richpuch commented 6 years ago

Went back to 0.4.9 and back to nothing...doesn't seem to execute the onstart1.sh file

balbuze commented 6 years ago

How do you reinstall the previous version? Because if you just use the zip it still use the same librespot. So I don't understand. I know it execute onstart1.sh because it stops volumio if a track is played when you connect and.play from spotify. But I'll have a deeper look.

richpuch commented 6 years ago

I had the copy of the old .zip, so I uploaded it and installed it that way.

Just played a track trough volumio and it played...when I went to spotify I never turned off the volumio track. I running volumio 2.295 and I see 2.348 is out...should I try the upgrade?

richpuch commented 6 years ago

Upgrading to latest version of Volumio seems to fix my problem...not sure if the upgrade or reboot that followed the upgrade fixed my problem...but it seems to be working fine.

Thanks a bunch for looking into this.

balbuze commented 6 years ago

thanks for the info! I was struggling to find what happened!

balbuze commented 6 years ago

it was working fine with different devices...

richpuch commented 6 years ago

one more question...is there a similar stop file that get executed when somebody stops playing via spotify or if a song is being played through the volumio interface? I trigger my system to tun on through home assistant via curl commands using onstart1.sh...I would like to send a notification to home assistant once the user stops playing through spotify.

balbuze commented 6 years ago

It should work if you add --onstop ./scriptwithyourcommandwhenstop.sh at the end of volspotconnect.tmpl. write your scriptwithyourcommandwhenstop.sh file, chmod +x disable and enable the plugin to take in consideration your change.

richpuch commented 6 years ago

works...got it setting a flag in home assistant.

Thanks again...great work.