vniehues / homebridge-saphi-tv

This plug-in provides Homebridge support for Philips TVs running SaphiOS.
Apache License 2.0
9 stars 2 forks source link

Pugin keeps turning TV off #14

Closed luc-ass closed 3 years ago

luc-ass commented 3 years ago

Describe The Bug: The TV keeps turning off without any user input. After some investigation I found, that the homebridge plugin keeps turning the TV off after requesting its status. This behavior is new. The plugin has been working without a hitch for about a week (when we got the TV). Restarting Homebridge did not solve the problem.

To Reproduce: Unclear

Expected behavior: TV should stay on after status request.

Logs:

[7/8/2021, 9:52:50 AM] [Wohnzimmer Fernseher] Get Active
[7/8/2021, 9:52:56 AM] [Wohnzimmer Fernseher] set Active => 0

Plugin Config:

{
    "name": "Wohnzimmer Fernseher",
    "ip_adress": "10.14.XX.XX",
    "wol_adress": "wol://28:AD:18:XX:XX:XX",
    "has_tv_channels": false,
    "channel_setup_popup_time": 2250,
    "startup_time": 15,
    "timeout": 5,
    "input_delay": 650,
    "api_version": 6,
    "api_port_no": 1925,
    "protocol": "http",
    "polling_interval": 40,
    "has_ambilight": true,
    "has_ambihue": true,
    "ambi_poweroff": false,
    "ambi_poweron": false,
    "inputs": [
        {
            "type": "TV"
        }
    ],
    "platform": "SaphiTV"
}

Screenshots:

Environment:

vniehues commented 3 years ago

Hey @luc-ass! Thank you for opening this issue. Can you please tell me the plugin version you are currently using?

luc-ass commented 3 years ago

Sorry, must have skipped the entry above. It's 0.0.27. I updated it above.

vniehues commented 3 years ago

As you can see from the following code:

    // handle on / off events using the Active characteristic
    this.tvService.getCharacteristic(this.platform.Characteristic.Active)
      .on('set', (newValue, callback) => {
        callback(null);
        this.SetActive(newValue);
        this.platform.log.debug('set Active => ' + newValue);
      })
      .on('get', (callback) => {
        this.GetActive(callback);
        this.platform.log.debug('Get Active');
      });

more specifically:

.on('set', (newValue, callback) => {
        callback(null);
        this.SetActive(newValue);
        this.platform.log.debug('set Active => ' + newValue);
      })

this is the code that is called when homekit sets a value. the getter does not set any values. Did you recently change anything about your homekit setup? - Maybe updated a device to a new iOS version? (15?)

I would suggest you update the plugin to its latest beta with the following command: sudo npm install -g homebridge-saphi-tv@beta

I've added many bugfixes and improved the overall performance. It is still in beta because I'm currently not able to spend much time working on it.

luc-ass commented 3 years ago

Yeah, that's why I was really confused by this weird behavior. I was already expecting the TV to be defective. As I have developed my own HomeKit plug-ins I did not suspect this behavior at first.

I will install the beta plug-in now and let you know whether their behavior persists or whether it is fixed.

Thank you again for your incredibly quick response!

luc-ass commented 3 years ago

Okay, installing the latest beta and running it with the previous configuration did work for a few minutes but started the same behavior after that. Also, updating the configuration via the web interface caused an error during boot:

[7/8/2021, 10:56:20 AM] [Wohnzimmer Fernseher] Finished launching platform: SaphiTV
[7/8/2021, 10:56:20 AM] [Wohnzimmer Fernseher] removing all accessories
[7/8/2021, 10:56:20 AM] TypeError: Cannot read property 'filter' of undefined
    at new TelevisionAccessory (/homebridge/node_modules/homebridge-saphi-tv/src/tvAccessory.ts:44:45)
    at SaphiTvPlatform.publishExampleExternalAccessory (/homebridge/node_modules/homebridge-saphi-tv/src/platform.ts:64:5)
    at HomebridgeAPI.<anonymous> (/homebridge/node_modules/homebridge-saphi-tv/src/platform.ts:31:12)
    at HomebridgeAPI.emit (events.js:387:35)
    at HomebridgeAPI.signalFinished (/usr/local/lib/node_modules/homebridge/src/api.ts:275:10)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:173:14)

Reverting back to the old configuration (for v.0.0.27) allows homebridge to start again... I'll keep an eye on it.

FYI: here are my configuration-files:

config

```json v0.0.27 { "name": "Wohnzimmer Fernseher", "ip_adress": "10.14.70.81", "wol_adress": "wol://28:AD:18:AC:AC:46", "has_tv_channels": false, "channel_setup_popup_time": 2250, "startup_time": 15, "timeout": 5, "input_delay": 650, "api_version": 6, "api_port_no": 1925, "protocol": "http", "polling_interval": 40, "has_ambilight": true, "has_ambihue": true, "ambi_poweroff": false, "ambi_poweron": false, "inputs": [ { "type": "TV" } ], "platform": "SaphiTV" } v0.0.28-10 { "name": "Wohnzimmer Fernseher", "ip_adress": "10.14.70.81", "wol_adress": "28:AD:18:AC:AC:46", "has_tv_channels": false, "channel_setup_popup_time": 2250, "startup_time": 15, "timeout": 5, "input_delay": 650, "api_version": 6, "api_port_no": 1925, "protocol": "http", "polling_interval": 40, "has_ambilight": true, "multirow_apps": false, "vertical_inputs": false, "has_ambihue": true, "ambi_poweroff": false, "ambi_poweron": false, "platform": "SaphiTV" } ```

luc-ass commented 3 years ago

On a side note, the plugin throws uncaught exemptions if the TV is unreachable:

(node:1743) UnhandledPromiseRejectionWarning: FetchError: request to http://10.14.70.81:1925/6/input/key failed, reason: connect EHOSTUNREACH 10.14.70.81:1925
    at ClientRequest.<anonymous> (/homebridge/node_modules/homebridge-saphi-tv/node_modules/node-fetch/lib/index.js:1461:11)
    at ClientRequest.emit (events.js:375:28)
    at Socket.socketErrorListener (_http_client.js:475:9)
    at Socket.emit (events.js:375:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(node:1743) 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: 43)
luc-ass commented 3 years ago

For now it seems as if power cycling the TV made the error go away. I have no idea how Saphi OS was ever allowed out of the lab (as for the network problems and the extremely buggy hue support), but there you have it. Now to find a way how to power cycle the TV on a regular basis. 😅

vniehues commented 3 years ago

Thank you for the detailed responses! :)

Updating the config should not throw errors (obviously) - I'll look into that.

Thats strange. I thought I handled the EHOSTUNREACH Error... thanks for the heads-up!

Yeah Saphi OS is extremly unstable. Also not all functions are implemented (properly or at all) and when you send too many requests the built-in webserver will just shut down until you power-cycle your TV by unplugging it for atleast 30 seconds.

As for power-cycling your TV on a regular basis (seems like a bad fix but I don't know a better one): how about a simple smart plug? homekit automations. done :)

If you have any other issues please let me know! I will be closing this one later today :)

luc-ass commented 3 years ago

Okay, that gave me some insight. I reduced the number of requests from a separate http-switch for the ambilight from 5 sec to 30 sec. Perhaps that reduces problems. Also I moved to ethernet...

vniehues commented 3 years ago

I hope that those steps solve your problem!