AlexanderBabel / homebridge-broadlink-rm

[This fork supports TV accessories] Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
46 stars 11 forks source link

Add delay to TV Input change #49

Closed gid204 closed 4 years ago

gid204 commented 4 years ago

Is there a way (or can functionality be added) to add a delay from turning the TV on to switching its input using a scene?

The use case is as follows: I have scene 1 which turns the tv on and sets HDM1 active and scene 2 which turns the tv on and sets HDMI 2 active. If the last used input was HDM1 and then I activate scene 2, the tv turns on and Home sees the input as HDMI2 but the tv is still on HDM1.

When watching the homebridge output it sends both commands (without delay) and so the TV doesn't acknowledge the second command (input change) as it is still turning on.

Thanks!!

gid204 commented 4 years ago

Update: I've managed to semi-reliably get around this by using conditional automations. I still think it would be a lot cleaner if some form of delay could be put in :)

kiwi-cam commented 4 years ago

Using a scene with a delay would require HomeKit to allow delays - other than posting feedback to Apple, that's out of our control. One way people achieve something similar is using a switch to send multiple IR codes. For example, turn on the TV, pause 10 seconds, then send the input select IR code:

...
        {
            "name": "Input One",
            "type": "switch",
            "data": {
                "on": [ {
                       "data": "ON_HEX_CODE_1",
                        "pause": 10
                      },
                      {
                        "data": "INPUT_HEX_CODE"
                      }],
                "off": "OFF_HEX"
            }
        },
...
gid204 commented 4 years ago

This is perfect thanks! Wasn’t aware you could break down the tv command with pauses, repeats etc like you can other accessories.

Will confirm it all works and close the case this evening.

Thanks!

kiwi-cam commented 4 years ago

No problem. If you'd like to explore more, I find the best documentation on this is from the original plugin author here: https://lprhodes.github.io/slate/#advanced-hex-structure

Good luck!

gid204 commented 4 years ago

I was very simply able to just add a pause as discussed - closing the issue. Thanks again!

gid204 commented 4 years ago

Okay I got excited, I'm still not able to resolve my issue. My config for the tv is as follows: "name":"LG TV", "type":"tv", "host":"192.168.1.7", "pingIPAddress": "192.168.1.9", "pingIPAddressStateOnly": true, "pingFrequency": 10, "pingGrace": 15, "data": { "off": "", "on":"", "remote": { "select": "", "arrowUp": "", "arrowDown": "", "arrowLeft": "", "arrowRight": "", "back": "", "playPause": "", "info": "" }, "volume": { "up": "", "down": "" }, "inputs": [ { "name": "PS4", "type": "hdmi", "data": [{ "pause": 3, "data": "" }] }, { "name": "Apple TV", "type": "hdmi", "data": [{ "pause": 3, "data": "" }] }, { "name": "HDMI 3", "type": "hdmi", "data": [{ "pause": 3, "data": "" }] }] } }, ---> more accessories

If I put the pause either in the input command (as above) or straight after the on command as you've demonstrated the pause does not take affect. If I do as your comment suggest, I.e. pause then run the input command, it works but the home app input and the actual tv input become out of sync.

Is there anyway just to implement the pause within the config between the on command and initial input change?

Cheers!

kiwi-cam commented 4 years ago

The pause config is designed to add a pause between commands, not at the start. Have you tried putting a dummy invalid hexcode at the start of the INPUT command, then the pause, followed by the valid hex code?

e.g.

{
  "name": "HDMI 3",
  "type": "hdmi",
  "data": [{
    "data": "2600000000aaaa",
    "pause": 3
  },{
    "data": "VALID_HEXCODE"
  }]
}
gid204 commented 4 years ago

Awesome this works, thanks again for your support!