homebridge-homesung
homebridge-homesung copied to clipboard
KEY_POWER bug
@kkapitan I think I discovered a bug. I added a KEY_POWER
command to my config.json. When I trigger it on my phone it does turn the TV off. But after I turn the TV back on using my remote and try to trigger any other command related to homesung plugin, e.g. KEY_VOLUP
the whole HomeKit app on my phone becomes unresponsive (including other accessories not related with your plugin). The only way to make the plugin work again is to run homesung-pair <ip of the device>
, generate new PIN and update aesKey
.
That's the log from Homebridge after I triggered the KEY_POWER
, turned the TV on with remote and tried to trigged any other command:
/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3
!function(a,b){function c(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function d(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function e(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function f(a,b){b=!!b;for(var c=a.length,d=new Uint8Array(b?4*c:c),e=0,f=0;c>e;e++){var g=a.charCodeAt(e);if(b&&g>=55296&&56319>=g){if(++e>=c)throw new Error(„Malformed string, low surrogate expected at position „+e);g=(55296^g)<<10|65536|56320^a.charCodeAt(e)}else if(!b&&g>>>8)throw new Error(„Wide characters are not allowed.”);!b||127>=g?d[f++]=g:2047>=g?(d[f++]=192|g>>6,d[f++]=128|63&g):65535>=g?(d[f++]=224|g>>12,d[f++]=128|g>>6&63,d[f++]=128|63&g):(d[f++]=240|g>>18,d[f++]=128|g>>12&63,d[f++]=128|g>>6&63,d[f++]=128|63&g)}return d.subarray(0,f)}function g(a){var b=a.length;1&b&&(a=„0”+a,b++);for(var c=new Uint8Array(b>>1),d=0;b>d;d+=2)c[d>>1]=parseInt(a.s
Error: bad padding
at new e (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:219)
at z.y [as decrypt] (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:5196)
at Function.G [as decrypt] (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:6018)
at Object.decryptData (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/index.js:666:41)
at Encryption.decrypt (/usr/lib/node_modules/homebridge-homesung/src/connection/encryption.js:16:22)
at Object.handleMessage (/usr/lib/node_modules/homebridge-homesung/src/connection/handlers.js:51:54)
at SocketConnection.
Thanks for reporting!
That's weird since again - this does not occur on H series. I'll take a closer look. Is this issue reproducible for you? Because my first guess would be, that you tried to pair after already obtaining identity and configuring the plugin. Each pairing session should invalidate the previous one, maybe the issue is there?
Nonetheless we need some better error handling here, because this kills the running homebridge instance.
...that you tried to pair after already obtaining identity and configuring the plugin.
That's not it. I paired it only once, updated the config.json
with aesKey
, sessionId
and didn't try to pair it again.
Is this issue reproducible for you?
Yep, it happens every time I try to use KEY_POWER
.
KEY_POWER
-> TV turns off -> "Power on" on remote -> Any other command -> App becomes unresponsive
Plugin works just fine when I don't use KEY_POWER
Allright, I’ll check what I can do then
If this is any help: I wanted to create a workaround for turning the TV off so I created an array that selects the "Power off" function from the "Top menu" in the TV
{ "name": "TV Power off", "command": ["KEY_MORE", "2*KEY_UP", "2*KEY_LEFT", "KEY_ENTER"] }
After the TV turns off and I turn it back on with the remote, HomeKit app becomes unresponsive. I tested dozen of other commands and arrays and they work fine as long as power off is not included.
EDIT: Weird thing – I changed the name of the command from "TV Power off" to "Disable Samsung" and now the workaround is working 😄 I also tested it with KEY_POWER
and it's working as long as I don't use word "power" in the name of the command.
That's truly weird! I'll run some tests in my spare time. I'm not sure why the whole homebridge gets stuck...
One thing that crossed my mind - my TV needs some time to start the networking interface after it is launched. I haven't tested the HomeKit and homebridge in that case, will definitely check that. But I wonder - does HomeKit return to the normal state within say 2-3 minutes after TV is started? Maybe this is the same case.
I'll soon provide you with the version that will log more info about what exactly is being sent back and forth, would you mind reproducing your problem then?
does HomeKit return to the normal state within say 2-3 minutes after TV is started?
No, it's stuck permanently.
would you mind reproducing your problem then?
Sure thing, just ping me when you have the updated version ready.
BTW. Any chance you planning to add delay
? This would be handy especially with longer arrays.
About the delay - sure thing! There is already a feature request for that, see: #3
I'll try to prepare the version with debug logging and this delay tonight. Hopefully we'll know some more about the origin of this powering off issue
Hi, small update from me - my RPI arrived so I can finally work on turn on feature.
The thing is I've got a little emergency this weekend that needs to be addressed, so the next version should be released on Monday or Tuesday.
Version 0.2.0 is out! It should now be possible to enable debug logs for all the traffic between a server and the TV. You can set it up by using additional { "debug": true }
settings in the device config.
Would you be so kind to reproduce the error with the debug logs on?
Also the 0.2.0 contains also experimental way to power on the TV via hdmi-cec. See power for an instruction of how to set it up! Maybe it will serve as some kind of workaround for you!
@kkapitan Thanks for the update :) I'll do some testing this afternoon
@kkapitan I set the debug to true and reproduced the error but I don't think the log is any different than the one I already pasted you:
[2018-9-18 20:07:41] [SamsungTV] Requesting device status [2018-9-18 20:07:41] [SamsungTV] Requesting device status succeded: on [2018-9-18 20:07:41] [SamsungTV] TV status: on [2018-9-18 20:07:48] [SamsungTV] CONNECTING
(this is where I send the command on my phone)
[2018-9-18 20:07:48] [SamsungTV] Handling initial message [2018-9-18 20:07:49] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[135,151,220,67,178,196,108,72,83,38,35,168,75,167,124,77,92,215,205,83,167,86,93,188,173,79,241,230,118,205,99,179,199,72,120,16,129,232,3,152,73,58,6,1,160,145,112,5,99,82,226,66,232,213,204,96,232,153,95,102,30,53,140,103]"}
/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3
!function(a,b){function c(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function d(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function e(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function f(a,b){b=!!b;for(var c=a.length,d=new Uint8Array(b?4*c:c),e=0,f=0;c>e;e++){var g=a.charCodeAt(e);if(b&&g>=55296&&56319>=g){if(++e>=c)throw new Error("Malformed string, low surrogate expected at position "+e);g=(55296^g)<<10|65536|56320^a.charCodeAt(e)}else if(!b&&g>>>8)throw new Error("Wide characters are not allowed.");!b||127>=g?d[f++]=g:2047>=g?(d[f++]=192|g>>6,d[f++]=128|63&g):65535>=g?(d[f++]=224|g>>12,d[f++]=128|g>>6&63,d[f++]=128|63&g):(d[f++]=240|g>>18,d[f++]=128|g>>12&63,d[f++]=128|g>>6&63,d[f++]=128|63&g)}return d.subarray(0,f)}function g(a){var b=a.length;1&b&&(a="0"+a,b++);for(var c=new Uint8Array(b>>1),d=0;b>d;d+=2)c[d>>1]=parseInt(a.s
Error: bad padding
at new e (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:219)
at z.y [as decrypt] (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:5196)
at Function.G [as decrypt] (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:6018)
at Object.decryptData (/usr/lib/node_modules/homebridge-homesung/vendor/encryption/index.js:666:41)
at Encryption.decrypt (/usr/lib/node_modules/homebridge-homesung/src/connection/encryption.js:16:22)
at Object.handleMessage (/usr/lib/node_modules/homebridge-homesung/src/connection/handlers.js:54:54)
at SocketConnection.
And like I mentioned before – after getting this error I have to run the homesung-pair
command to get your plugin working again.
And here's the log when the command was sent successfully:
[2018-9-18 20:16:43] [SamsungTV] CONNECTING [2018-9-18 20:16:43] [SamsungTV] Handling initial message [2018-9-18 20:16:44] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[118,76,38,40,50,199,7,1,93,100,213,120,60,8,166,191,51,171,157,25,234,1,147,127,182,202,99,83,0,114,162,13,240,87,21,86,90,123,83,199,8,149,189,33,126,133,112,19,88,150,247,169,98,164,86,177,34,242,200,59,78,187,130,35]"} [2018-9-18 20:16:44] [SamsungTV] Decrypted message: {"plugin":"NNavi","api":"GetDUID","result":"MTCEDVBZNE5OQ"} [2018-9-18 20:16:44] [SamsungTV] CONNECTED [2018-9-18 20:16:44] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[240,189,128,224,152,91,67,182,202,205,176,161,208,110,153,60,1,136,219,66,27,43,64,161,214,32,84,160,169,227,219,114,190,248,28,120,212,53,68,62,232,94,22,225,80,202,141,91,171,83,191,47,12,145,102,83,79,198,254,248,227,42,9,45]"} [2018-9-18 20:16:44] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}} [2018-9-18 20:16:44] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[240,189,128,224,152,91,67,182,202,205,176,161,208,110,153,60,1,136,219,66,27,43,64,161,214,32,84,160,169,227,219,114,190,248,28,120,212,53,68,62,232,94,22,225,80,202,141,91,171,83,191,47,12,145,102,83,79,198,254,248,227,42,9,45]"} [2018-9-18 20:16:44] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}} [2018-9-18 20:16:45] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[240,189,128,224,152,91,67,182,202,205,176,161,208,110,153,60,1,136,219,66,27,43,64,161,214,32,84,160,169,227,219,114,190,248,28,120,212,53,68,62,232,94,22,225,80,202,141,91,171,83,191,47,12,145,102,83,79,198,254,248,227,42,9,45]"} [2018-9-18 20:16:45] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}}
(J serie TV): I had the same issue. KEY_POWER resulting in Home Bridge being in responsive. it also resulted in the message "Is Server running?" After a homesung-pair it functions again. However when I added KEY_POWER to the power section (and not a separate key) it just worked. The power action turns off the TV. And after turning the TV on it still works and other keys as well (Mute, Volume)
The Log:
[9/30/2018, 12:31:20 PM] [SamsungTV] Requesting device status [9/30/2018, 12:31:20 PM] [SamsungTV] Requesting device status succeded: on [9/30/2018, 12:31:20 PM] [SamsungTV] Setting device to: standby [9/30/2018, 12:31:21 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[214,187,222,87,122,90,60,119,109,240,233,16,195,146,103,165,193,236,171,165,163,210,128,152,35,121,136,153,69,216,51,92,99,65,2,29,114,218,207,79,228,128,157,12,251,22,228,64,220,186,202,253,9,83,168,143,103,75,215,68,88,185,116,183]"} [9/30/2018, 12:31:21 PM] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}} [9/30/2018, 12:32:04 PM] [Config] Changes to config.json saved. [9/30/2018, 12:39:38 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receivePush","args":"[22,95,78,221,30,155,123,33,127,136,41,40,229,52,18,22,190,114,92,64,113,135,168,240,75,100,214,11,64,230,144,232,86,132,167,179,11,65,60,52,226,57,105,231,12,203,55,23,78,132,109,170,118,224,15,199,97,223,115,55,140,189,33,135,32,253,142,67,206,179,32,22,124,145,227,170,63,77,141,100]"} [9/30/2018, 12:39:38 PM] [SamsungTV] Decrypted message: {"plugin":"SecondTV","event":6,"data1":"EMP_TV_POWER_OFF","data2":""} [9/30/2018, 12:39:39 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receivePush","args":"[22,95,78,221,30,155,123,33,127,136,41,40,229,52,18,22,53,239,172,204,102,100,159,131,147,246,53,134,40,187,144,172,212,48,253,212,188,182,215,5,208,178,229,234,23,163,53,122,171,219,208,124,67,119,152,144,11,140,111,40,35,112,134,77,186,105,227,121,35,30,22,255,43,205,204,21,173,125,227,247]"} [9/30/2018, 12:39:39 PM] [SamsungTV] Decrypted message: {"plugin":"SecondTV","event":9,"data1":"EMP_SOURCE_LIST_CHANGED","data2":""} [9/30/2018, 12:39:48 PM] [SamsungTV] Requesting device status [9/30/2018, 12:39:48 PM] [SamsungTV] Requesting device status succeded: on [9/30/2018, 12:39:48 PM] [SamsungTV] TV status: on [9/30/2018, 12:39:50 PM] [SamsungTV] Handling keep alive [9/30/2018, 12:39:53 PM] [SamsungTV] Requesting device status [9/30/2018, 12:39:53 PM] [SamsungTV] Requesting device status succeded: on [9/30/2018, 12:39:53 PM] [SamsungTV] Requesting device status [9/30/2018, 12:39:53 PM] [SamsungTV] Requesting device status succeded: on [9/30/2018, 12:39:53 PM] [SamsungTV] Setting device to: standby [9/30/2018, 12:39:53 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[214,187,222,87,122,90,60,119,109,240,233,16,195,146,103,165,193,236,171,165,163,210,128,152,35,121,136,153,69,216,51,92,99,65,2,29,114,218,207,79,228,128,157,12,251,22,228,64,220,186,202,253,9,83,168,143,103,75,215,68,88,185,116,183]"} [9/30/2018, 12:39:53 PM] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}}
Unfortunately I have also still the situation that sometimes the power action powers down the TV and after starting the TV again the plugin cannot find the server it wants to connect to. This can only be solved by re-pairing the plugin. I will try to collect logs and recreation steps in the next days
Hi! Thanks for using the plugin and the logs! Can you also show me the output of typing {tv_ip}:8001/ms/1.0/ in the browser?
{ "DUID": "uuid:6c921f05-c7cf-408d-ba71-36097e6a2d10", "Model": "15_HAWKM_2D", "ModelName": "UE40J6200", "ModelDescription": "Samsung DTV RCR", "NetworkType": "wired", "SSID": "", "IP": "192.168.178.138", "FirmwareVersion": "Unknown", "DeviceName": "[TV] Living room", "DeviceID": "uuid:6c921f05-c7cf-408d-ba71-36097e6a2d10", "UDN": "uuid:6c921f05-c7cf-408d-ba71-36097e6a2d10", "Resolution": "1920x1080", "CountryCode": "NL", "SmartHubAgreement": "true", "ServiceURI": "http://192.168.178.138:8001/ms/1.0/", "DialURI": "http://192.168.178.138:8001/ws/apps/", "Capabilities": [ { "name": "samsung:multiscreen:1", "port": "8001", "location": "/ms/1.0/" } ] }
Just wanted to add I appreciate your work as it is the first Samsung plugin which actually works for the model. For me the main goal is power down, mute and volume control mainly used in automations.
Thanks! It means a lot to me :) I'll try to find the issue in my spare time, but as for now would you be so kind to try one of my ideas?
If you open /usr/local/lib/node_modules/homebridge-homesung/request-identity.js
via any text editor and replace this code:
const config = {
ip: args[0],
appId: '721b6fce-4ee6-48ba-8045-955a539edadb',
userId: '654321',
};
with this code
const config = {
ip: args[0],
deviceId: "6c921f05-c7cf-408d-ba71-36097e6a2d10",
appId: '721b6fce-4ee6-48ba-8045-955a539edadb',
userId: '654321',
};
Then save the file and try to pair and update the homebride config as with the first setup. I'm not able to test it on my device since I have H series which somehow works between TV launches.
This looks good. I edited the file (in nano), paired again (go a updated session id as well this time). I could now power the tv (remote) use homekit button,powerdown using the KEY_POWER in the power: section, push buttons when powered down without making homekit inresponsive and it stays working.
Great!
I will monitor this for a while. I now see one small thing and that is that the state of the homekit TV button (with the power: KEY_POWER behind it) is not checking the state it seems (it stays active and switches states only when clicking the button) ie. First round TV button is active, I click, powerdown happens, button is inactive. I start TV (with remote), click some buttons (mute, volume), TV button stays inactive. I click on the TV button, the TV powers don and the button is active, etc. etc. It would be nice if the button mirrors the power state of the TV (or is this a timing issue, where it just takessome time to refresh?)
I have this problem:
Sep 19 21:31:36 raspberry homebridge[2014]: [9/19/2018, 9:31:36 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:31:36 raspberry homebridge[2014]: [9/19/2018, 9:31:36 PM] [SamsungTV] TV status: standby Sep 19 21:31:36 raspberry homebridge[2014]: [9/19/2018, 9:31:36 PM] [SamsungTV] Requesting device status: 224 Sep 19 21:31:36 raspberry homebridge[2014]: [9/19/2018, 9:31:36 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:31:36 raspberry homebridge[2014]: [9/19/2018, 9:31:36 PM] [SamsungTV] TV status: standby Sep 19 21:31:42 raspberry homebridge[2014]: [9/19/2018, 9:31:42 PM] [SamsungTV] Requesting device status: 224 Sep 19 21:31:42 raspberry homebridge[2014]: [9/19/2018, 9:31:42 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:31:42 raspberry homebridge[2014]: [9/19/2018, 9:31:42 PM] [SamsungTV] Requesting device status: 224 Sep 19 21:31:42 raspberry homebridge[2014]: [9/19/2018, 9:31:42 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:31:42 raspberry homebridge[2014]: [9/19/2018, 9:31:42 PM] [SamsungTV] Changing status to: on Sep 19 21:32:56 raspberry homebridge[2014]: [9/19/2018, 9:32:56 PM] [SamsungTV] Requesting device status: 224 Sep 19 21:32:56 raspberry homebridge[2014]: [9/19/2018, 9:32:56 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:32:56 raspberry homebridge[2014]: [9/19/2018, 9:32:56 PM] [SamsungTV] Requesting device status: 224 Sep 19 21:32:56 raspberry homebridge[2014]: [9/19/2018, 9:32:56 PM] [SamsungTV] Requesting device status failed: cec-client never reported ready Sep 19 21:32:56 raspberry homebridge[2014]: [9/19/2018, 9:32:56 PM] [SamsungTV] Changing status to: on
and don't work a power ON or OFF!
Any idea?
But if i use:
cec-client Power OFF: standby 0 Power ON: on 0
and working, idk not working in plugin :'(
@kkapitan editing request-identity.js
didn't help in my case. I still get the same error as I mentioned above. Do you have any predictions what might be the cause of this?
@boro55 Did you put there your own deviceId (without the udid:
part) or the same as above?
@kaosmagix Thanks for testing! I hope it will work for good :)
@kaosmagix @maimbe I'll try to address those issues in next release which may happen in a week.
@kkapitan I pasted my own DeviceId from {tv_ip}:8001/ms/1.0/.
btw. thanks for all your hard work :)
Just to let you know it still happens. What seems to happen is that the pairing at some point does not work anymore and any command followed will cause HomeBridge to crash (I run homebridge in pm2, which directly restarts so at first I didn't notice).
Log when sending KEY_MUTE when the pairing is failed (this action crashed HomeBridge):
[10/1/2018, 7:26:21 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:26:21 PM] [SamsungTV] Requesting device status succeded: on
[10/1/2018, 7:26:21 PM] [SamsungTV] TV status: on
[10/1/2018, 7:26:26 PM] [SamsungTV] CONNECTING
[10/1/2018, 7:26:26 PM] [SamsungTV] Handling initial message
[10/1/2018, 7:26:26 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[135,151,220,67,178,196,108,72,83,38,35,168,75,167,124,77,92,215,205,83,167,86,93,188,173,79,241,230,118,205,99,179,199,72,120,16,129,232,3,152,73,58,6,1,160,145,112,5,99,82,226,66,232,213,204,96,232,153,95,102,30,53,140,103]"}
/usr/local/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3
!function(a,b){function c(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function d(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function e(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function f(a,b){b=!!b;for(var c=a.length,d=new Uint8Array(b?4*c:c),e=0,f=0;c>e;e++){var g=a.charCodeAt(e);if(b&&g>=55296&&56319>=g){if(++e>=c)throw new Error("Malformed string, low surrogate expected at position "+e);g=(55296^g)<<10|65536|56320^a.charCodeAt(e)}else if(!b&&g>>>8)throw new Error("Wide characters are not allowed.");!b||127>=g?d[f++]=g:2047>=g?(d[f++]=192|g>>6,d[f++]=128|63&g):65535>=g?(d[f++]=224|g>>12,d[f++]=128|g>>6&63,d[f++]=128|63&g):(d[f++]=240|g>>18,d[f++]=128|g>>12&63,d[f++]=128|g>>6&63,d[f++]=128|63&g)}return d.subarray(0,f)}function g(a){var b=a.length;1&b&&(a="0"+a,b++);for(var c=new Uint8Array(b>>1),d=0;b>d;d+=2)c[d>>1]=parseInt(a.substr(d,2),16);return c}function h(a){return f(atob(a))}function i(a,b){b=!!b;for(var c=a.length,d=new Array(c),e=0,f=0;c>e;e++){var g=a[e];if(!b||128>g)d[f++]=g;else if(g>=192&&224>g&&c>e+1)d[f++]=(31&g)<<6|63&a[++e];else if(g>=224&&240>g&&c>e+2)d[f++]=(15&g)<<12|(63&a[++e])<<6|63&a[++e];else{if(!(g>=240&&248>g&&c>e+3))throw new Error("Malformed UTF8 character at byte offset "+e);var h=(7&g)<<18|(63&a[++e])<<12|(63&a[++e])<<6|63&a[++e];65535>=h?d[f++]=h:(h^=65536,d[f++]=55296|h>>10,d[f++]=56320|1023&h)}}for(var i="",j=16384,e=0;f>e;e+=j)i+=String.fromCharCode.apply(String,d.slice(e,f>=e+j?e+j:f));return i}function j(a){for(var b="",c=0;c<a.length;c++){var d=(255&a[c]).toString(16);d.length<2&&(b+="0"),b+=d}return b}function k(a){return btoa(i(a))}function l(a){return"string"==typeof a}function m(a){return a instanceof ArrayBuffer}function n(a){return a instanceof Uint8Array}function o(a,b){var c=b.heap,d=c?c.byteLength:b.heapSize||65536;if(4095&d||0>=d)throw new Error("heap size must be a positive integer and a multiple of 4096");return c=c||new a(new ArrayBuffer(d))}function p(a,b,c,d,e){var f=a.length-b,g=e>f?f:e;return a.set(c.subarray(d,d+g),b),g}function q(a){a=a||{},this.heap=o(Uint8Array,a).subarray(S.HEAP_DATA),this.asm=a.asm||S(b,null,this.heap.buffer),this.mode=null,this.key=null,this.reset(a)}function r(a){if(void 0!==a){if(m(a)||n(a))a=new Uint8Array(a);else{if(!l(a))throw new TypeError("unexpected key type");a=f(a)}var b=a.length;if(16!==b&&24!==b&&32!==b)throw new d("illegal key size");var c=new DataView(a.buffer,a.byteOffset,a.byteLength);this.asm.set_key(b>>2,c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12),b>16?c.getUint32(16):0,b>16?c.getUint32(20):0,b>24?c.getUint32(24):0,b>24?c.getUint32(28):0),this.key=a}else if(!this.key)throw new Error("key is required")}function s(a){if(void 0!==a){if(m(a)||n(a))a=new Uint8Array(a);else{if(!l(a))throw new TypeError("unexpected iv type");a=f(a)}if(16!==a.length)throw new d("illegal iv size");var b=new DataView(a.buffer,a.byteOffset,a.byteLength);this.iv=a,this.asm.set_iv(b.getUint32(0),b.getUint32(4),b.getUint32(8),b.getUint32(12))}else this.iv=null,this.asm.set_iv(0,0,0,0)}function t(a){void 0!==a?this.padding=!!a:this.padding=!0}function u(a){return a=a||{},this.result=null,this.pos=0,this.len=0,r.call(this,a.key),this.hasOwnProperty("iv")&&s.call(this,a.iv),this.hasOwnProperty("padding")&&t.call(this,a.padding),this}function v(a){if(l(a)&&(a=f(a)),m(a)&&(a=new Uint8Array(a)),!n(a))throw new TypeError("data isn't of expected type");for(var b=this.asm,c=this.heap,d=S.ENC[this.mode],e=S.HEAP_DATA,g=this.pos,h=this.len,i=0,j=a.length||0,k=0,o=h+j&-16,q=0,r=new Uint8Array(o);j>0;)q=p(c,g+h,a,i,j),h+=q,i+=q,j-=q,q=b.cipher(d,e+g,h),q&&r.set(c.subarray(g,g+q),k),k+=q,h>q?(g+=q,h-=q):(g=0,h=0);return this.result=r,this.pos=g,this.len=h,this}function w(a){var b=null,c=0;void 0!==a&&(b=v.call(this,a).result,c=b.length);var e=this.asm,f=this.heap,g=S.ENC[this.mode],h=S.HEAP_DATA,i=this.pos,j=this.len,k=16-j%16,l=j;if(this.hasOwnProperty("padding")){if(this.padding){for(var m=0;k>m;++m)f[i+j+m]=k;j+=k,l=j}else if(j%16)throw new d("data length must be a multiple of the block size")}else j+=k;var n=new Uint8Array(c+l);return c&&n.set(b),j&&e.cipher(g,h+i,j),l&&n.set(f.subarray(i,i+l),c),this.result=n,this.pos=0,this.len=0,this}function x(a){if(l(a)&&(a=f(a)),m(a)&&(a=new Uint8Array(a)),!n(a))throw new TypeError("data isn't of expected type");var b=this.asm,c=this.heap,d=S.DEC[this.mode],e=S.HEAP_DATA,g=this.pos,h=this.len,i=0,j=a.length||0,k=0,o=h+j&-16,q=0,r=0;this.hasOwnProperty("padding")&&this.padding&&(q=h+j-o||16,o-=q);for(var s=new Uint8Array(o);j>0;)r=p(c,g+h,a,i,j),h+=r,i+=r,j-=r,r=b.cipher(d,e+g,h-(j?0:q)),r&&s.set(c.subarray(g,g+r),k),k+=r,h>r?(g+=r,h-=r):(g=0,h=0);return this.result=s,this.pos=g,this.len=h,this}function y(a){var b=null,c=0;void 0!==a&&(b=x.call(this,a).result,c=b.length);var f=this.asm,g=this.heap,h=S.DEC[this.mode],i=S.HEAP_DATA,j=this.pos,k=this.len,l=k;if(k>0){if(k%16){if(this.hasOwnProperty("padding"))throw new d("data length must be a multiple of the block size");k+=16-k%16}if(f.cipher(h,i+j,k),this.hasOwnProperty("padding")&&this.padding){var m=g[j+l-1];if(1>m||m>16||m>l)throw new e("bad padding");for(var n=0,o=m;o>1;o--)n|=m^g[j+l-o];if(n)throw new e("bad padding");l-=m}}var p=new Uint8Array(c+l);return c>0&&p.set(b),l>0&&p.set(g.subarray(j,j+l),c),this.result=p,this.pos=0,this.len=0,this}function z(a){this.padding=!0,q.call(this,a),this.mode="ECB"}function A(a){z.call(this,a)}function B(a){z.call(this,a)}function C(a){this.padding=!0,this.iv=null,q.call(this,a),this.mode="CBC"}function D(a){C.call(this,a)}function E(a){C.call(this,a)}function F(a,b,c){if(void 0===a)throw new SyntaxError("data required");if(void 0===b)throw new SyntaxError("key required");return new z({heap:Z,asm:$,key:b,padding:c}).encrypt(a).result}function G(a,b,c){if(void 0===a)throw new SyntaxError("data required");if(void 0===b)throw new SyntaxError("key required");return new z({heap:Z,asm:$,key:b,padding:c}).decrypt(a).result}function H(a,b,c,d){if(void 0===a)throw new SyntaxError("data required");if(void 0===b)throw new SyntaxError("key required");return new C({heap:Z,asm:$,key:b,padding:c,iv:d}).encrypt(a).result}function I(a,b,c,d){if(void 0===a)throw new SyntaxError("data required");if(void 0===b)throw new SyntaxError("key required");return new C({heap:Z,asm:$,key:b,padding:c,iv:d}).decrypt(a).result}function J(){return this.result=null,this.pos=0,this.len=0,this.asm.reset(),this}function K(a){if(null!==this.result)throw new c("state must be reset before processing new data");if(l(a)&&(a=f(a)),m(a)&&(a=new Uint8Array(a)),!n(a))throw new TypeError("data isn't of expected type");for(var b=this.asm,d=this.heap,e=this.pos,g=this.len,h=0,i=a.length,j=0;i>0;)j=p(d,e+g,a,h,i),g+=j,h+=j,i-=j,j=b.process(e,g),e+=j,g-=j,g||(e=0);return this.pos=e,this.len=g,this}function L(){if(null!==this.result)throw new c("state must be reset before processing new data");return this.asm.finish(this.pos,this.len,0),this.result=new Uint8Array(this.HASH_SIZE),this.result.set(this.heap.subarray(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H|48]<<24|u[H|49]<<16|u[H|50]<<8|u[H|51],u[H|52]<<24|u[H|53]<<16|u[H|54]<<8|u[H|55],u[H|56]<<24|u[H|57]<<16|u[H|58]<<8|u[H|59],u[H|60]<<24|u[H|61]<<16|u[H|62]<<8|u[H|63])}function x(H){H=H|0;u[H|0]=d>>>24;u[H|1]=d>>>16&255;u[H|2]=d>>>8&255;u[H|3]=d&255;u[H|4]=e>>>24;u[H|5]=e>>>16&255;u[H|6]=e>>>8&255;u[H|7]=e&255;u[H|8]=f>>>24;u[H|9]=f>>>16&255;u[H|10]=f>>>8&255;u[H|11]=f&255;u[H|12]=g>>>24;u[H|13]=g>>>16&255;u[H|14]=g>>>8&255;u[H|15]=g&255;u[H|16]=h>>>24;u[H|17]=h>>>16&255;u[H|18]=h>>>8&255;u[H|19]=h&255}function y(){d=1732584193;e=4023233417;f=2562383102;g=271733878;h=3285377520;i=j=0}function z(H,I,J,K,L,M,N){H=H|0;I=I|0;J=J|0;K=K|0;L=L|0;M=M|0;N=N|0;d=H;e=I;f=J;g=K;h=L;i=M;j=N}function A(H,I){H=H|0;I=I|0;var J=0;if(H&63)return-1;while((I|0)>=64){w(H);H=H+64|0;I=I-64|0;J=J+64|0}i=i+J|0;if(i>>>0<J>>>0)j=j+1|0;return J|0}function B(H,I,J){H=H|0;I=I|0;J=J|0;var K=0,L=0;if(H&63)return-1;if(~J)if(J&31)return-1;if((I|0)>=64){K=A(H,I)|0;if((K|0)==-1)return-1;H=H+K|0;I=I-K|0}K=K+I|0;i=i+I|0;if(i>>>0<I>>>0)j=j+1|0;u[H|I]=128;if((I|0)>=56){for(L=I+1|0;(L|0)<64;L=L+1|0)u[H|L]=0;w(H);I=0;u[H|0]=0}for(L=I+1|0;(L|0)<59;L=L+1|0)u[H|L]=0;u[H|56]=j>>>21&255;u[H|57]=j>>>13&255;u[H|58]=j>>>5&255;u[H|59]=j<<3&255|i>>>29;u[H|60]=i>>>21&255;u[H|61]=i>>>13&255;u[H|62]=i>>>5&255;u[H|63]=i<<3&255;w(H);if(~J)x(J);return K|0}function C(){d=k;e=l;f=m;g=n;h=o;i=64;j=0}function D(){d=p;e=q;f=r;g=s;h=t;i=64;j=0}function E(H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W){H=H|0;I=I|0;J=J|0;K=K|0;L=L|0;M=M|0;N=N|0;O=O|0;P=P|0;Q=Q|0;R=R|0;S=S|0;T=T|0;U=U|0;V=V|0;W=W|0;y();v(H^1549556828,I^1549556828,J^1549556828,K^1549556828,L^1549556828,M^1549556828,N^1549556828,O^1549556828,P^1549556828,Q^1549556828,R^1549556828,S^1549556828,T^1549556828,U^1549556828,V^1549556828,W^1549556828);p=d;q=e;r=f;s=g;t=h;y();v(H^909522486,I^909522486,J^909522486,K^909522486,L^909522486,M^909522486,N^909522486,O^909522486,P^909522486,Q^909522486,R^909522486,S^909522486,T^909522486,U^909522486,V^909522486,W^909522486);k=d;l=e;m=f;n=g;o=h;i=64;j=0}function F(H,I,J){H=H|0;I=I|0;J=J|0;var K=0,L=0,M=0,N=0,O=0,P=0;if(H&63)return-1;if(~J)if(J&31)return-1;P=B(H,I,-1)|0;K=d,L=e,M=f,N=g,O=h;D();v(K,L,M,N,O,2147483648,0,0,0,0,0,0,0,0,0,672);if(~J)x(J);return P|0}function G(H,I,J,K,L){H=H|0;I=I|0;J=J|0;K=K|0;L=L|0;var M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0;if(H&63)return-1;if(~L)if(L&31)return-1;u[H+I|0]=J>>>24;u[H+I+1|0]=J>>>16&255;u[H+I+2|0]=J>>>8&255;u[H+I+3|0]=J&255;F(H,I+4|0,-1)|0;M=R=d,N=S=e,O=T=f,P=U=g,Q=V=h;K=K-1|0;while((K|0)>0){C();v(R,S,T,U,V,2147483648,0,0,0,0,0,0,0,0,0,672);R=d,S=e,T=f,U=g,V=h;D();v(R,S,T,U,V,2147483648,0,0,0,0,0,0,0,0,0,672);R=d,S=e,T=f,U=g,V=h;M=M^d;N=N^e;O=O^f;P=P^g;Q=Q^h;K=K-1|0}d=M;e=N;f=O;g=P;h=Q;if(~L)x(L);return 0}return{reset:y,init:z,process:A,finish:B,hmac_reset:C,hmac_init:E,hmac_finish:F,pbkdf2_generate_block:G}}function N(a){a=a||{},this.heap=o(Uint8Array,a),this.asm=a.asm||M(b,null,this.heap.buffer),this.BLOCK_SIZE=_,this.HASH_SIZE=aa,this.reset()}function O(){return null===ca&&(ca=new N({heapSize:1048576})),ca}function P(a){if(void 0===a)throw new SyntaxError("data required");return O().reset().process(a).finish().result}function Q(a){var b=P(a);return j(b)}function R(a){var b=P(a);return k(b)}c.prototype=Object.create(Error.prototype,{name:{value:"IllegalStateError"}}),d.prototype=Object.create(Error.prototype,{name:{value:"IllegalArgumentError"}}),e.prototype=Object.create(Error.prototype,{name:{value:"SecurityError"}});b.Float64Array||b.Float32Array;a.string_to_bytes=f,a.hex_to_bytes=g,a.base64_to_bytes=h,a.bytes_to_string=i,a.bytes_to_hex=j,a.bytes_to_base64=k;var S=function(){"use strict";function a(){e=[],f=[];var a,b,c=1;for(a=0;255>a;a++)e[a]=c,b=128&c,c<<=1,c&=255,128===b&&(c^=27),c^=e[a],f[e[a]]=a;e[255]=e[0],f[0]=0,k=!0}function b(a,b){var c=e[(f[a]+f[b])%255];return(0===a||0===b)&&(c=0),c}function c(a){var b=e[255-f[a]];return 0===a&&(b=0),b}function d(){function d(a){var b,d,e;for(d=e=c(a),b=0;4>b;b++)d=255&(d<<1|d>>>7),e^=d;return e^=99}k||a(),g=[],h=[],i=[[],[],[],[]],j=[[],[],[],[]];for(var e=0;256>e;e++){var f=d(e);g[e]=f,h[f]=e,i[0][e]=b(2,f)<<24|f<<16|f<<8|b(3,f),j[0][f]=b(14,e)<<24|b(9,e)<<16|b(13,e)<<8|b(11,e);for(var l=1;4>l;l++)i[l][e]=i[l-1][e]>>>8|i[l-1][e]<<24,j[l][f]=j[l-1][f]>>>8|j[l-1][f]<<24}}var e,f,g,h,i,j,k=!1,l=!1,m=function(a,b,c){function e(a,b,c,d,e,h,i,k,l){var n=f.subarray(0,60),o=f.subarray(256,316);n.set([b,c,d,e,h,i,k,l]);for(var p=a,q=1;4*a+28>p;p++){var r=n[p-1];(p%a===0||8===a&&p%a===4)&&(r=g[r>>>24]<<24^g[r>>>16&255]<<16^g[r>>>8&255]<<8^g[255&r]),p%a===0&&(r=r<<8^r>>>24^q<<24,q=q<<1^(128&q?27:0)),n[p]=n[p-a]^r}for(var s=0;p>s;s+=4)for(var t=0;4>t;t++){var r=n[p-(4+s)+(4-t)%4];4>s||s>=p-4?o[s+t]=r:o[s+t]=j[0][g[r>>>24]]^j[1][g[r>>>16&255]]^j[2][g[r>>>8&255]]^j[3][g[255&r]]}m.set_rounds(a+5)}l||d();var f=new Uint32Array(c);f.set(g,512),f.set(h,768);for(var k=0;4>k;k++)f.set(i[k],4096+1024*k>>2),f.set(j[k],8192+1024*k>>2);var m=function(a,b,c){"use asm";var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;var y=new a.Uint32Array(c),z=new a.Uint8Array(c);function A(X,Y,Z,$,_,aa,ba,ca){X=X|0;Y=Y|0;Z=Z|0;$=$|0;_=_|0;aa=aa|0;ba=ba|0;ca=ca|0;var da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0;da=Z|1024,ea=Z|2048,fa=Z|3072;_=_^y[(X|0)>>2],aa=aa^y[(X|4)>>2],ba=ba^y[(X|8)>>2],ca=ca^y[(X|12)>>2];for(ka=16;(ka|0)<=$<<4;ka=ka+16|0){ga=y[(Z|_>>22&1020)>>2]^y[(da|aa>>14&1020)>>2]^y[(ea|ba>>6&1020)>>2]^y[(fa|ca<<2&1020)>>2]^y[(X|ka|0)>>2],ha=y[(Z|aa>>22&1020)>>2]^y[(da|ba>>14&1020)>>2]^y[(ea|ca>>6&1020)>>2]^y[(fa|_<<2&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;$=$|0;p=X,q=Y,r=Z,s=$}function P(X,Y,Z,$){X=X|0;Y=Y|0;Z=Z|0;$=$|0;o=~s&o|s&$,n=~r&n|r&Z,m=~q&m|q&Y,l=~p&l|p&X}function Q(X){X=X|0;if(X&15)return-1;z[X|0]=d>>>24,z[X|1]=d>>>16&255,z[X|2]=d>>>8&255,z[X|3]=d&255,z[X|4]=e>>>24,z[X|5]=e>>>16&255,z[X|6]=e>>>8&255,z[X|7]=e&255,z[X|8]=f>>>24,z[X|9]=f>>>16&255,z[X|10]=f>>>8&255,z[X|11]=f&255,z[X|12]=g>>>24,z[X|13]=g>>>16&255,z[X|14]=g>>>8&255,z[X|15]=g&255;return 16}function R(X){X=X|0;if(X&15)return-1;z[X|0]=h>>>24,z[X|1]=h>>>16&255,z[X|2]=h>>>8&255,z[X|3]=h&255,z[X|4]=i>>>24,z[X|5]=i>>>16&255,z[X|6]=i>>>8&255,z[X|7]=i&255,z[X|8]=j>>>24,z[X|9]=j>>>16&255,z[X|10]=j>>>8&255,z[X|11]=j&255,z[X|12]=k>>>24,z[X|13]=k>>>16&255,z[X|14]=k>>>8&255,z[X|15]=k&255;return 16}function S(){B(0,0,0,0);t=d,u=e,v=f,w=g}function T(X,Y,Z){X=X|0;Y=Y|0;Z=Z|0;var $=0;if(Y&15)return-1;while((Z|0)>=16){V[X&7](z[Y|0]<<24|z[Y|1]<<16|z[Y|2]<<8|z[Y|3],z[Y|4]<<24|z[Y|5]<<16|z[Y|6]<<8|z[Y|7],z[Y|8]<<24|z[Y|9]<<16|z[Y|10]<<8|z[Y|11],z[Y|12]<<24|z[Y|13]<<16|z[Y|14]<<8|z[Y|15]);z[Y|0]=d>>>24,z[Y|1]=d>>>16&255,z[Y|2]=d>>>8&255,z[Y|3]=d&255,z[Y|4]=e>>>24,z[Y|5]=e>>>16&255,z[Y|6]=e>>>8&255,z[Y|7]=e&255,z[Y|8]=f>>>24,z[Y|9]=f>>>16&255,z[Y|10]=f>>>8&255,z[Y|11]=f&255,z[Y|12]=g>>>24,z[Y|13]=g>>>16&255,z[Y|14]=g>>>8&255,z[Y|15]=g&255;$=$+16|0,Y=Y+16|0,Z=Z-16|0}return $|0}function U(X,Y,Z){X=X|0;Y=Y|0;Z=Z|0;var $=0;if(Y&15)return-1;while((Z|0)>=16){W[X&1](z[Y|0]<<24|z[Y|1]<<16|z[Y|2]<<8|z[Y|3],z[Y|4]<<24|z[Y|5]<<16|z[Y|6]<<8|z[Y|7],z[Y|8]<<24|z[Y|9]<<16|z[Y|10]<<8|z[Y|11],z[Y|12]<<24|z[Y|13]<<16|z[Y|14]<<8|z[Y|15]);$=$+16|0,Y=Y+16|0,Z=Z-16|0}return $|0}var V=[B,C,D,E,F,G,H,I];var W=[D,J];return{set_rounds:K,set_state:L,set_iv:M,set_nonce:N,set_mask:O,set_counter:P,get_state:Q,get_iv:R,gcm_init:S,cipher:T,mac:U}}(a,b,c);return m.set_key=e,m};return m.ENC={ECB:0,CBC:2,CFB:4,OFB:6,CTR:7},m.DEC={ECB:1,CBC:3,CFB:5,OFB:6,CTR:7},m.MAC={CBC:0,GCM:1},m.HEAP_DATA=16384,m}(),T=z.prototype;T.BLOCK_SIZE=16,T.reset=u,T.encrypt=w,T.decrypt=y;var U=A.prototype;U.BLOCK_SIZE=16,U.reset=u,U.process=v,U.finish=w;var V=B.prototype;V.BLOCK_SIZE=16,V.reset=u,V.process=x,V.finish=y;var W=C.prototype;W.BLOCK_SIZE=16,W.reset=u,W.encrypt=w,W.decrypt=y;var X=D.prototype;X.BLOCK_SIZE=16,X.reset=u,X.process=v,X.finish=w;var Y=E.prototype;Y.BLOCK_SIZE=16,Y.reset=u,Y.process=x,Y.finish=y;var Z=new Uint8Array(1048576),$=S(b,null,Z.buffer);a.AES_ECB=z,a.AES_ECB.encrypt=F,a.AES_ECB.decrypt=G,a.AES_ECB.Encrypt=A,a.AES_ECB.Decrypt=B,a.AES_CBC=C,a.AES_CBC.encrypt=H,a.AES_CBC.decrypt=I,a.AES_CBC.Encrypt=D,a.AES_CBC.Decrypt=E;var _=64,aa=20;N.BLOCK_SIZE=_,N.HASH_SIZE=aa;var ba=N.prototype;ba.reset=J,ba.process=K,ba.finish=L;var ca=null;return N.bytes=P,N.hex=Q,N.base64=R,a.SHA1=N,"function"==typeof define&&define.amd?define([],function(){return a}):"object"==typeof module&&module.exports?module.exports=a:b.asmCrypto=a,a}({},function(){return this}());
^
Error: bad padding
at new e (/usr/local/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:219)
at z.y [as decrypt] (/usr/local/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:5266)
at Function.G [as decrypt] (/usr/local/lib/node_modules/homebridge-homesung/vendor/encryption/asmcrypto.js:3:6018)
at Object.decryptData (/usr/local/lib/node_modules/homebridge-homesung/vendor/encryption/index.js:666:41)
at Encryption.decrypt (/usr/local/lib/node_modules/homebridge-homesung/src/connection/encryption.js:16:22)
at Object.handleMessage (/usr/local/lib/node_modules/homebridge-homesung/src/connection/handlers.js:54:54)
at SocketConnection.<anonymous> (/usr/local/lib/node_modules/homebridge-homesung/src/connection/connection.js:35:35)
at WebSocket.emit (events.js:182:13)
at Receiver.receiverOnMessage (/usr/local/lib/node_modules/homebridge-homesung/node_modules/ws/lib/websocket.js:719:20)
at Receiver.emit (events.js:182:13)
Freshly paired and working fine:
[10/1/2018, 7:52:35 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:52:35 PM] [SamsungTV] Requesting device status succeded: on
[10/1/2018, 7:52:35 PM] [SamsungTV] TV status: on
[10/1/2018, 7:52:42 PM] [SamsungTV] CONNECTING
[10/1/2018, 7:52:42 PM] [SamsungTV] Handling initial message
[10/1/2018, 7:52:43 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[9,200,221,251,210,160,103,127,53,172,168,251,205,86,177,224,223,50,85,148,171,249,93,34,12,108,149,124,161,249,204,161,6,97,129,17,225,102,67,127,7,37,24,15,86,248,116,133,117,25,100,4,169,213,230,183,234,206,40,162,180,131,62,206]"}
[10/1/2018, 7:52:43 PM] [SamsungTV] Decrypted message: {"plugin":"NNavi","api":"GetDUID","result":"MTCBBEJVWV74Y"}
[10/1/2018, 7:52:43 PM] [SamsungTV] CONNECTED
[10/1/2018, 7:52:43 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[200,53,43,181,238,17,203,70,129,32,7,37,197,49,237,160,113,214,186,199,35,240,109,37,110,178,230,100,113,1,88,109,147,18,214,132,101,93,14,230,163,104,230,243,68,43,221,150,60,58,70,196,242,241,162,3,171,80,22,228,130,213,47,100]"}
[10/1/2018, 7:52:43 PM] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}}
Executing KEY_POWER (still running fine):
[10/1/2018, 7:54:22 PM] [SamsungTV] Handling keep alive
[10/1/2018, 7:54:24 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:54:24 PM] [SamsungTV] Requesting device status succeded: on
[10/1/2018, 7:54:24 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:54:24 PM] [SamsungTV] Requesting device status succeded: on
[10/1/2018, 7:54:24 PM] [SamsungTV] Setting device to: standby
[10/1/2018, 7:54:25 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receiveCommon","args":"[200,53,43,181,238,17,203,70,129,32,7,37,197,49,237,160,113,214,186,199,35,240,109,37,110,178,230,100,113,1,88,109,147,18,214,132,101,93,14,230,163,104,230,243,68,43,221,150,60,58,70,196,242,241,162,3,171,80,22,228,130,213,47,100]"}
[10/1/2018, 7:54:25 PM] [SamsungTV] Decrypted message: {"plugin":"RemoteControl","api":"SendRemoteKey","result":{}}
But then:
[10/1/2018, 7:56:49 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:56:54 PM] [SamsungTV] Requesting device status failed: ETIMEDOUT
[10/1/2018, 7:56:54 PM] [SamsungTV] TV status: standby
[10/1/2018, 7:57:08 PM] [SamsungTV] Requesting device status
[10/1/2018, 7:57:13 PM] [SamsungTV] Requesting device status failed: ETIMEDOUT
[10/1/2018, 7:57:13 PM] [SamsungTV] TV status: standby
[10/1/2018, 7:58:25 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receivePush","args":"[116,165,112,207,63,7,24,239,219,65,27,1,138,69,45,218,64,144,5,205,94,221,22,129,42,242,23,126,17,18,47,112,125,53,155,189,2,23,56,136,149,207,199,189,253,158,116,179,141,114,212,251,220,85,254,128,196,239,120,29,130,70,56,42,248,81,182,150,185,39,184,169,62,213,204,176,70,141,107,129]"}
[10/1/2018, 7:58:25 PM] [SamsungTV] Decrypted message: {"plugin":"SecondTV","event":6,"data1":"EMP_TV_POWER_OFF","data2":""}
[10/1/2018, 7:58:25 PM] [SamsungTV] Handling message: 5::/com.samsung.companion:{"name":"receivePush","args":"[116,165,112,207,63,7,24,239,219,65,27,1,138,69,45,218,153,164,16,201,60,242,26,59,250,31,192,122,215,165,5,91,64,5,0,44,69,151,111,146,2,9,156,150,203,151,0,172,100,5,131,45,143,186,58,211,237,242,107,234,20,144,199,144,129,76,14,207,93,173,115,197,69,104,239,196,194,45,103,104]"}
[10/1/2018, 7:58:25 PM] [SamsungTV] Decrypted message: {"plugin":"SecondTV","event":9,"data1":"EMP_SOURCE_LIST_CHANGED","data2":""}
[10/1/2018, 7:58:37 PM] [SamsungTV] DISCONNECTED
Andof course, everything keeps working for the moment after multiple power offs, actions, etc.
Just to let you know. The config still works, no crashes, no restarts needed, playing with all the exposed buttons when the TV is on and off, including the KEY_POWER (defined in the "power": section), and running automations for turning off the TV on Good Night and when no guest and family outside geofence. Thanks again for building this as it is currently the only working plugin for my J-serie Samsung TV.