Giter Club home page Giter Club logo

Comments (2)

johngrinders avatar johngrinders commented on July 18, 2024

Now, I noticed also random on and off when the TV is off. I didn't notice before, but how the TV statuses were needed, this error immediately surfaced. Now, in a matter of seconds, the TV turned on several times.
Uploading 5C689FBC-5D9B-467C-8FF9-39DB082307C3.png…

from homey-webos-plus.

MaxvandeLaar avatar MaxvandeLaar commented on July 18, 2024

@jseverinson @johngrinders Some users also asked this question on the Athom forum and this is something rather difficult for me to debug without access to debug logging and your tv. None of those will be possible of course. I anticipated possible on/off issues with some tv's as the LG tv's are a bit inconsistent when it comes to letting me know if a tv is on or off and when it actually changes state. Therefore, I have created a different method to detect the state, however, this is deactivated by default. You can switch methods in the Homey TV device settings.

Of course please rule out any networking issues you might face, I advise to always connect the tv with an ethernet cable. If you have any further questions or issues regarding tv on/off state feel free to open the issue 😉

Here is the explanation I have on the forum:

So after I explained how this works to someone else before I noticed I chose horrible labels as it can get a bit confusing; sorry for that 😉

So how it works… (the dumbed down explanation)

The TV sends messages to my app when it powers off. However, what kind of messages and the order they are send differ almost per TV and software version. It is a bit chaotic.

This can be controlled by the Timeout power off check. By setting it to 10000 it will tell the app to wait 10 seconds after it received an ‘Off’ notification from the TV to set it to off in the app. This is due to the strange order of the notifications. For example, I sometimes receive an TV is off notification and after that a TV is going in suspended mode… while the actual order is suspended (but the status of the tv is still active) and then it turns off. The code for that looks like this:

      timer = setTimeout(() => {
        this.log(`_powerStateListener: Called timeout`, status, processing);

        //Screen saver(?) should tv be turned on?
        if (((status === 'active' || status === 'screen saver' || status === 'screen off') && !processing) ||
          (processing &&
            (
              processing.includes('on') ||
              processing.includes('ready') ||
              processing.includes('resume') ||
              processing.includes('saver')
            )
          )
        ) {
          handleOn();
        } else if ((!processing && status !== 'active' && status !== 'screen off') ||
          (processing && (
              processing.includes('standby') ||
              processing.includes('suspend') ||
              processing.includes('off')
            )
          )
        ) {
          handleOff();
        }

        clearTimeout(timer);
        timer = null;
      }, this.getSettings().powerStateTimeout || 2000);

Some TV’s actually never send these notifications or only partially. Therefore, I also implemented the possibility to use a simple network polling method.

If the Power off check is not working for you (which it isn’t in this case) you can set Use polling... to Yes.

Now the other to params come into play.

The Poll interval on/off check is simply the interval the app will poll. So in the default case it will check if the TV is on/off every 10 seconds and it will give the TV 8 seconds (Poll timeout on/off check) to tell it’s alive, else it’s dead so it’s turned off. The Poll timeout should never be higher than the Poll interval. You can play with these two parameters to find the perfect settings for you. It might be possible that due to a slow network or just slow TV the TV needs more than 8 seconds to respond to a poll. So I would suggest to start with a poll interval of 30 seconds and give the TV 20 seconds to reply. If that works, just try to lower the values until you find the sweet spot.

from homey-webos-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.