ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
145 stars 14 forks source link

Television input source selection not working #109

Closed jameswestcott closed 3 years ago

jameswestcott commented 3 years ago

I'm trying to set up the Television accessory and am having issues selecting the Input Source in the Home app.

When "Cmd4_Mode" is set to Polled, input sources are listed in identifier order and everything works as expected. However, when "Cmd4_Mode" is set to Always, the input sources are now listed in alphabetical order and when selecting an input source nothing happens. There's no log entry to say the action has been selected. The only log entry that appears is if the device is inactive, it'll make the device active.

(As a side note, sending the commands to make the device active and selecting the input source at the same time happen in quick succession and my surround processor can't handle both commands simultaneously! I can probably script around that specific issue).

{ "platform": "Cmd4", "name": "Cmd4", "allowTLV8": false, "outputConstants": false, "restartRecover": true, "Cmd4_Mode": "Always", "accessories": [ { "Type": "Television", "DisplayName": "AnthemAmp", "ConfiguredName": "AnthemAmp", "PublishExternally": true, "Category": "TELEVISION", "Active": "INACTIVE", "ActiveIdentifier": 1, "SleepDiscoveryMode": "ALWAYS_DISCOVERABLE", "RemoteKey": "SELECT", "LinkedTypes": [ { "Type": "InputSource", "Identifier": 3, "DisplayName": "WatchAppleTV", "ConfiguredName": "WatchAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 7, "DisplayName": "WatchChromecast", "ConfiguredName": "WatchChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 1, "DisplayName": "WatchSky", "ConfiguredName": "WatchSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 5, "DisplayName": "WatchMediaPlayer", "ConfiguredName": "WatchMediaPlayer", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 6, "DisplayName": "WatchTV", "ConfiguredName": "WatchTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 9, "DisplayName": "ListenRoon", "ConfiguredName": "ListenRoon", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 4, "DisplayName": "ListenAppleTV", "ConfiguredName": "ListenAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 8, "DisplayName": "ListenChromecast", "ConfiguredName": "ListenChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 2, "DisplayName": "ListenSky", "ConfiguredName": "ListenSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" } ], "Manufacturer": "cmd4", "Model": "Television", "SerialNumber": "00001", "StateChangeResponseTime": 3, "State_cmd": "node C:\Users\james\.homebridge\instance5\cmd4\television1.js", "polling": [ { "Characteristic": "Active", "Interval": 600, "Timeout": 5000 }, { "Characteristic": "ActiveIdentifier", "Interval": 600, "Timeout": 5000 } ] }

ztalbot2000 commented 3 years ago

Hi James,

Queries to the device at the same time are not my responsibility, though I have been working on a solution for someone else who has multiple accessories that are actually the same device. It is a long way off though. I don't know what your script looks like, but if you use curl for instance, it has retries, back off, etc.

As for "Always", your script would have to respond for every characteristic in your config.json and it probably does not. As "Polled" all the characteristics are retrieved from cache ( except those polled) so this is why things work. Your script does not have to do anything except respond to Active and ActiveIdentifier of the TV. There is also less congestion, being that most characteristics only need getting once and interferes with your first issue of many queries to the device at the same time.

I certainly never paid attention to the order. Most likely though if you are set to always and your script does not handle every characteristic, it is possible IOS does not sort the unresponsive Input Sources. There is no sorting in Cmd4. Everything is processed top to bottom.

So I don't think there is any issues here. Hopefully I responded to all your concerns.

Take care, John Talbot

On Mon, Apr 19, 2021 at 3:17 PM jameswestcott @.***> wrote:

I'm trying to set up the Television accessory and am having issues selecting the Input Source in the Home app.

When "Cmd4_Mode" is set to Polled, input sources are listed in identifier order and everything works as expected. However, when "Cmd4_Mode" is set to Always, the input sources are now listed in alphabetical order and when selecting an input source nothing happens. There's no log entry to say the action has been selected. The only log entry that appears is if the device is inactive, it'll make the device active.

(As a side note, sending the commands to make the device active and selecting the input source at the same time happen in quick succession and my surround processor can't handle both commands simultaneously! I can probably script around that specific issue).

{ "platform": "Cmd4", "name": "Cmd4", "allowTLV8": false, "outputConstants": false, "restartRecover": true, "Cmd4_Mode": "Always", "accessories": [ { "Type": "Television", "DisplayName": "AnthemAmp", "ConfiguredName": "AnthemAmp", "PublishExternally": true, "Category": "TELEVISION", "Active": "INACTIVE", "ActiveIdentifier": 1, "SleepDiscoveryMode": "ALWAYS_DISCOVERABLE", "RemoteKey": "SELECT", "LinkedTypes": [ { "Type": "InputSource", "Identifier": 3, "DisplayName": "WatchAppleTV", "ConfiguredName": "WatchAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 7, "DisplayName": "WatchChromecast", "ConfiguredName": "WatchChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 1, "DisplayName": "WatchSky", "ConfiguredName": "WatchSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 5, "DisplayName": "WatchMediaPlayer", "ConfiguredName": "WatchMediaPlayer", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 6, "DisplayName": "WatchTV", "ConfiguredName": "WatchTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 9, "DisplayName": "ListenRoon", "ConfiguredName": "ListenRoon", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 4, "DisplayName": "ListenAppleTV", "ConfiguredName": "ListenAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 8, "DisplayName": "ListenChromecast", "ConfiguredName": "ListenChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 2, "DisplayName": "ListenSky", "ConfiguredName": "ListenSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" } ], "Manufacturer": "cmd4", "Model": "Television", "SerialNumber": "00001", "StateChangeResponseTime": 3, "State_cmd": "node C:\Users\james.homebridge\instance5\cmd4\television1.js", "polling": [ { "Characteristic": "Active", "Interval": 600, "Timeout": 5000 }, { "Characteristic": "ActiveIdentifier", "Interval": 600, "Timeout": 5000 } ] }

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX5ACZKA62VIXBAEWILTJR6UBANCNFSM43GPVOVQ .

jameswestcott commented 3 years ago

Thanks for the tips John. It turns out I’d put a placeholder script in for Get Identifier and so it was returning the same ID for all inputs! That completely confused HomeKit.

From: John Talbot @.> Date: Monday, 19 April 2021 at 22:26 To: ztalbot2000/homebridge-cmd4 @.> Cc: jameswestcott @.>, State change @.> Subject: Re: [ztalbot2000/homebridge-cmd4] Television input source selection not working (#109) Hi James,

Queries to the device at the same time are not my responsibility, though I have been working on a solution for someone else who has multiple accessories that are actually the same device. It is a long way off though. I don't know what your script looks like, but if you use curl for instance, it has retries, back off, etc.

As for "Always", your script would have to respond for every characteristic in your config.json and it probably does not. As "Polled" all the characteristics are retrieved from cache ( except those polled) so this is why things work. Your script does not have to do anything except respond to Active and ActiveIdentifier of the TV. There is also less congestion, being that most characteristics only need getting once and interferes with your first issue of many queries to the device at the same time.

I certainly never paid attention to the order. Most likely though if you are set to always and your script does not handle every characteristic, it is possible IOS does not sort the unresponsive Input Sources. There is no sorting in Cmd4. Everything is processed top to bottom.

So I don't think there is any issues here. Hopefully I responded to all your concerns.

Take care, John Talbot

On Mon, Apr 19, 2021 at 3:17 PM jameswestcott @.***> wrote:

I'm trying to set up the Television accessory and am having issues selecting the Input Source in the Home app.

When "Cmd4_Mode" is set to Polled, input sources are listed in identifier order and everything works as expected. However, when "Cmd4_Mode" is set to Always, the input sources are now listed in alphabetical order and when selecting an input source nothing happens. There's no log entry to say the action has been selected. The only log entry that appears is if the device is inactive, it'll make the device active.

(As a side note, sending the commands to make the device active and selecting the input source at the same time happen in quick succession and my surround processor can't handle both commands simultaneously! I can probably script around that specific issue).

{ "platform": "Cmd4", "name": "Cmd4", "allowTLV8": false, "outputConstants": false, "restartRecover": true, "Cmd4_Mode": "Always", "accessories": [ { "Type": "Television", "DisplayName": "AnthemAmp", "ConfiguredName": "AnthemAmp", "PublishExternally": true, "Category": "TELEVISION", "Active": "INACTIVE", "ActiveIdentifier": 1, "SleepDiscoveryMode": "ALWAYS_DISCOVERABLE", "RemoteKey": "SELECT", "LinkedTypes": [ { "Type": "InputSource", "Identifier": 3, "DisplayName": "WatchAppleTV", "ConfiguredName": "WatchAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 7, "DisplayName": "WatchChromecast", "ConfiguredName": "WatchChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 1, "DisplayName": "WatchSky", "ConfiguredName": "WatchSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 5, "DisplayName": "WatchMediaPlayer", "ConfiguredName": "WatchMediaPlayer", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 6, "DisplayName": "WatchTV", "ConfiguredName": "WatchTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 9, "DisplayName": "ListenRoon", "ConfiguredName": "ListenRoon", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 4, "DisplayName": "ListenAppleTV", "ConfiguredName": "ListenAppleTV", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 8, "DisplayName": "ListenChromecast", "ConfiguredName": "ListenChromecast", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" }, { "Type": "InputSource", "Identifier": 2, "DisplayName": "ListenSky", "ConfiguredName": "ListenSky", "CurrentVisibilityState": "SHOWN", "InputSourceType": "HDMI", "IsConfigured": "CONFIGURED" } ], "Manufacturer": "cmd4", "Model": "Television", "SerialNumber": "00001", "StateChangeResponseTime": 3, "State_cmd": "node C:\Users\james.homebridge\instance5\cmd4\television1.js", "polling": [ { "Characteristic": "Active", "Interval": 600, "Timeout": 5000 }, { "Characteristic": "ActiveIdentifier", "Interval": 600, "Timeout": 5000 } ] }

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX5ACZKA62VIXBAEWILTJR6UBANCNFSM43GPVOVQ .

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/ztalbot2000/homebridge-cmd4/issues/109#issuecomment-822796481, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMCLF5SBMPWARFNBDSOSUATTJSNZLANCNFSM43GPVOVQ.