merdok / homebridge-webos-tv

Homebridge plugin for LG webOS TVs
MIT License
664 stars 89 forks source link

"luna send" popup whenever settiing the screen brightness #375

Closed samerziade closed 3 years ago

samerziade commented 3 years ago

If I have the TV brightness as a separate switch, whenever I change it's percentage values I get an alert on the TV that says "luna send" with an OK button that never disappears.

merdok commented 3 years ago

Hi, can you post a debug log from the point when that happens?

sfla commented 3 years ago

This is happening to me too. I have added these

"pictureModeButtons": [{
        "pictureMode": "dolbyHdrGame",
        "name": "Game"
    },
    {
        "pictureMode": "dolbyHdrStandard",
        "name": "Standard"
    }
]

and whenever I use them, there's a popup on the TV saying

LUNASEND lunaSend [Ok]

What kind of debug log do you want, where do I find it? I've enabled deep debug logs, but there's nothing happening in the output from homebridge whenever I do anything.

merdok commented 3 years ago

As stated in the README the deep debug log property has only an effect if you start homebridge in debug log. So you need to start homebridge with the -D flag in debug mode like that: homebridge -D. Then you need to replicate the issue and watch the log for information which pops there.

sfla commented 3 years ago

This is when attempting to "flick the switch" for changing picture mode to "Game": I have a LG 65B7V or something, it has firmware version 06.00.05, and webOS version 3.9.0-62705 (dreadlocks2-dudhwa). Running Homebridge from a raspberry pi.

[28.6.2021, 22:17:32] [webostv] [StiTV] system.notifications service - createAlert requested. Title: lunaSend, Message: lunaSend, Type: confirm, Modal: true
[28.6.2021, 22:17:32] [webostv] [StiTV] Message from TV 

[28.6.2021, 22:17:32] [webostv] [StiTV]  {
  type: 'utf8',
  utf8Data: '{"type":"response","id":"814d1cda000f","payload":{"returnValue":true,"alertId":"com.webos.service.apiadapter-1624911453362"}}'
}
[28.6.2021, 22:17:32] [webostv] [StiTV] {
  "returnValue": true,
  "alertId": "com.webos.service.apiadapter-1624911453362"
}
[28.6.2021, 22:17:32] [webostv] [StiTV] system.notifications service - closeAlert requested. Alert id: com.webos.service.apiadapter-1624911453362
[28.6.2021, 22:17:32] [webostv] [StiTV] Message from TV 

[28.6.2021, 22:17:32] [webostv] [StiTV]  {
  type: 'utf8',
  utf8Data: '{"type":"error","id":"814d1cda0010","error":"404 no such service or method","payload":{}}'
}
[28.6.2021, 22:17:32] [webostv] [StiTV] Unknown error while requesting closeAlert from service system.notifications
lunasend

The first line in the logs looks suspicious, causing exactly what I see. I wonder why it's there?

merdok commented 3 years ago

The log looks fine, it works as expected, but it seems like older webOS TVs do not have the closeAlert service... Does the control center remote work for you? If so then i will fallback to the ENTER button on older webOS TVs.

sfla commented 3 years ago

Yes, I can use Enter, all directions, and back. But the picture-mode-action triggering this popup doesn't actually work. It's not changing the picture mode.

merdok commented 3 years ago

The picture mode should change after you press the ok button, if that is not the case then your TV probably does not support the specified picture modes.

sfla commented 3 years ago

Oh wait, if I push the button twice in a row it seems to work:

  1. Be on "Standard" picture mode
  2. Activate/swipe "Game" picture mode
  3. Popup appears, but picture mode is not changed
  4. Activate/swipe "Game" again (without closing popup!!)
  5. Picture mode is changed
  6. close popup

If I close the popup after the first swipe, it just shows the popup again without changing the picture mode.

merdok commented 3 years ago

I will provide a hotfix update in a moment which should fix the popup issue.

merdok commented 3 years ago

