ndg63276 / alexa-sky-hd

A smart home skill for Alexa to control a Sky+HD or SkyQ box
33 stars 15 forks source link

Controlling Sky Q features like opening apps and UI shortcuts #2

Closed rosstilley closed 5 years ago

rosstilley commented 5 years ago

First off, great app!

It’d be good if there was a way of including controls that make use of Sky Q’s features. Opening specific apps like Netflix for example, or jumping straight to your recordings.

Does anyone know if it’s possible to send these commands using Q’s IP controls?

It must be possible in some form because you can use Sky’s voice controls to jump to these areas.

Does anyone know or know if there’s a way to find out?

R

ndg63276 commented 5 years ago

If you have been able to set up the skill, you might be able to help me find out if that is possible. Basically I send a number to your sky box, and each number corresponds to a button on the remote. For example, a zero is the power button. It is possible that the Netflix button has a number, but I can't find out as I don't have a Sky Q box.

If you go to https://repl.it/@ndg63276/SkyQTester, and press Run at the top, the right hand window will ask you for your dynamic dns server, and then your port number, as you would have set up for the Alexa skill. If they connect ok, it will then try to send various numbers to your sky box, so we can see what that does. It will ask if you are ready between each one, just type no if you want to stop. Make sure your Sky box is on and showing a channel between each one, so you can see what each number does.

For now, it will loop through the codes I already know, so you can tell me if any of them start the Netflix app. It probably won't. We can try other codes after that.

Let me know how you get on.

rosstilley commented 5 years ago

Cheers for the reply. No problem with helping you investigate.

Because I'm using Sky Q Hub, I'm not able to redirect to an alternative port - something I'll need to look into long term - for now I'm forwarding 49160 to my main Q box with a DNS service.

So am I right in thinking the way of doing this is to alter the code in the tester to include additional codes, like this?

