shaundon / lametric-spotify

0 stars 0 forks source link

Device Option #1

Closed pmchaumien closed 3 years ago

pmchaumien commented 3 years ago

Hello Shaun

Thanks for your app, it’s great… I managed to deploy it on heroku and it works great, I receive the information from my spotify account on my LAmetric... I'm over the moon.... But can you explain me how to include the option to know which device is used... I don't understand how to do it. I don't know if it's in the index.js code or just in the Lametric application creator. can you help me?

Thanks by advance

Pierre-Marie

shaundon commented 3 years ago

Hey, that's great to hear!

On the Heroku side, the server is already set up to recognise devices, if you provide it, so you shouldn't need to edit the code at all.

On the LaMetric app creator, add a text parameter to your app that corresponds to the devices parameter:

Screen Shot 2021-02-16 at 08 52 18

Then in the LaMetric app, you should see this parameter as a text field on the settings screen. You can set it here:

IMG_B0A028E61F2C-1

(Note: It's called 'Speakers' for me as I gave the devices parameter a more user-friendly name)

Then for that field, enter a comma-separated list of devices to match. So, if you only want your LaMetric to display songs playing on "Kitchen Echo" and "Living Room Echo", you'd enter Kitchen Echo,Living Room Echo.

Hope this helps!

pmchaumien commented 3 years ago

Thanks you, i will try 💯

pmchaumien commented 3 years ago

i made some code modification before your answer

index.js

    if (nowPlaying['is_playing'] && nowPlaying.item && nowPlaying.item.name && nowPlaying.item.artists) {
        const track = nowPlaying.item.name;
        const artists = nowPlaying.item.artists.map(artist => artist.name).join(', ');
        const device = nowPlaying.device.name;
        responseText = `${track} - ${artists}`;
        if (allowedDevices && !allowedDevices.includes(nowPlaying.device.name)) {
            responseText = `${track} - ${artists} - ${device}`;
        }
    }
    console.log(responseText);

and in the lametric app i put a checkbox with devices option but now

screencapture-developer-lametric-com-applications-app-25662-1613468894998 (1)

"lametric" show all the time the active device... even more when the checkbox is on false....

I'm a newbee with javascript and i'm little lost know... in fact I want to be able to activate the option when I want to see the active device

shaundon commented 3 years ago

devices shouldn't be a checkbox, it should be a text field

pmchaumien commented 3 years ago

ok Shaun, i will try it 👍

pmchaumien commented 3 years ago

Thanks you Shaun, it's functional

shaundon commented 3 years ago

Ah that's great to hear, enjoy!