@sfla please try version 2.2.1, the popup should now not appear anymore.

sfla commented 3 years ago

The popup now flashes for a frame before disappearing, which is completely fine. Sadly, it didn't fix the issue regarding not actually changing the picture mode. And since the message is now dismissed immediately, I'm no longer able to call the action twice to force it. Strange! Race condition? Or maybe it somehow needs to be called twice before you dismiss it?

merdok commented 3 years ago

Nothing needs to be called twice, it either works or not, If it does not change the picture mode after it disappears once then your tv most probably does not support the specified picture mode.

sfla commented 3 years ago

As I stated in previous comment, it did work if I called the action twice. Once to show the popup, then once again WHILE the popup was visible. It seems like the action needs to be called while this popup is visible, and that the current implementation somehow tries to change the picture mode before the popup has appeared. So it's most definitely supported.

merdok commented 3 years ago

You can try to replace this code lines: https://github.com/merdok/homebridge-webos-tv/blob/9ccfb407392986a3a2ebfea1e490da43c42b9dd0/lib/LgTvController.js#L1113-L1119

with this code:

let result = this.openAlert('lunaSend', 'lunaSend', true, buttons, onClose, onFail, 'confirm', true).then((res) => {
      if (res && res.alertId && this.getWebOsVersion() >= 4) {
        this.closeAlert(res.alertId); // seems that the close alert service is only available on webos4 or higher
      } else {
        let result = this.openAlert('lunaSend', 'lunaSend', true, buttons, onClose, onFail, 'confirm', true).then((res) => {
          this.sendRemoteInputSocketCommand('ENTER');
        })
      }
    })

And let me know if that works for you.

sfla commented 3 years ago

It took me an hour to wrap my head around building stuff for Homebridge, but it worked like a charm! The popup occasionally blinks twice now (when going from Game to Standard), but that's no problem. It now successfully changes the picture mode every time. Thanks, man! And excellent response time.

Another question: I literally ONLY need the ability to change between Game and Standard picture mode through the Home-app. Power and inputs etc are all controlled by the connected devices. The layout for this TV in the Home app is pretty darn hideous. Is it possible to customize the layout? This is what I'm looking at:

home

I don't need the power-button, and the modes don't have to be huge switches, they can just be two small buttons. Is that possible? (I.E I would prefer to only have two small circular buttons in the top, one for Game, one for Standard)

Related; maybe this is supported now? https://github.com/merdok/homebridge-webos-tv/blob/9ccfb407392986a3a2ebfea1e490da43c42b9dd0/index.js#L355-L363

merdok commented 3 years ago

Good to hear that it works now :) Seems like that code is required for TVs with webOS lower then 4.0, will update that.

As for you questions, you should be able to hide the power button with the hideTvService property. After that you can ungroup the two mode tiles in the home app which should give you two separate buttons. Or just simply straight ungroup the tiles.

As for the code, this is not supported by Home app, adding this characteristic does not change anything in the Home app UI, so Apple first needs to implement it... but they taking themselves time since this is already since a long time but no support in the Home app still...

sfla commented 3 years ago

Perfect! Enabling "Hide the TV Services" did the trick. The only side-effect this had (obviously) is that the icon for the TV changed from a "TV icon" to a "Switch icon". In addition, the "state" of the icon is always "off" regardless of the TV's power status. This makes complete sense, though. Still, it's now a lot easier to use, thanks! In a perfect world I'd prefer to keep the TV-icon for the group, and that the group mimics the power state of the actual TV (but preferably without having the power-button inside). I can understand that this might be literally impossible to implement though. Thanks for all your help. I didn't create this issue, but I'm pretty certain it can be closed.

merdok commented 3 years ago

Glad it works👍

Unfortunately we do not live in an ideal world😅 If you want to see the status of the tv then you need to have that power button enabled which is part of the tv service, this is also the switch which is used for the group tile to show the status. If you hide the tv service then you will lose all that information.