commands = { "Testing20": 20, "Testing21": 21, "Testing22": 22, "Testing23": 23, "Testing24": 24, "Testing25": 25, "Testing26": 26, "Testing27": 27, "Testing28": 28, "Testing29": 29, "Testing30": 30,

Do you know how far they're likely to go up to? Hundreds or thousands?

R

ndg63276 commented 5 years ago

Ok, no problem with the port forwarding.

If you look at line 140 of the tester, it currently says try_commands(hostname, portno), which will try the known commands, eg Power, Channel Up etc.

If you change that to try_other_commands(hostname, portno), it will try other codes up to 300. When I run it on my SkyHD box, nothing happens at all. So it will be interesting to see if any of them do anything on a SkyQ box.

No idea how high they might go, if you want to try higher than 300, then edit line 105 from for code in range(0,300): to for code in range(300,1000): etc.

rosstilley commented 5 years ago

Perfect, will try that out tonight.

rosstilley commented 5 years ago

Spent a bit of time playing with this but was getting the same command being issued to the box.

For each of the 'other commands' it was bringing up the Recordings menu. Constantly.

I tried to dismiss the guide and go back to live TV, to see if that gave a different response... but no. It just kept opening the same page through all 300 codes. Strange.

I'm going to try again tonight with the Q Mini... but I think I was doing everything else right.

R

ndg63276 commented 5 years ago

Sorry, that's my fault, there was a bug in the tester code. I've updated and simplified https://repl.it/@ndg63276/SkyQTester a bit, hopefully it works but I can't test right now.

rosstilley commented 5 years ago

No worries. Tried again last night and faired a bit better.

Unfortunately the only additional command that appeared to trigger any activity was an option to set up the bluetooth remote control.

After I hit 300, I tried to up the numbers but it started to throw up python errors for using a range.

Is it possible for them to issue commands past 300?

R

ndg63276 commented 5 years ago

It is possible, but given they seemto be based on ASCII codes, they probably stop at 255.

The other thing to try, is there a combination of commands that will always get to the Netflix page? For example, to turn on subtitles, I send the "help" button, followed by "down", "right" and "select". So if there's another way into Netflix, let me know.

rosstilley commented 5 years ago

Hey, yeah I guess sending sequences might be the best alternative to having direct commands - especially if you can send them faster than inputting them from a remote.

Here are all the sequences I think would be useful;

Open Netflix Home, Right, Down, Down, Down, Down, Down, OK

Open Spotify Home, Right, Down, Down, Down, Down, Down, Right, OK

Open YouTube Home, Right, Down, Down, Down, Down, Down, Right, Right, OK

Open VEVO Home, Right, Down, Down, Down, Down, Down, Right, Right, Right, OK

Open Red Bull TV Home, Right, Down, Down, Down, Down, Down, Right, Right, Right, Right, OK

Open Sky News Sidebar, OK

Open Sky Sports Sidebar, Down, OK

Open My Photos Sidebar, Down, Down, OK

Open Weather Sidebar, Down, Down, Down, OK

Show Help Sidebar, Down, Down, Down, Down, OK

Open Catch Up TV Home, Down, Down, Down, Right

Open iPlayer Home, Down, Down, Down, Right, Down, Right

Open ITV Hub Home, Down, Down, Down, Right, Down, Down, Right

Open All4 Home, Down, Down, Down, Right, Down, Down, Down, Right

Open 5 On Demand Home, Down, Down, Down, Right, Down, Down, Down, Down, Right

Open Sky Channels Catch Up Home, Down, Down, Down, Right, Down, Down, Down, Down, Down, Right

Open All Channels Catch Up Home, Down, Down, Down, Right, Down, Down, Down, Down, Down, Down, Right

Open Ultimate On Demand Home, Down, Down, Down, Down, Right

Open Sky Box Sets Home, Down, Down, Down, Down, Down, Right

Open Netflix Guide Home, Down, Down, Down, Down, Right, Down, Down, Right

Open Ultra HD On Demand Home, Down, Down, Down, Down, Right, Down, Down, Down, Down, Down, Right

Open Sky Cinema Home, Down, Down, Down, Down, Down, Right

Open Sky Store Home, Down, Down, Down, Down, Down, Down, Right

Open Sports Guide Home, Down, Down, Down, Down, Down, Down, Down, Right

Open Kids Guide Home, Down, Down, Down, Down, Down, Down, Down, Down, Right

Open Music Guide Home, Down, Down, Down, Down, Down, Down, Down, Down, Down, Right

Open Online Video Home, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Right

Open Settings Home, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Right

Open Manual Tuning Home, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Right, Down, Down, Down, Down, Right

Open My Account Home, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Down, Right, OK

Open New Series Home, Down, Right,Up, Up, Right

Open Manage Recordings Home, Down, Down, Right, Down, Down, Down, Down, Down, Down, Right

R

ndg63276 commented 5 years ago

Ok, that's a lot of possibilities! I've just done one for Netflix, let's see if it works before I do any more.

  1. Go to https://eu-west-1.console.aws.amazon.com/lambda/home?region=eu-west-1#/functions, and log in.
  2. Go to the Sky Box function, whatever you called it.
  3. About half way down there should be a file editor, hopefully with lambda_function.py open.
  4. Replace all the code in there with this file: https://raw.githubusercontent.com/ndg63276/alexa-sky-hd/master/lambda_function.py
  5. Click Save at the top right
  6. In the Alexa app, press the bottom right icon, for smart home stuff. Scroll the top panel to the right until you find Scenes, then push Discover Scenes. It should find a new one called Netflix.
  7. Say "Alexa, turn on Netflix". Let me know what happens!

The SkyHD remote doesn't have Home or OK buttons, so I've replaced them with TV Guide and Select, which I think will do the same thing, but let me know.

rosstilley commented 5 years ago

haha fair point!

Unfortunately it doesn't look like it's working as it should.

The speed is great - definitely a useable solution - but it looks like the 'right' command isn't being sent?

https://www.dropbox.com/s/lofiptx194lyoit/IMG_0810.TRIM.mp4?dl=0

I've added an additional 'right' to the commands, see what that does. Will report back. R

ndg63276 commented 5 years ago

My theory would be the 'right' is sent a little too fast for the system, so I've added a sleep command, that just waits for 1 second. You can try that with steps 1-5 above. Let me know how you get on.

rosstilley commented 5 years ago

No worries, I'll check tonight.

It might be worth adding in a sleep command for pressing 'select' too - it doesn't look like that registered either.

rosstilley commented 5 years ago

Bingo! Just a few tweaks to the code though, only one sleep required.

elif endpointId == "skyq-netflix": if request_name == "Activate": commands.append('tvguide') commands.append('sleep') commands.append('right') commands.append('down') commands.append('down') commands.append('down') commands.append('down') commands.append('down') commands.append('down') commands.append('select') name = "ActivationStarted" if request_name == "Deactivate": commands.append('sky') name = "DeactivationStarted"

ndg63276 commented 5 years ago

Awesome. I've updated the lambda_function.py, and added Spotify and YouTube as well. Let me know if any others are high priority.

Should probably update the zip file as well...

timj79 commented 5 years ago

Hi, thanks for your great work on this. It’s mostly working for me but having a few issues with the Netflix scene. Worked the first time but seems to keep going to on demand or the TV guide now for me.

I was also wondering is there a way to navigate the menus by voice? When I power on my box it starts on the home menu and won’t accept voice commands until I press back on the remote.

Would be really handy to have a scene for recordings as well

ndg63276 commented 5 years ago

I don't have a Sky Q box, so you'll have to give me more info.

The button presses for Netflix are: Home, Right, Down x5, OK. What are the button press sequences you are seeing instead?

There is no way to navigate the menu by voice.

timj79 commented 5 years ago

Ah ok thanks, that’s what the problem is then, at the moment that command leads to the ultimate Xmas collection. Netflix is home, right, down x 4, ok. There’s another way to access Netflix, which might be less likely to change. Home, down x 10, right, ok

timj79 commented 5 years ago

Is it possible to make scenes with just the back button and just the select button? I’d then be able to turn on by voice use the back scene to then close the home screen and then choose the channel, would cut out the need for the remote when turning on. Also if you are watching on demand, nothing works until back is pressed so would be really handy here as well. On Netflix I need to push ok to get past the profile and actually start watching the first show. Don’t know if this is possible but just throwing some ideas out there.

timj79 commented 5 years ago

Just figured out I can say alexa 'stop' to back out of the guide at power on. My epg seems to randomly change the layout. Home, right x5, ok is correct again now. I've modified the code for home, down x 10, right, ok but cant get it to work

ndg63276 commented 5 years ago

I don't think I'm going to be able to help much more, at least until I get a SkyQ box.

If you create a fork of my code and modify that, then I can check it for general errors, and you and @rosstilley can help each other as well.