jbree / homebridge-cec-accessory

Homebridge support for CEC devices over HDMI
MIT License
19 stars 6 forks source link

The same (1st one) response is reused for all configured accessories #14

Open cleanbit opened 6 years ago

cleanbit commented 6 years ago

Hi,

It seems that plugin sends only one request, when there are more than one CEC device configured, but reuses the same response for all devices. Thus the status in HomeKit will be reflected incorrectly.

I've added some logging to node module: Did Send Command and Did Receive Packet are the most interesting parts in the logs below. There will be only one Did Send Command but four Did Receive Packet outputs. As you can see, that only one request was sent and then it's response was reused for all devices.

Both PS3 and PS4 were turned off. Both Apple TV and TV were turned on.

Accessories:

  "accessories": [
    {
      "accessory": "cec",
      "name": "TV Power",
      "type": "power",
      "address": 0
    },
    {
      "accessory": "cec",
      "name": "Apple TV Power",
      "type": "power",
      "address": 4
    },
    {
      "accessory": "cec",
      "name": "PS3 Power",
      "type": "power",
      "address": 13
    },
    {
      "accessory": "cec",
      "name": "PS4 Power",
      "type": "power",
      "address": 8
    }
  ]

1st try:

Jan 20 18:04:32 coldwave homebridge[710]: [2018-1-20 18:04:32] Homebridge is running on port 51826.
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [TV Power] getOn: 224
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [PS3 Power] getOn: 237
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [PS4 Power] getOn: 232
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [Apple TV Power] getOn: 228
Jan 20 18:04:37 coldwave homebridge[710]: Did Send Command. Dest:  224 Command:  GIVE_DEVICE_POWER_STATUS
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [TV Power] TV Power reportStatus: on
Jan 20 18:04:37 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '0e', '90', '00' ],
Jan 20 18:04:37 coldwave homebridge[710]:   source: '0',
Jan 20 18:04:37 coldwave homebridge[710]:   target: 'e',
Jan 20 18:04:37 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:04:37 coldwave homebridge[710]:   args: [ 0 ] } Status:  0
Jan 20 18:04:37 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '0e', '90', '00' ],
Jan 20 18:04:37 coldwave homebridge[710]:   source: '0',
Jan 20 18:04:37 coldwave homebridge[710]:   target: 'e',
Jan 20 18:04:37 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:04:37 coldwave homebridge[710]:   args: [ 0 ] } Status:  0
Jan 20 18:04:37 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '0e', '90', '00' ],
Jan 20 18:04:37 coldwave homebridge[710]:   source: '0',
Jan 20 18:04:37 coldwave homebridge[710]:   target: 'e',
Jan 20 18:04:37 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:04:37 coldwave homebridge[710]:   args: [ 0 ] } Status:  0
Jan 20 18:04:37 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '0e', '90', '00' ],
Jan 20 18:04:37 coldwave homebridge[710]:   source: '0',
Jan 20 18:04:37 coldwave homebridge[710]:   target: 'e',
Jan 20 18:04:37 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:04:37 coldwave homebridge[710]:   args: [ 0 ] } Status:  0
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [TV Power] TV Power getOn: 1
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [PS3 Power] PS3 Power getOn: 1
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [PS4 Power] PS4 Power getOn: 1
Jan 20 18:04:37 coldwave homebridge[710]: [2018-1-20 18:04:37] [Apple TV Power] Apple TV Power getOn: 1

2nd try:

Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [PS4 Power] getOn: 232
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [PS3 Power] getOn: 237
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [Apple TV Power] getOn: 228
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [TV Power] getOn: 224
Jan 20 18:13:22 coldwave homebridge[710]: Did Send Command. Dest:  232 Command:  GIVE_DEVICE_POWER_STATUS
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [PS4 Power] PS4 Power reportStatus: standby
Jan 20 18:13:22 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '8e', '90', '01' ],
Jan 20 18:13:22 coldwave homebridge[710]:   source: '8',
Jan 20 18:13:22 coldwave homebridge[710]:   target: 'e',
Jan 20 18:13:22 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:13:22 coldwave homebridge[710]:   args: [ 1 ] } Status:  1
Jan 20 18:13:22 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '8e', '90', '01' ],
Jan 20 18:13:22 coldwave homebridge[710]:   source: '8',
Jan 20 18:13:22 coldwave homebridge[710]:   target: 'e',
Jan 20 18:13:22 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:13:22 coldwave homebridge[710]:   args: [ 1 ] } Status:  1
Jan 20 18:13:22 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '8e', '90', '01' ],
Jan 20 18:13:22 coldwave homebridge[710]:   source: '8',
Jan 20 18:13:22 coldwave homebridge[710]:   target: 'e',
Jan 20 18:13:22 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:13:22 coldwave homebridge[710]:   args: [ 1 ] } Status:  1
Jan 20 18:13:22 coldwave homebridge[710]: Did Receive Packet. Packet:  { tokens: [ '8e', '90', '01' ],
Jan 20 18:13:22 coldwave homebridge[710]:   source: '8',
Jan 20 18:13:22 coldwave homebridge[710]:   target: 'e',
Jan 20 18:13:22 coldwave homebridge[710]:   opcode: 144,
Jan 20 18:13:22 coldwave homebridge[710]:   args: [ 1 ] } Status:  1
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [PS4 Power] PS4 Power getOn: 0
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [PS3 Power] PS3 Power getOn: 0
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [Apple TV Power] Apple TV Power getOn: 0
Jan 20 18:13:22 coldwave homebridge[710]: [2018-1-20 18:13:22] [TV Power] TV Power getOn: 0