AdamSwinden / homebridge-sky-q

Homebridge plugin to turn on/off a Sky Q box.
MIT License
8 stars 5 forks source link

State awareness #1

Open jb-manchester opened 6 years ago

jb-manchester commented 6 years ago

Plugin works well but HomeKit is unaware when the Sky Q box is switched on/off via the normal remote (i.e. will report off when on or vice versa).

Would it be possible to add in this power state awareness? Maybe via something like this: https://www.npmjs.com/package/sky-q

Thanks.

betty02 commented 6 years ago

Installed this yesterday, works great from Siri, and I used it with Alexa so I tend not to look at my HomeKit app, but when I did it was showing as off etc, really think the state awareness would be really really good on this!

jdebardi commented 6 years ago

I have added state awareness using the mentioned package in my fork of this project and created a PR. Hopefully the original author will merge it ASAP :)

danbridgland commented 5 years ago

Any progress with this?

When I set up command to change channel, such as; { "accessory" : "SkyQ", "ipAddress" : "192.168.7.27", "name" : "Sky News", "cmd" : "backup,backup,backup,5,0,1" },

to launch Sky News on Sky Q Silver, if the box is already powered on, the switch always turns the Sky box off, if the box is off, the switch runs the box on, but only to launch’s to the guide.

Any idea how to fix this?

jdebardi commented 5 years ago

State awareness is only implemented when using the power command, not for other command strings.

The solution is to send sky,backup,5,0,1 Then regardless of on or off the box will turn on and then go to the channel.

When sending non power commands the switch is designed to switch off as soon as the command is sent. As command strings have no state it made sense to just flick the switch back to off immediately.

jdebardi commented 5 years ago

Actually looks like I did enable state awareness on command strings. You need autoOn enabled in your config for it to work. See the ReadMe. Regardless I still recommend using sky,backup to ensure a top level start.

danbridgland commented 5 years ago

@jdebardi, Thanks for responding,

I’ve now changed to: { "accessory" : "SkyQ", "name" : "Sky News", "ipAddress" : "192.168.7.27", "autoOn" : true, "delayed" : true, "cmd" : "sky,backup,5,0,1" }

Yet, still, it switches off the Sky Q box when it’s already running. When the Sky Q box isn’t already running, the box is turned on, but that’s it, no channel changing command is sent.

jdebardi commented 5 years ago

You don’t need delayed, that is probably breaking it (or you are not waiting long enough what with the delay!)

danbridgland commented 5 years ago

When I remove the delay, it makes no difference.

Is there an option to extend the delay? Is there an option to prevent the box turning off?

It would be useful to separate the power characteristic from the channel changing command, is this possible?

jdebardi commented 5 years ago

The delay is specifically for a Samsung bug (read the readme).

Try adding more backups to the command.

danbridgland commented 5 years ago

@jdebardi, Thanks for your continued help.

I’ve now tried the following, { "ipAddress" : "192.168.7.27", "accessory" : "SkyQ", "autoOn" : false, "delayed" : false, "name" : "Sky News", "cmd" : "sky,backup,backup,backup,backup,backup,backup,backup,backup,backup,backup,5,0,1" }

This has resulted in exactly the same behaviour. The Sky Box turns off every time, no matter what combination of autoOn, delayed and cmd.

Is it possible to separate the power on/off function from the command?

jdebardi commented 5 years ago

If you don’t put a cmd in then it will just be a power switch. So you could have 2 switches, 1 for power and 1 for cmd.

I’ll have a play later and see if I can reproduce your issue.

danbridgland commented 5 years ago

From my experience, it seems the power state is triggered every time. If the box is already on, the power will be switched off. If the box is off, the power will be switched on, and no further action is purformed. In both cases this is true regardless of the autoOn setting being true or false.

Please let me know if you’re able to reproduce. Thanks, Dan

jdebardi commented 5 years ago

If you create a switch with no cmd, no autoOn, no delay, (killing the home app on your phone in between to force a refresh) does it’s on/off state follow the box actual state. I mean turn the box on/off with the normal remote and see if the switch detects it’s correct status.

danbridgland commented 5 years ago

Unfortunately not. The switch seems to have no state awareness.

