Python Plugin: Spotify

Python and python framework

Moderator: leecollings

eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

Ok, now we are getting somewhere :

root@diskstation:/volume1/@appstore/domoticz/var# curl -v -L "http://127.0.0.1:8084/json.htm?type=com ... rvariables"
> GET /json.htm?type=command&param=getuservariables HTTP/1.1
> Host: 127.0.0.1:8084
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 56
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-cache
< Pragma: no-cache
< Access-Control-Allow-Origin: *
<
{
"status" : "OK",
"title" : "GetUserVariables"
}



total logging from the plug :
2018-07-05 12:31:05.642 Status: (Spotify) Started.
2018-07-05 12:31:06.024 Status: (Spotify) Entering work loop.
2018-07-05 12:31:06.024 Status: (Spotify) Initialized version 0.1, author 'djj'
2018-07-05 12:31:06.095 Error: (Spotify) Cannot read the uservariable holding the persistent variables
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

Ahh, so you have no variables at all at the moment? Try adding one manually in your domoticz. Maybe that’s causing the issue. (Should solve that in the code of that is the case...)


Verzonden vanaf mijn iPhone met Tapatalk
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

ehm ???
no idea what you mean and how to do that ...
I have 9 devices running smooth for months, no problems with them ...
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

adding a var named test with a value of 1 did the trick...
Perhaps you should modify your code to ignore uservars if there are none ...

Now I get an other error

Error: (Spotify) Error occured in request for getting acces_tokens from Spotify, error code: 400, reason: Bad Request. Seems either client_id, client_secret or code is incorred. Please note that the code received from Spotify could only be used once. Please get a new one from spotify.

let me re-initialize the codes
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

After re-init the code something is happening. I get a device, but only one ...
Screen Shot 2018-07-05 at 13.00.14.png
Screen Shot 2018-07-05 at 13.00.14.png (51.43 KiB) Viewed 6168 times
I expected more controls ???
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

Cool! I'll fix that in the code... [update]fixed in new version[/update]

For the usage, now update your user variable Spotify-searchTxt with for instance 'artist coldplay'. After the update. select on the device ebook, it should start playing spotify on this device.
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

Ok, that works ..

after adding a search string in that var I can switch between iPad and MacBook running spotify.
Some more controls would be nice but this is a start ...
It always sets the volume on the iPad 100% too

Eddie
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

Nice that it works!

Good feature requests :-)
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python Plugin: Spotify

Post by eddieb »

like
volume controls
display playing track
search from control
;-)

no hurry
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

eddieb wrote: Thursday 05 July 2018 15:15 like
volume controls
display playing track
search from control
;-)

no hurry
I did think about this... however i don't really see the use case for this. Real control of spotify I would always do via my spotify app. I'll will never go to my domoticz to do this.
Use case that i see, is that you enter home, wake up... you can start your favorite tune. Or in my case, i have a google home, were i will say what i would like to listen, via IFTTT it will update my user variable, en press play and it will play the tune on my receiver. (by default google home only allows Spotify playback on the google home device :? )
dlefol
Posts: 35
Joined: Monday 21 December 2015 16:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by dlefol »

Hi,

Thanks a lot for the plugin. I tested it yesterday and it works fine.
I have a similar use case as yours but a bit different:

I want to be able to launch automatically some of my playlists using scenes (for instance to have background music when I activate the scene "cooking" which triggers other things too).

I also want to use it as a simple spotify control for my kids so they can play music without giving them access to the phone/tablet. I'm planning to use the Xiaomi smart cube for that: shake would start spotify, rotate clockwise / anti clockwise would change the volume (I can control my sound system directly for that so not via spotify).

The controls I haven't figured out how to do yet are:
- skip to next / previous songs (for the kids who like to repeat the same song over and over again, a movement of the cube could allow that)
- Shuffle mode on / off for playlist

Thanks again for this plugin.
dlefol
Posts: 35
Joined: Monday 21 December 2015 16:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by dlefol »

Hello,

As I said in my previous post, I tested the plugin on my test machine and all worked fine. When I try to do the same on my production server, I have a problem unfortunatelly. As soon as the spotify hardware is activated my whole domoticz hangs up. No more response of the web interface at all.
I am obliged to restart the service and quickly deactivate the hardware to restore a running domoticz. I tried several times and it s really the activation of the hardware linked to the spotify plugin which causes the problem.

I have nothing in the log except the line saying Status (Spotify) Started and the one saying " Status: PluginSystem: Entering work loop".

Idon't know what to do to help solve this issue. I can test different things if you want but don't know which way to go...
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

Aiii, i honestly have no clue...

What kind of system is your test vs your production? What version of domoticz? OS running? python version?
Did you turn on the debug of the plugin? As it doesnt spit out any logging, which i find odd... as i understand from the plugin framework, It would first start with executing the code in the start command, that should spit out some logging already. After that it will go into the loop, looping every 30 seconds and running the heartbeat code.
dlefol
Posts: 35
Joined: Monday 21 December 2015 16:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by dlefol »

Hello again,

I had the time to investigate a bit more and the problem had nothing to do with the spotify plugin itself but was a more general issue with python plugins on my production machine. I updated the image of my RPi to stretch (production was still in jessie) and updated domoticz to the latest beta and it works now on my production as well.

Thanks
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by corederoma82 »

I'm sorry,
the "readme" of plugin says:

- Create a client ID at spotify (https://developer.spotify.com/dashboard/applications)
- Enter all fields as desired
- Enter IP address on which domoticz can be reached (but where is this field, in the plugin settings in domoticz)??????


Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

Yes, in domoticz hardware setting indeed..
I can understand why the readme is confusing here, i've updated it.
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by corederoma82 »

Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
User avatar
capman
Posts: 153
Joined: Friday 12 July 2013 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Python Plugin: Spotify

Post by capman »

I have done all the setup parameters and no error is in the log. But I don't know
what you mean with "Update user variable [name]-searchTxt" ? Is this something I should do in
domoticz ? Creating a variable for searching ?
Please explain what to do and where. Thanks
bartbosch
Posts: 1
Joined: Sunday 14 October 2018 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by bartbosch »

Hi,

I have been able to find everything, but not my code

Code: copy the code received from the spotify redirect in the query parameters
Image

is there anyone who can help me with this problem?


My error in the log:
Spoiler: show
2018-10-28 23:13:09.674 Error: (Spotify) Error occured in request for getting acces_tokens from Spotify, error code: 400, reason: Bad Request. Seems either client_id, client_secret or code is incorrect. Please note that the code received from Spotify could only be used once. Please get a new one from spotify.
Sjaakios
Posts: 37
Joined: Saturday 04 June 2016 23:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Spotify

Post by Sjaakios »

capman wrote: Friday 05 October 2018 12:49 I have done all the setup parameters and no error is in the log. But I don't know
what you mean with "Update user variable [name]-searchTxt" ? Is this something I should do in
domoticz ? Creating a variable for searching ?
Please explain what to do and where. Thanks
The plugin created a uservariable in domoticz, you can find this under setup -> more options -> user variables
Update the variable named ....-searchTxt with something like 'artist coldplay'
Next in your devices tab, select the device on which playback needs to be started. If all goes well it will play the top tracks by coldplay
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest