Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Able to pair, turn off once, then not able to turn off or use remote again #47

Open
Dennaldo opened this issue Dec 28, 2020 · 9 comments

Comments

@Dennaldo
Copy link

I was able to pair my TV using pair1. I have tried other ways to see if I could avoid what happens, but only pair1 seems to work with my TV.

I pair successfully, add the device in the Home app and am able to control the device using the iOS remote. I am able to see the status of the TV (on or off). I can power off the device once only, then the device never responds to power off again. I can still see the status in Home, cannot use the remote any longer in iOS, I can change the volume and mute/unmute Homebridge but also cannot power the device off.

When I try to power off the device again I get an UnhandledPromiseRejectionWarning in my logs. I apologize as I cannot paste the full text as iOS is not letting me copy it. I can grab them and post them later.

@mmende
Copy link
Owner

mmende commented Dec 28, 2020

Hm strange... this is probable a library agnostic problem that originates from this library. I am not 100% familiar with the way this library actually controls the tv unfortunately. Maybe I'll try to dive a bit deeper into the library to fix some bugs like these myself when I find some time to do so.

@Dennaldo
Copy link
Author

Below is the error printed in the HomeBridge log when I press the Power button on the device from both the Home app and from HomeBridge accessories:

(node:1013) UnhandledPromiseRejectionWarning: Error: Unable to handleEvent
at /usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:130:13
at /usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/Messages.js:30:31
at new Promise ()
at Messages.handle (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/Messages.js:29:12)
at onMessageEmitter (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:45:12)
at WebSocket. (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:157:9)
at WebSocket.emit (events.js:315:20)
at Receiver._receiver.onmessage (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/ws/lib/websocket.js:137:47)
at Receiver.dataMessage (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:409:14)
at Receiver.getData (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:347:12)
at Receiver.startLoop (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:143:16)
at Receiver.add (/usr/local/lib/node_modules/@dustinblackman/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:117:10)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:284:9)
at Socket.Readable.push (_stream_readable.js:223:10)
(Use node --trace-warnings ... to show where the warning was created)
(node:1013) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:1013) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@djsomi
Copy link

djsomi commented Jan 6, 2021

Same issue here, it was OK for the first time / day, now trowing this error for every button press.

@maverixx
Copy link

maverixx commented Jan 8, 2021

Same Issue. Managed to reconnect by (1) Resetting Samsung TV to factory settings, (2) reinstalling "SamsungTV Control" and going through pairing again. Sadly, the TV Q85T2020 now continuously want me to "Allow Node.js" each and everytime I send a command (and the command isn't implemented). Other wise the programming is really neat and Mr MMENDE deserves credit for the neatest yet seen Homebridge installation + auto config code. 😄

(Very happy to provide Logs if this is helpful. Just message me :) )

@deepontech
Copy link

Same here, keeps asking to allow Node.js

@patrickkettner
Copy link

looked at this for a bit. At least for devices that use the underlying samsung-tv-control (which I think is any device that is requiring the pin, but 🤷‍♂️), the token isn't being passed over. Specifically, the initiation of it here

  const control = new Samsung(cfg)

is passing in this config

  const cfg = getRemoteConfig(config)

which is being generated by this function

const getRemoteConfig = (config: DeviceConfig) => {
  const model = parseSerialNumber(config.modelName)
  const { year = 2013 } = model || {}
  const supportsLegacy = typeof year === `number` && year < 2014
  const port = config.remoteControlPort || supportsLegacy ? 55000 : 8002
  return {
    mac: config.mac,
    ip: config.lastKnownIp,
    name: PLATFORM_NAME,
    port,
  }
}

the token that is being added to the configuration file is not being passed in. I manually added this line

token: config.token,

to my own version locally, and its working now.

const getRemoteConfig = (config: DeviceConfig) => {
  const model = parseSerialNumber(config.modelName)
  const { year = 2013 } = model || {}
  const supportsLegacy = typeof year === `number` && year < 2014
  const port = config.remoteControlPort || supportsLegacy ? 55000 : 8002
  return {
    mac: config.mac,
    ip: config.lastKnownIp,
    name: PLATFORM_NAME,
    token: config.token,
    port,
  }
}

@mmende mmende closed this as completed in 4b7e232 Nov 8, 2021
@mmende
Copy link
Owner

mmende commented Nov 8, 2021

Thanks for the effort @patrickkettner. I just added your changes and published v2.0.3

@mmende mmende reopened this Nov 8, 2021
@djsomi
Copy link

djsomi commented Nov 24, 2021

Hi Guys,

Thanks for the update, I've tested it, was good for a few days, than it started to throwing this again:

(node:30540)_ UnhandledPromiseRejectionWarning: Error: Unable to handleEvent
at /usr/lib/node_modules/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:130:13
at /usr/lib/node_modules/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/Messages.js:30:31
at new Promise ()
at Messages.handle (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/Messages.js:29:12)
at onMessageEmitter (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:45:12)
at WebSocket. (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/samsung-remote-pin-paired/lib/Connection/SamsungTvConnection.js:157:9)
at WebSocket.emit (events.js:400:28)
at Receiver._receiver.onmessage (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/ws/lib/websocket.js:137:47)
at Receiver.dataMessage (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:409:14)
at Receiver.getData (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:347:12)
at Receiver.startLoop (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:143:16)
at Receiver.add (/usr/lib/node_modules/homebridge-samsungtv-control/node_modules/ws/lib/receiver.js:117:10)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:30540) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:30540) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@djsomi
Copy link

djsomi commented Dec 16, 2021

Tried to remove and add again, now it TV cant be added anymore. Mabye its from IOS 15?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants