tavicu / homebridge-samsung-tizen

Homebridge plugin for Samsung TV's with Tizen OS
MIT License
646 stars 89 forks source link

"TV is offline" error #478

Closed StefanScanteie closed 2 years ago

StefanScanteie commented 2 years ago

Hello,

I have two Samsung Q series in the same house, the same Wi-Fi network connected to the same Homebridge. One is a Q7 series that works perfectly fine with the plugin, absolutely no issues. The other one, a Q8 series, works fine, "answers" to my morning automation, but in the Homebridge log I have this error:

[17/02/2022, 09:00:13] [Samsung TV Q8] TV is offline

Clearly, it is not offline :), as it is working with my automations, streaming platforms are working perfectly fine etc.

tavicu commented 2 years ago

That error appears when you try to send a command, make an action and the TV is offline.

What are you trying to do? When do you get that error?

StefanScanteie commented 2 years ago

The error appears ONLY when the TV si powered ON by a personal automation set in the Home app. And this happen every morning. But the TV powers ON as expected.

Any other action (manual on/off, changing sources) does not throw this error.

tavicu commented 2 years ago

What does the automation is set to do?

Because form what you are telling me is that the automation triggers turn on command and something else. The problem with HomeKit is that automations send the commands at the same time, without delay (we are fixing it in another issue) and the "something else" command is triggered when the TV was not turned on yet.

StefanScanteie commented 2 years ago

When my wake-up alarm is stopped Set Top Lights, Wait, Set Samsung TV Q8

Basically, after I turn off my morning alarm, this personal automation will (a) turn on my kitchen top lights, (b) waits for 5 seconds and then (c) turns on the TV. And the TV turns ON. Is just the error that bugs me :).

tavicu commented 2 years ago

What inputs do you have set? Which is the first input?

Also you can start the homebridge in debug mode to see which command is throwing that error.

StefanScanteie commented 2 years ago
{
            "name": "SamsungTizen",
            "app_list": false,
            "devices": [
                {
                    "name": "Samsung TV Q8",
                    "ip": "192.168.1.138",
                    "mac": "00:00:00:00:00:00",
                    "refresh": {
                        "main": 1000,
                        "switch": 1000
                    },
                    "inputs": [
                        {
                            "type": "command",
                            "name": "Live TV",
                            "value": "KEY_SOURCE,KEY_RIGHT*5,KEY_ENTER"
                        },
                        {
                            "type": "app",
                            "name": "YouTube",
                            "value": "111299001912"
                        },
                        {
                            "type": "app",
                            "name": "Netflix",
                            "value": "11101200001"
                        },
                        {
                            "type": "app",
                            "name": "Apple TV",
                            "value": "3201807016597"
                        },
                        {
                            "type": "app",
                            "name": "Prime Video",
                            "value": "3201512006785"
                        },
                        {
                            "type": "app",
                            "name": "HBO Max",
                            "value": "3201601007230"
                        }
                    ]
                },

This is my config for this particular TV. I changed the MAC Address for this conversation.

Sure, I can run Homebridge in debug mode and come back tomorrow morning when this will occur.

StefanScanteie commented 2 years ago

Hello,

Here is the debug output:

[18/02/2022, 09:00:14] [Samsung TV Q8] TV is offline
[18/02/2022, 09:00:14] [Samsung TV Q8] [DEBUG] TvOfflineError: TV is offline
    at /usr/local/lib/node_modules/homebridge-samsung-tizen/lib/services/television.js:101:23
    at runMicrotasks (<anonymous>)
    at runNextTicks (node:internal/process/task_queues:61:5)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7)

As previously stated, the TV did power on correctly.

tavicu commented 2 years ago

Yup, the error comes from a line that try to set an input. So HomeKit sends 2 commands. One to turn on the TV and the 2nd to change the input. It send them at the same time.

The turn ON command works well but the 2nd to change the input will fail because it see the TV as offline and throw the error.

What you can do in your automation is to edit it and remove the TV then add it again without long pressing the pill to open the popup where you can set which input to set.

Also, this will be fixed in another feature we are working on.

StefanScanteie commented 2 years ago

Hello!

It took me a few days, but I can confirm that your workaround works. I no longer have the error in Homebridge.