danbridgland commented 5 years ago

This is the config: { "name" : "Sky Q", "ipAddress" : "192.168.7.27", "accessory" : "SkyQ" },

jdebardi commented 5 years ago

Can you go to http://192.168.7.27:9006/as/system/information You should get a load of info back including this line; "activeStandby" : true, (may say false depending on box state)

Or better, run curl http://192.168.7.27:9006/as/system/information in a terminal session on the system you are running homebridge on.

Can you also confirm your Sky Q software version. I'm wondering if there is an update that breaks the system info lookup and my Sky Q boxes don't have it yet.

I just tested mine on my Silver and Mini and state awareness works fine (I know it has been very recently as well as I have automation's depending on them at night to keep the lights on in a given room if the TV is still on).

danbridgland commented 5 years ago

When I follow the link or curl, I get the same result, I guess that’s expected.

The activeStandby state shows false. The box is currently on and playing content.

I’m running Sky Q firmware version 080.000.75.00L, I believe this is the latest firmware which added support for Netflix. See https://skyepginfo.co.uk/Firmware/SkyQ.php

jdebardi commented 5 years ago

The fact you get a result means it should work. I am on the same version.

I don’t get why it wouldn’t work then, especially as the curl works.

Can you post the homebridge logs. The plugin should print the status it finds. If you tail the log real-time and then describe what happens (basically when you open the home app it should instantly print in the log the box status with no delay).

danbridgland commented 5 years ago

The behaviour is unchanged. Always switches the power from whichever state it’s currently in.

System Log [2019-1-5 21:42:10] [Sky Q] Sending on command to 'Sky Q'...

Error Log Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.63] Muting event '16.10' notification for this connection since it originated here. Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.67] Sending HTTP event '16.10' with data: {"characteristics":[{"aid":16,"iid":10,"value":true}]} Sat, 05 Jan 2019 21:42:10 GMT Accessory [Homebridge] Setting Characteristic "On" to value 1 Sat, 05 Jan 2019 21:42:10 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":16,"iid":10,"value":1}] Sat, 05 Jan 2019 21:42:10 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: PUT /characteristics Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Sat, 05 Jan 2019 21:42:10 GMT Accessory [Homebridge] Got Characteristic "On" value: false Sat, 05 Jan 2019 21:42:10 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 21:42:10 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: GET /characteristics?id=16.10 Sat, 05 Jan 2019 21:42:10 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics?id=16.10 Sat, 05 Jan 2019 21:42:09 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Sat, 05 Jan 2019 21:42:09 GMT Accessory [Homebridge] Got Characteristic "On" value: false Sat, 05 Jan 2019 21:42:09 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 21:42:09 GMT Accessory [Homebridge] Got Characteristic "On" value: false Sat, 05 Jan 2019 21:42:09 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 21:42:09 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: GET /characteristics?id=16.10,15.10 Sat, 05 Jan 2019 21:42:09 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics?id=16.10,15.10

jdebardi commented 5 years ago

Can you get a log as you open the home app on the phone (having previously killed it).

I don’t see it reporting the current state anywhere.

Either that or ask Siri the status of SkyQ so it queries it real-time.

danbridgland commented 5 years ago

With the Sky Q box on, when I asked Siri for the status of Sky Q, I was told it was on. In then turned the sky box off with the sky remote and repeated the question to Siri. I was then given the same response. Your Sky Q is On.

The log follows. Though I don’t know if these relate to Sky or the other accessories.

Sat, 05 Jan 2019 22:23:01 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Sat, 05 Jan 2019 22:23:01 GMT Accessory [Homebridge] Got Characteristic "On" value: false Sat, 05 Jan 2019 22:23:01 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 22:23:01 GMT Accessory [Homebridge] Got Characteristic "On" value: true Sat, 05 Jan 2019 22:23:01 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 22:23:01 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: GET /characteristics?id=16.10,15.10 Sat, 05 Jan 2019 22:23:01 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics?id=16.10,15.10 Sat, 05 Jan 2019 22:22:54 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Sat, 05 Jan 2019 22:22:54 GMT Accessory [Homebridge] Got Characteristic "On" value: false Sat, 05 Jan 2019 22:22:54 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 22:22:54 GMT Accessory [Homebridge] Got Characteristic "On" value: true Sat, 05 Jan 2019 22:22:54 GMT Accessory [Homebridge] Getting value for Characteristic "On" Sat, 05 Jan 2019 22:22:54 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: GET /characteristics?id=16.10,15.10 Sat, 05 Jan 2019 22:22:54 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics?id=16.10,15.10

danbridgland commented 5 years ago

What setting do you have for Sky Q Preferences > Standby Mode? I have it set to Eco.

jdebardi commented 5 years ago

I tried my standby mode in all settings and it always works.

Can you find your node_modules directory and manually compare the homebridge-sky-q/index.js with that of this repo. I'm wondering if you are even running the latest codeline.

danbridgland commented 5 years ago

It’s the same version. I can just as easily remove and reinstall.

Do I need to install the sky-remote package separately, it’s listed as a dependency?

jdebardi commented 5 years ago

If you use npm it should handle all dependencies for you

danbridgland commented 5 years ago

Yes, I use npm. I’ll uninstall and reinstall, report back in a few minutes.

danbridgland commented 5 years ago

Uninstalled, reinstalled, exactly the same result.

jdebardi commented 5 years ago

Not sure what else to suggest I’m afraid!

danbridgland commented 5 years ago

Anyway to add a verbose logger to capture the command sent?

danbridgland commented 5 years ago

I’ve removed all other HomeBridge accessories and platforms. The only accessory is Sky-Q

{ "accessories" : [ { "accessory" : "SkyQ", "ipAddress" : "192.168.7.27", "name" : "Sky Q", "cmd" : "sky,backup,5,0,1" } ], "bridge" : { "username" : "CD:22:3D:E3:CE:64", "name" : "Homebridge", "pin" : "031-45-637", "port" : 51826 }, "platforms" : [ ] }

The log of the action to invoke Siri and Turn On Sky Q returned this:

Mon, 07 Jan 2019 23:58:40 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP Response is finished Mon, 07 Jan 2019 23:58:40 GMT EventedHTTPServer [::ffff:192.168.7.67] Sending HTTP event '16.10' with data: {"characteristics":[{"aid":16,"iid":10,"value":true}]} Mon, 07 Jan 2019 23:58:40 GMT EventedHTTPServer [::ffff:192.168.7.63] Muting event '16.10' notification for this connection since it originated here. Mon, 07 Jan 2019 23:58:40 GMT Accessory [Homebridge] Setting Characteristic "On" to value true Mon, 07 Jan 2019 23:58:40 GMT Accessory [Homebridge] Processing characteristic set: [{"aid":16,"iid":10,"value":true}] Mon, 07 Jan 2019 23:58:40 GMT HAPServer [CD:22:3D:E3:CE:64] HAP Request: PUT /characteristics Mon, 07 Jan 2019 23:58:40 GMT EventedHTTPServer [::ffff:192.168.7.63] HTTP request: /characteristics

The result is the same as always. The box turns off when on. Or turns on when off, no further commands are performed.

danbridgland commented 5 years ago

I’ve finally figured out the problem. But I’ve no idea how to fix it.

The package version which installs from the command ‘sudo npm install -g homebridge-sky-q‘ is v0.0.3. However, that package does not have the same index.js as shown on https://github.com/AdamSwinden/homebridge-sky-q/blob/master/index.js

How do I install the master package?

jdebardi commented 5 years ago

The proper fix is for @AdamSwinden to update the release.

For now if you just overwrite the contents of your index.js manually it’ll fix it. That’s what I was asking a few messages back - find your node_modules folder.

danbridgland commented 5 years ago

Thanks, sorry it took me a while to get there, as I’m doing this entirely through the iOS app ‘HomeBridge’, not so easy to navigate around.

jdebardi commented 5 years ago

Wow! I didn’t even know an app existed? Got a link? What have you installed homebridge on?

danbridgland commented 5 years ago

Homebridge for RaspberryPi by Niklas von Weihe https://itunes.apple.com/gb/app/homebridge-for-raspberrypi/id1123183713?mt=8

It’s not perfect, but it’s adequate if you have even the slightest idea what you’re doing.

Running a Pi2B1.1